Skip to content
Snippets Groups Projects
Commit d00ad7a5 authored by Moritz Meyerhof's avatar Moritz Meyerhof
Browse files

Enemys only spawnable between rounds

parent 380b8f7c
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment