/// <summary> /// Hides all the screens and shows the selected screen. /// </summary> private void SwitchToSelectedScreen() { game.HideScreens(); switch ((SelectableMenuItems)SelectedItem) { case SelectableMenuItems.Play: var playScreen = game.Services.GetService <GameScreen>(); playScreen.SetActive(true); playScreen.PlayMusic(); break; case SelectableMenuItems.Help: game.Services.GetService <HelpScreen>().SetActive(true); break; case SelectableMenuItems.Credits: game.Services.GetService <CreditsScreen>().SetActive(true); break; case SelectableMenuItems.Quit: game.Exit(); break; default: // Switch to the start screen as a backup var startScreen = game.Services.GetService <StartScreen>(); startScreen.SetActive(true); startScreen.PlayMusic(); break; } }
/// <summary> /// Update the screen. /// </summary> /// <param name="gameTime"></param> public override void Update(GameTime gameTime) { keyHandler.Update(); if (keyHandler.IsKeyPressed(Keys.Escape)) { var startScreen = GameRoot.Services.GetService <StartScreen>(); GameRoot.HideScreens(); startScreen.SetActive(true); } base.Update(gameTime); }
/// <summary> /// Destroys the player object /// </summary> public override void Destroy() { base.Destroy(); // Get the score before GameRoot.HideScreens(); resets the score var endScreen = GameRoot.Services.GetService <EndScreen>(); endScreen.EndScore.Score = Score.ToString(); // Hide all screens GameRoot.HideScreens(); // Show end/game over screen endScreen.SetActive(true); endScreen.PlayMusic(); }