Exemplo n.º 1
0
        /// <summary>
        /// The update loop that assumes timestep has been fixed
        /// </summary>
        /// <param name="gameTime"></param>
        protected override void Update(GameTime gameTime)
        {
            GlobalInput.Update();
            Timers.Update(gameTime);

            if (CurrentState == GameState.Menu)
            {
                if (GlobalInput.WasCommandEntered(InputCommand.Exit))
                {
                    Exit();
                }
                menu.Update(gameTime);
            }
            else if (CurrentState == GameState.Playing)
            {
                if (GlobalInput.WasCommandEntered(InputCommand.Pause) || !IsActive)
                {
                    CurrentState = GameState.Paused;
                }
                else
                {
                    SoundEffect.MasterVolume = 1;
                    scene.Update(gameTime);
                }
            }
            else if (CurrentState == GameState.Paused)
            {
                if (GlobalInput.WasCommandEntered(InputCommand.Pause))
                {
                    CurrentState = GameState.Playing;
                }
                else
                {
                    SoundEffect.MasterVolume = 0;
                    pauseMenu.Update(gameTime);
                }
            }
            else if (CurrentState == GameState.GameOver)
            {
                gameOverMenu.Update(gameTime);
                scene.Update(gameTime);
            }
        }