From 42e61f4d81951bee9b25e7bcf17f4e9080a8ba74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=8C=90=EB=8F=8C?= Date: Thu, 2 Nov 2023 08:56:09 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=8C=EC=9E=84=20=ED=95=9C=EC=82=AC?= =?UTF-8?q?=EC=9D=B4=ED=81=B4=2050%=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Client/Assets/1_Script/Info/BuildingCtrl.cs | 4 ++-- Client/Assets/1_Script/Info/SummonsUnit.cs | 3 ++- Client/Assets/1_Script/Info/UnitCtrl.cs | 19 ++++++++++++++++++- Client/Assets/1_Script/PlayCtrl.cs | 7 +++++++ 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Client/Assets/1_Script/Info/BuildingCtrl.cs b/Client/Assets/1_Script/Info/BuildingCtrl.cs index 81786f92..d0666930 100644 --- a/Client/Assets/1_Script/Info/BuildingCtrl.cs +++ b/Client/Assets/1_Script/Info/BuildingCtrl.cs @@ -1,6 +1,5 @@ using MEC; using System.Collections.Generic; -using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; @@ -55,6 +54,7 @@ public class BuildingCtrl : MonoBehaviour Debug.Log("°Ç¹°ÀÌ ÃÖ´ë ·¹º§ ÀÔ´Ï´Ù."); return; } + PlayCtrl.Instance.player.buildings[lineCount].units.Add(unitInfo); buildingLevel++; } @@ -76,6 +76,6 @@ public class BuildingCtrl : MonoBehaviour this.unitInfo = unitInfo; img.sprite = unitImg; img.color = Color.white; - buildingLevel++; + LevelUp(); } } diff --git a/Client/Assets/1_Script/Info/SummonsUnit.cs b/Client/Assets/1_Script/Info/SummonsUnit.cs index 7cacc915..315bb373 100644 --- a/Client/Assets/1_Script/Info/SummonsUnit.cs +++ b/Client/Assets/1_Script/Info/SummonsUnit.cs @@ -5,6 +5,7 @@ public class SummonsUnit : MonoBehaviour { public bool isEnemy; public List buildings; + public int campHp; //Å×½ºÆ®¿ëµµ public UnitCtrl unit; @@ -12,7 +13,7 @@ public class SummonsUnit : MonoBehaviour private void Awake() { buildings = new List(); - + campHp = 500; buildings.Add(new BuildingInfo()); buildings.Add(new BuildingInfo()); buildings.Add(new BuildingInfo()); diff --git a/Client/Assets/1_Script/Info/UnitCtrl.cs b/Client/Assets/1_Script/Info/UnitCtrl.cs index ed684e8d..e4f144a1 100644 --- a/Client/Assets/1_Script/Info/UnitCtrl.cs +++ b/Client/Assets/1_Script/Info/UnitCtrl.cs @@ -29,6 +29,8 @@ public class UnitCtrl : MonoBehaviour } private void Update() { + if (PlayCtrl.Instance.isEndGame) + return; delay -= Time.deltaTime; if (delay > 0) return; @@ -37,7 +39,22 @@ public class UnitCtrl : MonoBehaviour if (enemyUnits.Count == 0) { anim.SetTrigger("att"); - Debug.Log("Ä·ÇÁ °ø°Ý"); + if (isEnemy) + { + PlayCtrl.Instance.player.campHp -= unit.attack; + if(PlayCtrl.Instance.player.campHp <= 0) + { + PlayCtrl.Instance.isEndGame = true; + } + } + else + { + PlayCtrl.Instance.enemy.campHp -= unit.attack; + if (PlayCtrl.Instance.enemy.campHp <= 0) + { + PlayCtrl.Instance.isEndGame = true; + } + } delay = unit.attackSpeed; } else diff --git a/Client/Assets/1_Script/PlayCtrl.cs b/Client/Assets/1_Script/PlayCtrl.cs index 56a06bb1..14d1980a 100644 --- a/Client/Assets/1_Script/PlayCtrl.cs +++ b/Client/Assets/1_Script/PlayCtrl.cs @@ -26,6 +26,7 @@ public class PlayCtrl : SingletonMonoBehaviour public SummonsUnit player; public SummonsUnit enemy; public BuildingCtrl buildingCtrl; + public bool isEndGame; //¼±ÅÃµÈ uiÀÇ Á¤º¸¸¦ ÀúÀåÇÒ ¼ö ÀÖ°Ô ¸¸µé±â. //·¹º§¾÷ ui¸¸µé±â @@ -36,6 +37,7 @@ public class PlayCtrl : SingletonMonoBehaviour summons = 0.1f; slider.value = 0; stage = 0; + isEndGame = false; uiExit(); } @@ -50,6 +52,11 @@ public class PlayCtrl : SingletonMonoBehaviour } private void Update() { + if (isEndGame) + { + Debug.Log("°ÔÀÓÁ¾·á"); + return; + } float deltaTime = Time.deltaTime; camera.transform.position += Vector3.left * speed * deltaTime * move; if (camera.transform.position.x < -40)