Пример #1
0
        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;
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
 private void StartWave()
 {
     _waveState          = Enumerators.WaveState.SPAWNING;
     _countdown          = _currentWaveSettings.duration;
     _spawnWaveCoroutine = MainApp.Instance.StartCoroutine(SpawnWave());
 }