//--------------------------------------------------------------------- /// <summary> /// Updates the current GameState. /// </summary> /// <param name="_time">Provides a snapshot of timing values.</param> public override void Update(Microsoft.Xna.Framework.GameTime _time) { float _fElapsedTime = (float)_time.ElapsedGameTime.TotalSeconds; if (mbExit) { //--------------------------------------------------------- // Fade out current state if (CurrentState.UpdateFadeOut(_fElapsedTime)) { // We're done CurrentState.Stop(); Game.Exit(); } } //----------------------------------------------------------------- // Handle state switching else if (NextState != null) { if (CurrentState != null) { //--------------------------------------------------------- // Fade out current state if (CurrentState.UpdateFadeOut(_fElapsedTime)) { // We're done fading out CurrentState.Stop(); CurrentState = null; // Reset all vibrations when switching active GameState GamePad.SetVibration(PlayerIndex.One, 0f, 0f); GamePad.SetVibration(PlayerIndex.Two, 0f, 0f); GamePad.SetVibration(PlayerIndex.Three, 0f, 0f); GamePad.SetVibration(PlayerIndex.Four, 0f, 0f); NextState.Start(); } } if (CurrentState == null) { //--------------------------------------------------------- // Fade in next state if (NextState.UpdateFadeIn(_fElapsedTime)) { // We're done fading in CurrentState = NextState; NextState = null; CurrentState.Update(_fElapsedTime); } } } //----------------------------------------------------------------- // Update current GameState else { CurrentState.Update(_fElapsedTime); } }