public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); World.Update((float)gameTime.ElapsedGameTime.TotalSeconds); }
/// <summary> /// Updates the state of the game. This method checks the GameScreen.IsActive /// property, so the game will stop updating when the pause menu is active, /// or if you tab away to a different application. /// </summary> public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); // if this screen is leaving, then stop the music if (IsExiting) { World.AudioManager.StopMusic(); } else if ((otherScreenHasFocus == true) || (coveredByOtherScreen == true)) { // make sure nobody's controller is vibrating for (int i = 0; i < 4; i++) { GamePad.SetVibration((PlayerIndex)i, 0f, 0f); } if (gameOver == false) { for (int i = 0; i < World.Ships.Length; i++) { World.Ships[i].ProcessInput(gameTime.TotalGameTime.Seconds, true); } } } else { // check for a winner if (gameOver == false) { for (int i = 0; i < World.Ships.Length; i++) { if (World.Ships[i].Score >= WorldRules.ScoreLimit) { ScreenManager.AddScreen(new GameOverScreen(string.Format(Strings.Player_X_Wins, (i + 1)))); gameOver = true; break; } } } // update the world if (gameOver == false) { World.Update((float)gameTime.ElapsedGameTime.TotalSeconds); } } }