diff --git a/Assets/Scripts/LevelConfig/WaveObserver.cs b/Assets/Scripts/LevelConfig/WaveObserver.cs index e1d3ebb..196d8ad 100644 --- a/Assets/Scripts/LevelConfig/WaveObserver.cs +++ b/Assets/Scripts/LevelConfig/WaveObserver.cs @@ -81,37 +81,58 @@ public class WaveObserver : Singleton spawnerSubject.ChangeSpawnSpeed(_levelConfig.Interval * _spawnerTiming); if (paramPrefab.Equals(_levelConfig.ConstantSpawn[0].GetEnemyObject())) { + //int currentCount = 0; + //for (int i = 0; i < _copyConstantSpawn.Count; i++) + //{ + // if (_levelConfig.ConstantSpawn[i].GetEnemyObject() == paramPrefab) + // { + // currentCount = --_copyConstantSpawn[i]; + // break; + // Debug.Log("Amout to spawn is now: " + currentCount); + // if (currentCount <= 0) + // { + // //bool hasNextTarget = false; + // //for (int j = i; j < _copyConstantSpawn.Count; j++) + // //{ + // // if (_copyConstantSpawn[_copyConstantSpawn.Count - j] > 0) + // // { + // // spawnerSubject.Prefab = _levelConfig.ConstantSpawn[j].GetEnemyObject(); + // // hasNextTarget = true; + // // Debug.Log(spawnerSubject.Prefab.name); + // // } + // //} + // //if (!hasNextTarget) + // //{ + // foreach (SpawnerTile spawner in _subjects) + // { + // if (spawner.Prefab.Equals(paramPrefab)) + // { + // spawner.StopSpawn(); + // Debug.Log("----Spawn Stopped----"); + // } + // } + // //} + // } + // } + //} int currentCount = 0; for (int i = 0; i < _copyConstantSpawn.Count; i++) { if (_levelConfig.ConstantSpawn[i].GetEnemyObject() == paramPrefab) { currentCount = --_copyConstantSpawn[i]; - //break; - Debug.Log("Amout to spawn is now: " + currentCount); - if (currentCount <= 0) + break; + } + } + Debug.Log("Amout to spawn is now: " + currentCount); + if (currentCount <= 0) + { + foreach (SpawnerTile spawner in _subjects) + { + if (spawner.Prefab.Equals(paramPrefab)) { - bool hasNextTarget = false; - for (int j = i; j < _copyConstantSpawn.Count; j++) - { - if (_copyConstantSpawn[_copyConstantSpawn.Count - j] > 0) - { - spawnerSubject.Prefab = _levelConfig.ConstantSpawn[j].GetEnemyObject(); - hasNextTarget = true; - Debug.Log(spawnerSubject.Prefab.name); - } - } - if (!hasNextTarget) - { - foreach (SpawnerTile spawner in _subjects) - { - if (spawner.Prefab.Equals(paramPrefab)) - { - spawner.StopSpawn(); - Debug.Log("----Spawn Stopped----"); - } - } - } + spawner.StopSpawn(); + Debug.Log("----Spawn Stopped----"); } } }