Example #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)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here
            // Start drawing
            spriteBatch.Begin();

            switch (Level)
            {
            //-------------------------------------------------------------------------------------------

            case 0:

                bgLayer3.Draw(spriteBatch);
                break;

            //-------------------------------------------------------------------------------------------

            case 1:

                bgLayer1.Draw(spriteBatch);
                bgLayer2.Draw(spriteBatch);
                break;

            //-------------------------------------------------------------------------------------------

            case 2:

                bgLayer4.Draw(spriteBatch);
                break;

                //-------------------------------------------------------------------------------------------
            }

            //Draw the Main Background Texture
            spriteBatch.Draw(mainBackground, rectBackground, Color.White);
            // Draw the moving background
            //  bgLayer1.Draw(spriteBatch);
            //  bgLayer2.Draw(spriteBatch);
            //  bgLayer3.Draw(spriteBatch);

            //-------------------------------------------------------------------------------------------

            if (gameState == GameStates.TitleScreen)
            {
                spriteBatch.Draw(titleScreen, new Rectangle(0, 0, titleScreen.Width, titleScreen.Height), Color.White);
            }

            //-------------------------------------------------------------------------------------------

            if (gameState == GameStates.start)
            {
                spriteBatch.DrawString(MenuFont, "Beginning Wave: " + guiInfo.LEVEL, new Vector2(300, 300), Color.White);
            }

            //-------------------------------------------------------------------------------------------

            if (gameState == GameStates.Playing || gameState == GameStates.WaveComplete)
            {
                // Draw the Player
                player.Draw(spriteBatch);

                //Draw Enemies
                Balloons.DrawEnemies(spriteBatch);

                //Draw Lazers
                LazerBeams.DrawLasers(spriteBatch, soundE);

                //Draw Explosions
                VFX.DrawExplosions(spriteBatch);
                CheckPlayerDeath();

                //Drawing GUI elements
                spriteBatch.Draw(legand, new Vector2(0, 410), Color.White);
                spriteBatch.DrawString(guiFont, "Score: " + guiInfo.SCORE, new Vector2(10, 422), Color.White);
                spriteBatch.DrawString(guiFont, "Level:  " + guiInfo.LEVEL, new Vector2(10, 450), Color.White);
                spriteBatch.DrawString(guiFont, "HP: " + guiInfo.PlayerHP, new Vector2(200, 422), Color.White);

                for (int i = 1; i <= guiInfo.LIVES; i++)
                {
                    spriteBatch.Draw(playerGUI, new Vector2(220 + i * 45, 395), Color.White);
                }
            }

            //-------------------------------------------------------------------------------------------

            if (gameState == GameStates.WaveComplete)
            {
                spriteBatch.DrawString(MenuFont, "Beginning Wave: " + guiInfo.LEVEL, new Vector2(300, 300), Color.Yellow);
            }

            //-------------------------------------------------------------------------------------------

            if (gameState == GameStates.GameOver)
            {
                spriteBatch.Draw(gameover, new Rectangle(0, 0, titleScreen.Width, titleScreen.Height), Color.White);
            }

            //-------------------------------------------------------------------------------------------

            // Stop drawing
            spriteBatch.End();
            base.Draw(gameTime);
        }