/// <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, false); // Gradually fade in or out depending on whether we are covered by the pause screen. if (coveredByOtherScreen) { pauseAlpha = Math.Min(pauseAlpha + 1f / 32, 1); } else { pauseAlpha = Math.Max(pauseAlpha - 1f / 32, 0); } if (IsActive) { if (playerController.GameOver) { HandleGameOver(); } if (enemyController.LevelFinished) { HandleLevelComplete(); } var timeWarpFactor = 1.0f; foreach (float value in timeFactors.Values) { timeWarpFactor *= value; } var elapsedTime = gameTime.ElapsedGameTime.Milliseconds * timeWarpFactor; var timeSpan = new TimeSpan(0, 0, 0, 0, (int)elapsedTime); myGameTime = new GameTime(myGameTime.TotalGameTime, timeSpan); affectedGameTime += elapsedTime; #region Update Objects #region Update Player playerController.Update(elapsedTime); #endregion #region Update Bullets bulletController.Update(elapsedTime); #endregion #region Update Enemies enemyController.Update(elapsedTime); #endregion #region Update Particles particleController.Update(elapsedTime); #endregion #region Update Background backgroundController.Update(elapsedTime); #endregion #endregion } }