コード例 #1
0
        /// <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)
        {
            KeyboardState keyboardState = Keyboard.GetState();

            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || currentGameState == GameState.Exit)
            {
                this.Exit();
            }

            // Updating playing state
            switch (currentGameState)
            {
            case GameState.Playing:
            {
                break;
            }

            case GameState.MainMenu:
            {
                break;
            }

            case GameState.Paused:
            {
                //alienSquad.setAlienSoundState(SoundState.Stopped);
                break;
            }

            case GameState.GameOverMenu:
            {
                mothershipSprite.setMothershipSoundState(SoundState.Stopped);
                alienSquad.setAlienSoundState(SoundState.Stopped);
                score.setExtraLifeSoundState(SoundState.Stopped);
                break;
            }
            }

            // Check to see if the user has paused or unpaused
            if (!score.GetGameOver())
            {
                checkPauseKey(keyboardState);
                checkPauseGuide();
            }

            // If the user hasn't paused, Update normally
            if (!paused)
            {
                base.Update(gameTime);
            }
        }