public void Reset() { _Wave = 1; _TotalTime = TimeSpan.Zero; _TotalEntitiesKilled = 0; _DifficultyModifier = 1f; _CurrentPhase = ArenaPhases.Start; if (RemainingEntities != null) { foreach (var s in RemainingEntities) { if (!s.IsDisposed) { s.Dispose(); } } } RemainingEntities = new List <Entity>(); _BattleTimer = TimeSpan.Zero; _PhaseTimer = TimeSpan.FromSeconds(PHASE_DURATION); foreach (var s in EnemySpawners) { s.GetComponent <SpawnerComponent>().Reset(); } }
protected override void OnUpdate(GameTime Time) { //Not sure if it's a bug, but this is called multiple times before gametime is even determined. if (Time.TotalGameTime == TimeSpan.Zero) { return; } DeterminePlayerState(); switch (_CurrentPhase) { case ArenaPhases.Start: StartPhaseUpdate(); _PhaseTimer -= Time.ElapsedGameTime; if (_PhaseTimer <= TimeSpan.Zero) { AudioManager.PlaySoundEffect("ArenaStart"); InitBattlePhase(); _BattleTimer = TimeSpan.Zero; _PhaseTimer = TimeSpan.FromSeconds(PHASE_DURATION); _CurrentPhase = ArenaPhases.Battle; } break; case ArenaPhases.Battle: BattlePhaseUpdate(); _BattleTimer += Time.ElapsedGameTime; if (RemainingEntities.Count == 0) { AudioManager.PlaySoundEffect("ArenaEnd"); InitEndPhase(); _PhaseTimer = TimeSpan.FromSeconds(PHASE_DURATION); _CurrentPhase = ArenaPhases.End; } break; case ArenaPhases.End: EndPhaseUpdate(); _PhaseTimer -= Time.ElapsedGameTime; if (_PhaseTimer <= TimeSpan.Zero) { InitStartPhase(); _PhaseTimer = TimeSpan.FromSeconds(PHASE_DURATION); _CurrentPhase = ArenaPhases.Start; } break; case ArenaPhases.GameOver: _PhaseTimer -= Time.ElapsedGameTime; if (_PhaseTimer <= TimeSpan.Zero) { Reset(); _PhaseTimer = TimeSpan.FromSeconds(PHASE_DURATION); _CurrentPhase = ArenaPhases.Start; CorvusGame.Instance.SceneManager.ReloadScenes(true); } break; } }
public void Reset() { _Wave = 1; _TotalTime = TimeSpan.Zero; _TotalEntitiesKilled = 0; _DifficultyModifier = 1f; _CurrentPhase = ArenaPhases.Start; if (RemainingEntities != null) { foreach (var s in RemainingEntities) { if(!s.IsDisposed) s.Dispose(); } } RemainingEntities = new List<Entity>(); _BattleTimer = TimeSpan.Zero; _PhaseTimer = TimeSpan.FromSeconds(PHASE_DURATION); foreach (var s in EnemySpawners) s.GetComponent<SpawnerComponent>().Reset(); }
private void DeterminePlayerState() { if (_CurrentPhase == ArenaPhases.GameOver) { return; } bool allplayersDisposed = true; foreach (var p in CorvusGame.Instance.Players) { if (!p.Character.IsDisposed) { allplayersDisposed = false; break; } } if (allplayersDisposed) { _TotalTime += _BattleTimer; _CurrentPhase = ArenaPhases.GameOver; _PhaseTimer = TimeSpan.FromSeconds(GAMEOVER_PHASE_DURATION); } }
private void DeterminePlayerState() { if (_CurrentPhase == ArenaPhases.GameOver) return; bool allplayersDisposed = true; foreach (var p in CorvusGame.Instance.Players) { if (!p.Character.IsDisposed) { allplayersDisposed = false; break; } } if (allplayersDisposed) { _TotalTime += _BattleTimer; _CurrentPhase = ArenaPhases.GameOver; _PhaseTimer = TimeSpan.FromSeconds(GAMEOVER_PHASE_DURATION); } }
protected override void OnUpdate(GameTime Time) { //Not sure if it's a bug, but this is called multiple times before gametime is even determined. if (Time.TotalGameTime == TimeSpan.Zero) return; DeterminePlayerState(); switch (_CurrentPhase) { case ArenaPhases.Start: StartPhaseUpdate(); _PhaseTimer -= Time.ElapsedGameTime; if (_PhaseTimer <= TimeSpan.Zero) { AudioManager.PlaySoundEffect("ArenaStart"); InitBattlePhase(); _BattleTimer = TimeSpan.Zero; _PhaseTimer = TimeSpan.FromSeconds(PHASE_DURATION); _CurrentPhase = ArenaPhases.Battle; } break; case ArenaPhases.Battle: BattlePhaseUpdate(); _BattleTimer += Time.ElapsedGameTime; if (RemainingEntities.Count == 0) { AudioManager.PlaySoundEffect("ArenaEnd"); InitEndPhase(); _PhaseTimer = TimeSpan.FromSeconds(PHASE_DURATION); _CurrentPhase = ArenaPhases.End; } break; case ArenaPhases.End: EndPhaseUpdate(); _PhaseTimer -= Time.ElapsedGameTime; if (_PhaseTimer <= TimeSpan.Zero) { InitStartPhase(); _PhaseTimer = TimeSpan.FromSeconds(PHASE_DURATION); _CurrentPhase = ArenaPhases.Start; } break; case ArenaPhases.GameOver: _PhaseTimer -= Time.ElapsedGameTime; if (_PhaseTimer <= TimeSpan.Zero) { Reset(); _PhaseTimer = TimeSpan.FromSeconds(PHASE_DURATION); _CurrentPhase = ArenaPhases.Start; CorvusGame.Instance.SceneManager.ReloadScenes(true); } break; } }