示例#1
0
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // Update the explosions
            _explosions.Update(gameTime);

            if ((!paused) && (!gameOver))
            {
                // Check collisions with meteors
                HandleDamages();

                // Check if a player get a power boost
                HandlePowerSourceSprite(gameTime);

                // Update score
                score.Value = player.Score;
                score.Power = player.Power;

                // Check if player is dead
                gameOver = (player.Power <= 0);
                if (gameOver)
                {
                    player.Visible = (player.Power > 0);

                    // Stop the music
                    MediaPlayer.Stop();
                }

                // Update all other game components
                base.Update(gameTime);
            }

            // In game over state, keep the meteors animation
            if (gameOver)
            {
                meteors.Update(gameTime);
            }
        }