Exemple #1
0
        private void Draw()
        {
            int weight = Constants.pixel * Constants.tileWidth;

            System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
            System.Drawing.Graphics   formGraphics;
            formGraphics = this.CreateGraphics();

            for (int i = 0; i < game.Map.GetRowNum(); i++)
            {
                for (int j = 0; j < game.Map.GetColumnNum(); j++)
                {
                    TileBase iTile = game.Map.GetTile(i, j);
                    myBrush.Color = GetTileColor(iTile.Type());
                    formGraphics.FillRectangle(myBrush, new Rectangle(j * weight, i * weight, weight, weight));
                }
            }
            foreach (MoveObject mobject in game.GameObject)
            {
                if (mobject is Tank)
                {
                    myBrush.Color = Color.Green;
                }
                else if (mobject is BonusSpeed)
                {
                    myBrush.Color = Color.Pink;
                }
                else if (mobject is BonusPower)
                {
                    myBrush.Color = Color.Yellow;
                }
                else if (mobject is Tower)
                {
                    myBrush.Color = Color.Red;
                }
                else if (mobject is TowerUpgrade)
                {
                    myBrush.Color = Color.Violet;
                }
                else
                {
                    myBrush.Color = Color.Red;
                }
                formGraphics.FillEllipse(myBrush, new Rectangle(mobject.X * Constants.pixel, mobject.Y * Constants.pixel, mobject.Width * Constants.pixel, mobject.Width * Constants.pixel));
                myBrush.Color = Color.White;
                if ((mobject is Tank) || (mobject is Tower) || (mobject is TowerUpgrade))
                {
                    if (mobject.Direction == DirectionType.Down)
                    {
                        formGraphics.FillRectangle(myBrush, new Rectangle((mobject.X + 1) * Constants.pixel + 5, (mobject.Y + 2) * Constants.pixel, Constants.pixel / 2, Constants.pixel));
                    }
                    if (mobject.Direction == DirectionType.Up)
                    {
                        formGraphics.FillRectangle(myBrush, new Rectangle((mobject.X + 1) * Constants.pixel + 5, mobject.Y * Constants.pixel, Constants.pixel / 2, Constants.pixel));
                    }
                    if (mobject.Direction == DirectionType.Left)
                    {
                        formGraphics.FillRectangle(myBrush, new Rectangle(mobject.X * Constants.pixel, (mobject.Y + 1) * Constants.pixel + 5, Constants.pixel, Constants.pixel / 2));
                    }
                    if (mobject.Direction == DirectionType.Right)
                    {
                        formGraphics.FillRectangle(myBrush, new Rectangle((mobject.X + 2) * Constants.pixel, (mobject.Y + 1) * Constants.pixel + 5, Constants.pixel, Constants.pixel / 2));
                    }
                }
            }
        }
Exemple #2
0
 public override void ContactTile(TileBase tile, out bool needRemove)
 {
     needRemove = true;
 }