public bool GameOverFunc() { _state = GameStates.PostGame; _background = new MainBackground(); _postGameScreen = new PostGameScreen(); return(true); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { try { InputService.Update(gameTime); _background?.Update(gameTime); switch (_state) { case GameStates.MainMenu: _mainMenu.Update(); break; case GameStates.GameSetup: _gameSetup.Update(); break; case GameStates.Game: _players.ForEach(p => p.Update(gameTime)); Globals.GameState.Update(gameTime); if (Level.TimeRemaining <= TimeSpan.Zero && !Globals.GameState.Enemies.Any(e => e.IsSpawnedEnemy)) { _state = GameStates.Intermission; _background = new MainBackground(); _intermissionScreen = new IntermissionScreen(); Level.LevelComplete(); } break; case GameStates.Intermission: _intermissionScreen.Update(); if (_intermissionScreen.Ready) { _intermissionScreen = null; _background = null; _state = GameStates.Game; Level.StartLevel(); } return; case GameStates.PostGame: _postGameScreen.Update(); if (_postGameScreen.Ready) { _postGameScreen = null; _state = GameStates.MainMenu; _players.ForEach(p => p.GameOver()); Globals.GameState = new GameState(_players); _mainMenu = new MainMenu(SetupGameFunc); } return; } base.Update(gameTime); } catch (Exception e) { var a = 5; } }