Commit d0ebf97f authored by 황호기's avatar 황호기

make objects

parent d6949141
fileFormatVersion: 2
guid: 22a2cc57e1dcbab4a96c47135f10ddf3
timeCreated: 1452901047
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
......@@ -5,12 +5,21 @@ public class Enemy : MonoBehaviour {
// Use this for initialization
Vector3 movedirection;
public MainLogic mainLogic;
public TextMesh hpText;
public Transform hpbar;
public int HP = 100;
void Start () {
hpText.GetComponent<MeshRenderer>().sortingOrder = 5;
}
// Update is called once per frame
void Update () {
if (HP <= 0)
{
Destroy(gameObject);
mainLogic.moneyManager.nowMoney += 500;
}
if (movedirection.magnitude != 0 && (movedirection.x * (new Vector3(-2.2f, 0f, 0) - transform.position).x < 0 || movedirection.y * (new Vector3(-2.2f, 0f, 0) - transform.position).y < 0))
{
mainLogic.OnGodnessClicked();
......@@ -26,5 +35,8 @@ public class Enemy : MonoBehaviour {
}
transform.Translate(movedirection / movedirection.magnitude / 60);
hpbar.localPosition = new Vector3((1-(float)HP / 100) * -3.5f, 5, 0);
hpbar.localScale = new Vector3((float)HP / 2, 10, 1);
hpText.text = HP.ToString();
}
}
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using UnityEngine.SceneManagement;
public class GameOverUI : MonoBehaviour {
public string nowrate;
public Text rateText;
// Use this for initialization
void Start () {
......@@ -11,7 +13,7 @@ public class GameOverUI : MonoBehaviour {
// Update is called once per frame
void Update () {
rateText.text = "도달 생성률 : " + nowrate;
}
public void ReturnIntro()
{
......
using UnityEngine;
using System.Collections;
using UnityEngine;
using System.Collections;
public class Hole : MonoBehaviour {
int level;
// Use this for initialization
void Start () {
level = 1;
}
// Update is called once per frame
void Update () {
public int level;
public Unit unitObject;
public TextMesh lvText;
public MainLogic mainLogic;
// Use this for initialization
void Start()
{
lvText.GetComponent<MeshRenderer>().sortingOrder = 5;
level = 1;
StartCoroutine(HoleLogic());
}
// Update is called once per frame
void Update () {
lvText.text = "lv." + level;
}
public void SetPosition(int index)
{
if(index>4)
if(index>3)
index++;
transform.position = new Vector3(Random.Range(-6.6f + 2.9f * (index % 3), -3.7f + 2.9f * (index % 3)), Random.Range(-4.8f + 3.2f * (index / 3), -1.6f + 3.2f * (index / 3)), 0);
}
}
}
IEnumerator HoleLogic()
{
while (mainLogic.gameOverUI.gameObject.activeSelf==false)
{
yield return new WaitForSeconds(2.0f/(level));
var nowunit = Instantiate<Unit>(unitObject);
nowunit.mainLogic = mainLogic;
nowunit.transform.position = transform.position;
mainLogic.moneyManager.peopleMoney += 30;
}
}
}
......@@ -9,34 +9,39 @@ public class MainLogic : MonoBehaviour {
public MoneyManager moneyManager;
public Enemy EnemyObject;
public Hole HoleObject;
public GameObject CreateButton;
public Button DestroyButton;
Hole[] Holes = new Hole[8];
float nextSpwnTime = 2f;
float nextSpwnrate = 0.5f;
int destroyCoolTime = 500;
int nowDestroyCoolTime = 500;
// Use this for initialization
void Start () {
StartCoroutine(GameLogic());
DestroyButton.interactable = false;
}
// Update is called once per frame
void Update () {
if (moneyManager.nowMoney < 0)
OnGodnessClicked();
if (nowDestroyCoolTime > 0)
{
nowDestroyCoolTime--;
if (nowDestroyCoolTime == 0)
DestroyButton.interactable = true;
}
}
public void OnGodnessClicked()
{
moneyManager.gameObject.SetActive(false);
gameOverUI.gameObject.SetActive(true);
gameOverUI.nowrate = nextSpwnrate.ToString();
}
public void Create()
public void OnCreateButtonClicked()
{
int nowIndex = Random.Range(0, 8);
if(Holes[nowIndex] != null)
{
}
else
{
(Holes[nowIndex] = Instantiate<Hole>(HoleObject)).SetPosition(nowIndex);
moneyManager.holeMoney += 1000;
}
CreateButton.SetActive(!CreateButton.activeSelf);
}
IEnumerator GameLogic()
......@@ -54,7 +59,70 @@ public class MainLogic : MonoBehaviour {
else
(nowEnemy = Instantiate<Enemy>(EnemyObject)).transform.position = new Vector3(Random.Range(-6.5f, 2.1f), 4.8f, 0);
nowEnemy.mainLogic = this;
yield return new WaitForSeconds(nextSpwnTime);
yield return new WaitForSeconds(1/nextSpwnrate);
nextSpwnrate += 0.02f;
}
}
public void create()
{
CreateButton.SetActive(false);
for (int i = 0; i < 8; i++)
{
if (Holes[i] == null)
break;
if (i == 7)
return;
}
int nowIndex = Random.Range(0, 8);
while (Holes[nowIndex] != null)
nowIndex = Random.Range(0, 8);
(Holes[nowIndex] = Instantiate<Hole>(HoleObject)).SetPosition(nowIndex);
Holes[nowIndex].mainLogic = this;
moneyManager.holeMoney += 300;
}
public void Upgrade()
{
CreateButton.SetActive(false);
for (int i = 0; i < 8; i++)
{
if (Holes[i] != null && Holes[i].level<19)
break;
if (i == 7)
return;
}
int nowIndex = Random.Range(0, 8);
while (Holes[nowIndex] == null || Holes[nowIndex].level == 19)
nowIndex = Random.Range(0, 8);
Holes[nowIndex].level++;
moneyManager.holeMoney += 300;
}
public void Destroy()
{
for (int i = 0; i < 8; i++)
{
if (Holes[i] != null)
break;
if (i == 7)
return;
}
int nowIndex = Random.Range(0, 8);
while (Holes[nowIndex] == null)
nowIndex = Random.Range(0, 8);
foreach (Enemy e in FindObjectsOfType<Enemy>())
{
e.HP -= 40 + Holes[nowIndex].level * 10;
}
moneyManager.nowMoney += Holes[nowIndex].level * 6000;
moneyManager.holeMoney -= Holes[nowIndex].level * 300;
DestroyButton.interactable = false;
destroyCoolTime += 100;
nowDestroyCoolTime = destroyCoolTime;
Destroy(Holes[nowIndex].gameObject);
}
}
......@@ -4,7 +4,7 @@ using System.Collections;
public class MoneyManager : MonoBehaviour {
int maxMoney = 291000;
int nowMoney = 39393;
public int nowMoney = 39393;
int baseMoneyDelta = 3939;
public int holeMoney = 0;
public int peopleMoney = 0;
......
using UnityEngine;
using System.Collections;
public class Unit : MonoBehaviour
{
// Use this for initialization
Vector3 movedirection;
public MainLogic mainLogic;
public TextMesh hpText;
public Transform hpbar;
public Transform target;
public int HP = 200;
public int MaxHP = 200;
public int Atk = 10;
void Start()
{
hpText.GetComponent<MeshRenderer>().sortingOrder = 5;
target = transform;
}
// Update is called once per frame
void Update()
{
if (HP <= 0)
{
mainLogic.moneyManager.peopleMoney -= 30;
Destroy(gameObject);
}
if(target!=null)
movedirection = target.position - transform.position;
if (target != null && movedirection.magnitude != 0)
transform.Translate(movedirection / movedirection.magnitude / 30);
hpbar.localPosition = new Vector3((1 - (float)HP / MaxHP) * -3.5f, 5, 0);
hpbar.localScale = new Vector3((float)HP / MaxHP*50, 10, 1);
hpText.text = HP.ToString();
}
void OnTriggerStay2D(Collider2D other)
{
if ((target == null || target == transform) && other.tag == "enemy")
{
target = other.transform;
}
}
public void Attack(Enemy enemy)
{
HP -= 10;
enemy.HP -= Atk;
}
}
fileFormatVersion: 2
guid: 75d0e5c9eb1805949b30cb20e9f0a040
timeCreated: 1452900758
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System.Collections;
public class UnitBody : MonoBehaviour {
public Unit myUnit;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerStay2D(Collider2D other)
{
if (other.tag == "enemy")
{
myUnit.Attack(other.GetComponent<Enemy>());
}
}
}
fileFormatVersion: 2
guid: 119f9ee7840ab4d46856a6b2e77b2228
timeCreated: 1452900917
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: fdf82c3d91edbbb439765ba3e047c8ba
timeCreated: 1452899576
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 16
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 8
buildTargetSettings: []
spriteSheet:
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment