private void Reset(params object[] parameters) { List <PLESpawn> currentWaveSpawners = WorkingLevelData.GetPLESpawnsFromWave(CurrentWaveIndex); for (int i = 0; i < currentWaveSpawners.Count; i++) { PLESpawn spawn = currentWaveSpawners[i]; spawn.SetOnCriticalEnemiesDead(null); } FindObjectsOfType <EnemyBase>().ToList().ForEach(enemy => { enemy.OnDeath(); }); CurrentWaveIndex = 0; infiniteWaveIndex = 0; hasCycledLevel = false; }
private void CallWave(int waveIndex) { CurrentWaveIndex = waveIndex; editorInstance.EnableCurrentWaveSpawnParents(waveIndex); List <PLESpawn> currentWaveSpawners = WorkingLevelData.GetPLESpawnsFromWave(waveIndex); for (int i = 0; i < currentWaveSpawners.Count; i++) { PLESpawn spawn = currentWaveSpawners[i]; spawn.SetOnCriticalEnemiesDead(OnCriticalSpawnsInSpawnerDead); spawn.StartSpawning(); } EventSystem.Instance.TriggerEvent(Strings.Events.PLE_CALL_WAVE, waveIndex); EventSystem.Instance.TriggerEvent(Strings.Events.WAVE_COMPLETE, infiniteWaveIndex); }
private void OnCriticalSpawnsInSpawnerDead() { //check if all spawners in given wave are marked as completed List <PLESpawn> currentWaveSpawners = WorkingLevelData.GetPLESpawnsFromWave(CurrentWaveIndex); bool lastWaveIsComplete = true; if (CurrentWaveIndex > 0 || (CurrentWaveIndex == 0 && InfiniteWavesEnabled && hasCycledLevel)) { int lastWaveIndex = CurrentWaveIndex - 1; if (lastWaveIndex < 0) { lastWaveIndex = MaxWaveIndex; } List <PLESpawn> lastWaveSpawners = WorkingLevelData.GetPLESpawnsFromWave(lastWaveIndex); lastWaveIsComplete = lastWaveSpawners.All(spawner => { return(spawner.AllEnemiesDead); }); } bool currentWaveMinEnemiesAreDead = currentWaveSpawners.All(spawner => { return(spawner.MinEnemiesDead); }); if (lastWaveIsComplete && currentWaveMinEnemiesAreDead) { if (CurrentWaveIndex >= WorkingLevelData.WaveCount - 1 && !InfiniteWavesEnabled) { EventSystem.Instance.TriggerEvent( Strings.Events.LEVEL_COMPLETED, SceneTracker.CurrentSceneName, ScoreManager.Instance.GetScore(), ModManager.leftArmOnLoad.ToString(), ModManager.rightArmOnLoad.ToString()); } else if (CurrentWaveIndex >= WorkingLevelData.WaveCount - 1 && InfiniteWavesEnabled) { hasCycledLevel = true; infiniteWaveIndex++; CallWave(0); } else { CallNextWave(); } } }
private List <PLESpawn> GetWavePLESpawns(int waveIndex) { return(WorkingLevelData.GetPLESpawnsFromWave(waveIndex)); }