Beispiel #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            // Set the window's background color to black
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin();

            // Switch to draw stuff specific to a gamestate. Most of it is self-documenting.
            switch (gameState)
            {
            case GameState.TitleScreen:
                spriteBatch.Draw(background, Vector2.Zero, Color.RoyalBlue);
                rain.Draw(spriteBatch);
                mainMenu.Draw(spriteBatch);
                break;

            case GameState.Tutorial:
                spriteBatch.Draw(background, Vector2.Zero, Color.RoyalBlue);
                rain.Draw(spriteBatch);
                tutorial.Draw(spriteBatch);
                break;

            case GameState.Credits:
                spriteBatch.Draw(background, Vector2.Zero, Color.RoyalBlue);
                rain.Draw(spriteBatch);
                credits.Draw(spriteBatch);
                break;

            case GameState.PrePlaying:
                spriteBatch.Draw(background, Vector2.Zero, Color.White);
                rain.Draw(spriteBatch);
                break;

            case GameState.Playing:
                spriteBatch.Draw(background, Vector2.Zero, Color.White);
                // Draw 'hog if player is "behind" it.
                if (playerSprite.Position.Y >= ally.HogSprite.Position.Y)
                {
                    ally.Draw(spriteBatch);
                }

                spriteBatch.Draw(playerSprite.Texture, playerSprite.Position, playerSprite.SourceRect, Color.White);
                playerSprite.Draw(spriteBatch);
                // Draw 'hog if player is "in front" of it.
                if (playerSprite.Position.Y + playerSprite.Texture.Height <
                    ally.HogSprite.Position.Y + ally.HogSprite.Texture.Height)
                {
                    ally.Draw(spriteBatch);
                }
                enemyManager.Draw(spriteBatch);
                enemyExplosionManager.Draw(spriteBatch);
                playerExplosionManager.Draw(spriteBatch);
                rain.Draw(spriteBatch);
                scoreManager.Draw(spriteBatch);
                break;

            case GameState.Paused:
                spriteBatch.Draw(background, Vector2.Zero, Color.White);
                // Draw 'hog if player is "behind" it.
                if (playerSprite.Position.Y >= ally.HogSprite.Position.Y)
                {
                    ally.Draw(spriteBatch);
                }

                spriteBatch.Draw(playerSprite.Texture, playerSprite.Position, playerSprite.SourceRect, Color.White);
                playerSprite.Draw(spriteBatch);
                // Draw 'hog if player is "in front" of it.
                if (playerSprite.Position.Y + playerSprite.Texture.Height <
                    ally.HogSprite.Position.Y + ally.HogSprite.Texture.Height)
                {
                    ally.Draw(spriteBatch);
                }
                enemyManager.Draw(spriteBatch);
                enemyExplosionManager.Draw(spriteBatch);
                playerExplosionManager.Draw(spriteBatch);
                rain.Draw(spriteBatch);
                scoreManager.Draw(spriteBatch);
                paused.Draw(spriteBatch);
                break;

            case GameState.GameOver:
                spriteBatch.Draw(background, Vector2.Zero, Color.White);
                // Draw 'hog if player is "behind" it.
                if (playerSprite.Position.Y >= ally.HogSprite.Position.Y)
                {
                    ally.Draw(spriteBatch);
                }

                spriteBatch.Draw(playerSprite.Texture, playerSprite.Position, playerSprite.SourceRect, Color.White);
                playerSprite.Draw(spriteBatch);
                // Draw 'hog if player is "in front" of it.
                if (playerSprite.Position.Y + playerSprite.Texture.Height <
                    ally.HogSprite.Position.Y + ally.HogSprite.Texture.Height)
                {
                    ally.Draw(spriteBatch);
                }
                enemyManager.Draw(spriteBatch);
                enemyExplosionManager.Draw(spriteBatch);
                playerExplosionManager.Draw(spriteBatch);
                rain.Draw(spriteBatch);
                gameOver.Draw(spriteBatch);
                break;
            }
            // Draw mouse cursor sprite.
            inputManager.Draw(spriteBatch);

            spriteBatch.End();
            base.Draw(gameTime);
        }