public void Update() { if (_gameManager.IsGameRunning) { if (_waveState == Enumerators.WaveState.LAST_WAVE_FINISHED) { return; } if (_countdown <= 0f) { switch (_waveState) { case Enumerators.WaveState.WAIT_NEXT_WAVE: StartWave(); break; case Enumerators.WaveState.SPAWNING: StopSpawnCoroutine(); if (_currentWaveIndex + 1 >= _gameManager.LevelController.CurrentLevel.LevelSettings.waves.Length) { IsLastWaveFinished = true; _waveState = Enumerators.WaveState.LAST_WAVE_FINISHED; break; } NextWave(); break; } } _countdown -= Time.deltaTime; } }
private void NextWave() { _waveState = Enumerators.WaveState.WAIT_NEXT_WAVE; _currentWaveIndex++; _currentWaveSettings = _gameManager.LevelController.CurrentLevel.LevelSettings.waves[_currentWaveIndex]; _countdown = _currentWaveSettings.delayBeforeStartWave; OnWaveChangedEvent?.Invoke(_currentWaveIndex + 1, _gameManager.LevelController.CurrentLevel.LevelSettings.waves.Length); }
public void InitWaves() { _currentWaveIndex = 0; _currentWaveSettings = _gameManager.LevelController.CurrentLevel.LevelSettings.waves[_currentWaveIndex]; _countdown = _currentWaveSettings.delayBeforeStartWave; _waveState = Enumerators.WaveState.WAIT_NEXT_WAVE; IsLastWaveFinished = false; OnWaveChangedEvent?.Invoke(_currentWaveIndex + 1, _gameManager.LevelController.CurrentLevel.LevelSettings.waves.Length); }
private void StartWave() { _waveState = Enumerators.WaveState.SPAWNING; _countdown = _currentWaveSettings.duration; _spawnWaveCoroutine = MainApp.Instance.StartCoroutine(SpawnWave()); }