/// <summary> /// Finish the current game /// </summary> private void FinishCurrentGame() { IsActive = false; foreach (GameScreen screen in ScreenManager.GetScreens()) { screen.ExitScreen(); } if (HighScoreScreen.IsInHighscores(gameTime)) { // Show the device's keyboard Guide.BeginShowKeyboardInput(PlayerIndex.One, "Player Name", "Enter your name (max 15 characters)", "Player", (r) => { string playerName = Guide.EndShowKeyboardInput(r); if (playerName != null && playerName.Length > 15) { playerName = playerName.Substring(0, 15); } HighScoreScreen.PutHighScore(playerName, gameTime); ScreenManager.AddScreen(new BackgroundScreen(), null); ScreenManager.AddScreen(new HighScoreScreen(), null); }, null); return; } ScreenManager.AddScreen(new BackgroundScreen(), null); ScreenManager.AddScreen(new HighScoreScreen(), null); }
private void DrawEndGame(GameTime gameTime) { string text = HighScoreScreen.IsInHighscores(this.gameTime) ? " You got a High Score!" : " Game Over"; text += "\nTouch the screen to continue"; Vector2 size = timeFont.MeasureString(text); Vector2 textPosition = (new Vector2(ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height) - size) / 2f; ScreenManager.SpriteBatch.DrawString(timeFont, text, textPosition, Color.White); }
/// <summary> /// Load game content /// </summary> protected override void LoadContent() { AudioManager.LoadSounds(); HighScoreScreen.LoadHighscore(); base.LoadContent(); }
/// <summary> /// Respond to "Exit" Item Selection /// </summary> /// <param name="playerIndex"></param> protected override void OnCancel(PlayerIndex playerIndex) { HighScoreScreen.SaveHighscore(); ScreenManager.Game.Exit(); }