public override void Update(GameTime gameTime, StateManager screen, GamePadState gamePadState, MouseState mouseState, KeyboardState keyState, InputHandler input) { if (input.KeyboardState.WasKeyPressed(Keys.Escape)) { screen.Pop(); } highScore.Update(gameTime); }
public static State NewHighScoreUpdate(GameTime gameTime, ContentManager content, GameWindow window) { hs.Update(gameTime); // Execute update method in hs object KeyboardState keyboardState = Keyboard.GetState(); if (keyboardState.IsKeyDown(Keys.Enter)) // If enter is pressed { hs.Add(player.Points); // Add name + score to highscorelist Reset(window, content); // Reset the game and go to main menu // Set a cooldown on the menu so that game doesn't automatically start again menu.lastChange = gameTime.TotalGameTime.TotalMilliseconds; return(State.Menu); } return(State.NewHighscore); // Keep newhighscore running as default }
private void UpdateScreens(GameTime gameTime) { switch (gameState) { case GameState.menu: //MENU menu.Update((float)gameTime.ElapsedGameTime.TotalSeconds); break; case GameState.gamePlay: //GAMEPLAY gameManager.Update((float)gameTime.ElapsedGameTime.TotalSeconds); if (gameManager.GameOver() || gameManager.Winner()) { switchScreenTimer += (float)gameTime.ElapsedGameTime.TotalSeconds; if (switchScreenTimer > 4 || KeyMouseReader.KeyPressed(Keys.Escape) || KeyMouseReader.KeyPressed(Keys.Space)) { switchScreenTimer = 0; gameState = GameState.enterUser; menu.run = Menu.RunTime.FirstLoad; } } else if (KeyMouseReader.KeyPressed(Keys.Escape)) { gameState = GameState.menu; } break; case GameState.highscore: //HIGHSCORES menu.Update((float)gameTime.ElapsedGameTime.TotalSeconds); highScore.Update(); if (KeyMouseReader.KeyPressed(Keys.Escape)) { gameState = GameState.menu; } break; case GameState.enterUser: //ENTER USER newScore.Update(); break; } }