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

add objects(2)

parent d0ebf97f
......@@ -14,7 +14,8 @@ public class Enemy : MonoBehaviour {
}
// Update is called once per frame
void Update () {
void FixedUpdate()
{
if (HP <= 0)
{
Destroy(gameObject);
......
......@@ -28,7 +28,7 @@ public class Hole : MonoBehaviour {
IEnumerator HoleLogic()
{
while (mainLogic.gameOverUI.gameObject.activeSelf==false)
while (mainLogic.GameOverUI.gameObject.activeSelf==false)
{
yield return new WaitForSeconds(2.0f/(level));
var nowunit = Instantiate<Unit>(unitObject);
......
......@@ -5,16 +5,19 @@ using System.Collections.Generic;
using UnityEngine.SceneManagement;
public class MainLogic : MonoBehaviour {
public GameOverUI gameOverUI;
public GameOverUI GameOverUI;
public SpaceUI SpaceUI;
public MoneyManager moneyManager;
public Enemy EnemyObject;
public Hole HoleObject;
public GameObject CreateButton;
public Button DestroyButton;
public Image NatureImage;
public Slider DestroySlider;
Hole[] Holes = new Hole[8];
float nextSpwnrate = 0.5f;
int destroyCoolTime = 500;
int nowDestroyCoolTime = 500;
int destroyCoolTime = 200;
int nowDestroyCoolTime = 200;
// Use this for initialization
void Start () {
StartCoroutine(GameLogic());
......@@ -22,7 +25,12 @@ public class MainLogic : MonoBehaviour {
}
// Update is called once per frame
void Update () {
void FixedUpdate()
{
if (moneyManager.nowMoney > 291000)
NatureImage.color = Color.yellow;
else
NatureImage.color = Color.red;
if (moneyManager.nowMoney < 0)
OnGodnessClicked();
if (nowDestroyCoolTime > 0)
......@@ -31,12 +39,13 @@ public class MainLogic : MonoBehaviour {
if (nowDestroyCoolTime == 0)
DestroyButton.interactable = true;
}
DestroySlider.value = (float)nowDestroyCoolTime / destroyCoolTime;
}
public void OnGodnessClicked()
{
moneyManager.gameObject.SetActive(false);
gameOverUI.gameObject.SetActive(true);
gameOverUI.nowrate = nextSpwnrate.ToString();
GameOverUI.gameObject.SetActive(true);
GameOverUI.nowrate = nextSpwnrate.ToString();
}
public void OnCreateButtonClicked()
......@@ -46,7 +55,7 @@ public class MainLogic : MonoBehaviour {
IEnumerator GameLogic()
{
while (gameOverUI.gameObject.activeSelf == false)
while (GameOverUI.gameObject.activeSelf == false)
{
int direction = Random.Range(0, 4);
Enemy nowEnemy;
......@@ -120,9 +129,29 @@ public class MainLogic : MonoBehaviour {
moneyManager.nowMoney += Holes[nowIndex].level * 6000;
moneyManager.holeMoney -= Holes[nowIndex].level * 300;
DestroyButton.interactable = false;
destroyCoolTime += 100;
destroyCoolTime += 50;
nowDestroyCoolTime = destroyCoolTime;
Destroy(Holes[nowIndex].gameObject);
}
public void Nature()
{
if(NatureImage.color == Color.red)
{
if (Random.Range(0f, 1f) < 0.005)
{
Time.timeScale = 0;
SpaceUI.gameObject.SetActive(true);
}
}
else
{
foreach (Unit u in FindObjectsOfType<Unit>())
{
if (moneyManager.nowMoney > 291000)
moneyManager.nowMoney -= 200;
u.Atk += 5;
}
}
}
}
......@@ -18,7 +18,7 @@ public class MoneyManager : MonoBehaviour {
}
// Update is called once per frame
void Update () {
void FixedUpdate () {
index++;
int totalMoneyDelta = baseMoneyDelta - holeMoney - peopleMoney;
if (index > 50)
......
using UnityEngine;
using System.Collections;
public class SpaceUI : MonoBehaviour {
MainLogic mainLogic;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void makeHelp()
{
}
}
fileFormatVersion: 2
guid: 55f5afd97a8074942bc5df674e7ed26b
timeCreated: 1452919314
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -19,7 +19,7 @@ public class Unit : MonoBehaviour
}
// Update is called once per frame
void Update()
void FixedUpdate()
{
if (HP <= 0)
{
......
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