Exemple #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)
        {
            spriteBatch.Begin();
            GraphicsDevice.Clear(Color.Black);

            #region MenuDraw

            switch (CurrentGameState)
            {
            case MenuState.GameState.Options:
                options.Draw(spriteBatch);
                break;

            case MenuState.GameState.LevelComplete:
                levelComplete.Draw(spriteBatch);
                break;

            case MenuState.GameState.MainMenu:
                mainmenu.Draw(spriteBatch);
                break;

            case MenuState.GameState.GameOver:
                gameOver.Draw(spriteBatch);
                if (!gameOver.Over)
                {
                    animationSprite.Draw(gameTime, spriteBatch, new Vector2(ScreenWidth / 2 - player.Rectangle.Width * 4, ScreenHeight / 2 - player.Rectangle.Height / 2), SpriteEffects.None, 0);
                }
                break;

            case MenuState.GameState.Pause:
                pause.Draw(spriteBatch);
                break;

            case MenuState.GameState.Exit:
                break;

            default:
                break;
            }
            spriteBatch.End();
            #endregion


            if (CurrentGameState == MenuState.GameState.Playing)
            {
                GraphicsDevice.Clear(Color.Cyan);
                spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, null, null, null, null, camera.Transform);
                map.Draw(spriteBatch, gameTime, camera.Center);
                player.Draw(gameTime, spriteBatch);

                DrawHud();
                if (!CanCompleteLevel)
                {
                    spriteBatch.DrawString(hudFont, "Not Enough Score!", new Vector2(camera.Center.X - ScreenWidth / 10, camera.Center.Y - ScreenHeight / 2 + ScreenHeight / 9), Color.Red, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f);
                    spriteBatch.DrawString(hudFont, "Not Enough Score!", new Vector2(camera.Center.X - ScreenWidth / 10 + 2f, camera.Center.Y - ScreenHeight / 2 + ScreenHeight / 9 + 2f), Color.Black, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f);
                }
                spriteBatch.End();
            }
            base.Draw(gameTime);
        }