diff --git a/Assets/Scripts/Store/EnemySpawnController.cs b/Assets/Scripts/Store/EnemySpawnController.cs index e9fede1f0cce0b391a7afdb7c6ac38b3a1238a8a..2f4a7647cd328a37c182d24aac936b8039369e36 100644 --- a/Assets/Scripts/Store/EnemySpawnController.cs +++ b/Assets/Scripts/Store/EnemySpawnController.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; -public class EnemySpawnController : MonoBehaviour +public class EnemySpawnController : MonoBehaviour, IRoundCallback { [SerializeField] List<Opponent> enemyList; @@ -13,6 +13,7 @@ public class EnemySpawnController : MonoBehaviour Dictionary<Opponent, Image> enemies = new Dictionary<Opponent, Image>(); float mana; + bool running = false; Opponent activeSpawn; GameObject enemyImage; @@ -29,6 +30,12 @@ public class EnemySpawnController : MonoBehaviour } } + private void Start() + { + RoundController.instance.roundCallbacks.Add(this); + OnRoundEnd(); + } + // Update is called once per frame void Update() { @@ -70,11 +77,10 @@ public class EnemySpawnController : MonoBehaviour public void OnEnemyMouseDown(string enemyName) { SetEnemyToSpawnObject(enemyName); - if (StatsManager.instance.ModifyMana(-1 * (int)activeSpawn.enemyCost)) + if (StatsManager.instance.ModifyMana(-1 * (int)activeSpawn.enemyCost) && !running) { dragObject.GetComponent<Image>().sprite = activeSpawn.EnemySprite; enemyImage = Instantiate(dragObject, GetPreviewWorldPosition(), Quaternion.identity, transform); - OnEnemyDrag(); } } @@ -109,4 +115,14 @@ public class EnemySpawnController : MonoBehaviour pos.z = 0; return pos; } + + public void OnRoundStart() + { + running = true; + } + + public void OnRoundEnd() + { + running = false; + } }