Exemple #1
0
 public override void Draw(GameTime gameTime)
 {
     Background.Draw(gameTime);
     LevelManager.Draw(gameTime);
     TowerManager.Draw(gameTime);
     foreach (Creep creep in CreepList)
     {
         creep.Draw(gameTime);
     }
     GuiManager.Draw(gameTime);
     base.Draw(gameTime);
 }
        /// <summary>
        /// Draws the gameplay screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // This game has a blue background. Why? Because!
            ScreenManager.GraphicsDevice.Clear(ClearOptions.Target,
                                               Color.CornflowerBlue, 0, 0);

            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate,
                              SaveStateMode.None, camera.TransformMatrix);

            level.Draw(spriteBatch);

            DrawCursor();

            waveManager.Draw(spriteBatch);
            towerManager.Draw(spriteBatch);

            int round = waveManager.Round;

            guiManager.Draw(spriteBatch, round, money, lives);

            if (towerSelected)
            {
                Rectangle rect = Engine.CreateRectForCell(new Point((int)((selectedTowerPos.X + 16) / Engine.TileWidth),
                                                                    (int)(selectedTowerPos.Y + 16) / Engine.TileHeight));

                Vector2 center = new Vector2(rect.X + rect.Width / 2,
                                             rect.Y + rect.Height / 2);

                if (selectedType == 1)
                {
                    spriteBatch.Draw(arrowRange, Vector2.Subtract(center, new Vector2(arrowRange.Width / 2)),
                                     new Color(new Vector4(0, 0, 0, 0.5f)));
                }
                else if (selectedType == 2)
                {
                    spriteBatch.Draw(spikeRange, Vector2.Subtract(center, new Vector2(spikeRange.Width / 2)),
                                     new Color(new Vector4(0, 0, 0, 0.5f)));
                }
            }

            if (tower != null)
            {
                towerPreview.Draw(spriteBatch, cellX, cellY);
            }

            spriteBatch.End();

            base.Draw(gameTime);
        }