/// <summary> /// Make spawn all enemies at every point of the wave index /// Increase Wave Index /// </summary> private void ActivateWave() { if (!PhotonNetwork.isMasterClient || IsDesactivated) { return; } if (waves.Count == 0) { ActivatedAreas.Add(this); return; } if (waveIndex >= waves.Count && !isLooping) { ActivatedAreas.Remove(this); isActivated = false; IsDesactivated = true; OnAreaDesactivated?.Invoke(); OnOneAreaDesactivated?.Invoke(); if (ActivatedAreas.Count == 0) { TDS_UIManager.Instance.SwitchCurtains(false); } return; } else if (waveIndex >= waves.Count) { waveIndex = 0; } List <TDS_Enemy> _spawnedEnemies = waves[waveIndex].GetWaveEnemies(this); spawnedEnemies.AddRange(_spawnedEnemies); if (waves[waveIndex].IsActivatedByEvent) { foreach (TDS_Enemy e in _spawnedEnemies) { e.IsPacific = true; e.IsParalyzed = true; } } else { ActivateEnemies(); } //If the wave is empty, start the next wave if (spawnedEnemies.Count == 0) { waveIndex++; OnNextWave?.Invoke(); } }
/// <summary> /// Called when the Area has to be started /// When a player enter in the trigger or when the activation event is called /// Call the OnAreaActivated envent when the spawner area is ready and not activated yet /// </summary> public void StartSpawnArea() { if (PhotonNetwork.isMasterClient && isReady && !isActivated) { Action _removeEnemies = null; foreach (TDS_Enemy _enemy in spawnedEnemies) { if (_enemy.IsDead) { _removeEnemies += () => spawnedEnemies.Remove(_enemy); _removeEnemies += () => deadEnemies.Add(_enemy); } else { _enemy.Area = this; } } _removeEnemies?.Invoke(); ActivatedAreas.Add(this); OnAreaActivated?.Invoke(); foreach (TDS_Player _player in TDS_LevelManager.Instance.AllPlayers) { if (_player.Throwable) { LinkThrowable(_player.Throwable); } if (_player.PlayerType == PlayerType.Juggler) { ((TDS_Juggler)_player).Throwables.ForEach(t => LinkThrowable(t)); } } } }