private void Update() { if (_currentWave == null) { return; } _timeAfterLastSpawn += Time.deltaTime; if (_timeAfterLastSpawn >= _currentWave.Delay) { InstantiateEnemy(); _spawned++; EnemySpawnChanged?.Invoke(_spawned, _currentWave.Count); _timeAfterLastSpawn = 0; } if (_currentWave.Count <= _spawned) { if (_waves.Count > _currentWaveNumber + 1) { AllEnemySpawned?.Invoke(); } _currentWave = null; } }
public void NextWave() { EnemySpawnChanged?.Invoke(0, 1); SetWave(++_currentWaveNumber); _spawned = 0; }
private void Start() { SetWave(_currentWaveNumber); EnemySpawnChanged?.Invoke(0, 1); }