Esempio n. 1
0
 // Paints the GameWorld.
 private void GameWorldPB_Paint(object sender, PaintEventArgs e)
 {
     base.OnPaint(e);
     // Previews location of Tower placement if mouse is on the PictureBox.
     if (mousePos != null)
     {
         SolidBrush brush = new SolidBrush(Color.FromArgb(128, 200, 0, 0));
         // No tower selected: 1 square mouse cursor
         if (selectedTower == null)
         {
             e.Graphics.FillRectangle(brush, new Rectangle(GetTileAtMouse.pos, new Vector2D(BaseTile.size, BaseTile.size)));
         }
         // Tower selected: 4 square mouse cursor
         else
         {
             e.Graphics.FillRectangle(brush, new Rectangle(GetTileAtMouse.pos, new Vector2D(BaseTile.size * 2, BaseTile.size * 2)));
             if (selectedTower != null)
             {
                 selectedTower.position = GetTileAtMouse.pos + new Vector2D(BaseTile.size, BaseTile.size);;
                 selectedTower.DrawAttackRange(e.Graphics);
             }
         }
     }
     if (world.Tower != null)
     {
         SolidBrush blue = new SolidBrush(Color.FromArgb(128, Color.Blue));
         e.Graphics.FillRectangle(blue, new Rectangle(world.Tower.pos[0].pos, new Vector2D(BaseTile.size * 2, BaseTile.size * 2)));
         world.Tower.DrawAttackRange(e.Graphics);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Draw a silhouette of the pending tower over the mouse's current location.  Draw it with a red tint if the target area is obstructed.
        /// </summary>
        protected void DrawPendingTower()
        {
            Point drawSize = new Point(ActivePlayer.PendingTowerTemplate.SpriteWidth, ActivePlayer.PendingTowerTemplate.SpriteHeight);

            if (CursorIsOnMap())   // Draw the tower so that it snaps to the hovered grid position.
            {
                Point placementPos = GetAreaStartPoint();

                //Draw the tower to snap to the selected tiles
                Tower projectedTower = new Tower(ActivePlayer.PendingTowerTemplate, placementPos);
                projectedTower.Draw();

                //TODO: Check if the destination of this tower is obstructed, and change the tint accordingly

                // Draw the firing range of this tower's projected position.
                projectedTower.DrawAttackRange();
            }
        }