Pull request #69: Bugfix/spawnLevelConfigOddBehaviour

Merge in CGD/gather-and-defend from bugfix/spawnLevelConfigOddBehaviour to main

* commit 'dcdc0d7fc8033a332cf0b0dd260aeeea18b3a3b5':
  reset WaveObserver state wip
This commit is contained in:
Élia Gingras 01 2024-06-23 22:57:47 +00:00 committed by Ader Alisma 01
commit 556b09734e

View File

@ -20,10 +20,20 @@ public class WaveObserver : Singleton<WaveObserver>
public void Init(WaveConfig config) public void Init(WaveConfig config)
{ {
_subjects.Clear();
_aliveEnemyCount.Clear();
_intervalTiming.Clear();
_levelConfig = Object.Instantiate(config); _levelConfig = Object.Instantiate(config);
_copyConstantSpawn = new List<int>(); _copyConstantSpawn = new List<int>();
_copyGroupSpawn = new List<List<int>>(); _copyGroupSpawn = new List<List<int>>();
_groupSpawnTimers = new List<float>(); _groupSpawnTimers = new List<float>();
_spawnerTiming = 0;
_currentGroupIndex = 0;
_once = true;
if (!_levelConfig) if (!_levelConfig)
{ {
Debug.LogError("level config was null"); Debug.LogError("level config was null");
@ -59,6 +69,7 @@ public class WaveObserver : Singleton<WaveObserver>
*/ */
public void Attach(SpawnerTile spawnerSubject) public void Attach(SpawnerTile spawnerSubject)
{ {
if (_subjects.Contains(spawnerSubject)) return;
spawnerSubject.Prefab = _levelConfig.GetRandomSpawn().GetEnemyObject(); spawnerSubject.Prefab = _levelConfig.GetRandomSpawn().GetEnemyObject();
_subjects.Add(spawnerSubject); _subjects.Add(spawnerSubject);