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

            screenWidth  = GraphicsDevice.Viewport.Width;
            screenHeight = GraphicsDevice.Viewport.Height;

            float elapsedGameTime = (float)gameTime.ElapsedGameTime.TotalSeconds;


            if (gameStateWatcher.currentGameState == GameStateWatcher.GameState.StartMenu)
            {
                startMenuScreen.DrawFrame();
            }
            else if (gameStateWatcher.currentGameState == GameStateWatcher.GameState.UpgradeMenu)
            {
            }
            else if (gameStateWatcher.currentGameState == GameStateWatcher.GameState.GameOver)
            {
                gameOverScreen.DrawFrame(spriteBatch, backgroundAnimation, elapsedGameTime, screenHeight, screenWidth, arialFont28);
            }
            else if (gameStateWatcher.currentGameState == GameStateWatcher.GameState.RunningLevel)
            {
                //Draw Background first
                backgroundAnimation.DrawFrame(elapsedGameTime, screenHeight);

                //Then draw Player
                player.DrawFrame();

                playerShotHandler.DrawShots();

                //Then draw Enemies
                foreach (EnemyClass enemy in enemies.Where(item => item.enemyActive == true))
                {
                    enemy.DrawFrame();
                }
                //Draw Enemy death animation if needed
                foreach (EnemyClass enemy in enemies.Where(item => item.enemyActive == false))
                {
                    //If the Animation Position Vector is Empty, set it one time
                    if (enemy.enemyDeathAnimation.animationPosition.X == 0f && enemy.enemyDeathAnimation.animationPosition.Y == 0f)
                    {
                        enemy.enemyDeathAnimation.animationPosition = enemy.enemyPosition + enemy.enemyDeathAnimation.positionCorrection;
                    }

                    //Call DeathAnimation DrawFrame
                    enemy.enemyDeathAnimation.DrawFrame(elapsedGameTime, enemy);
                }
            }


            base.Draw(gameTime);
        }