/// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { this.Exit(); } switch (GameElements.currentState) { case GameElements.State.Run: GameElements.currentState = GameElements.RunUpdate(Content, Window, gameTime); break; case GameElements.State.Highscore: GameElements.currentState = GameElements.HighScoreUpdate(); break; case GameElements.State.Quit: this.Exit(); break; default: GameElements.currentState = GameElements.MenuUpdate(); break; } base.Update(gameTime); }
/// <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) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { Exit(); } //Get current state and execute said states update method switch (GameElements.currentState) { case GameElements.State.Run: GameElements.currentState = GameElements.RunUpdate(Content, Window, gameTime); break; case GameElements.State.Highscore: GameElements.currentState = GameElements.HighScoreUpdate(gameTime); break; case GameElements.State.NewHighscore: GameElements.currentState = GameElements.NewHighScoreUpdate(gameTime, Content, Window); break; case GameElements.State.Quit: this.Exit(); break; default: //By default, set state as menu (Game start). GameElements.currentState = GameElements.MenuUpdate(gameTime); break; } base.Update(gameTime); }