public void CreateShotTank(MovingObject sender)
        {
            switch (sender.MovementDirection)
            {
            case (int)Direction.DOWN:
            {
                ShotsTanks.Add(new ShotView(sender.X, sender.Y + 1, sender.MovementDirection, sender));
                break;
            }

            case (int)Direction.LEFT:
            {
                ShotsTanks.Add(new ShotView(sender.X - 1, sender.Y, sender.MovementDirection, sender));
                break;
            }

            case (int)Direction.RIGHT:
            {
                ShotsTanks.Add(new ShotView(sender.X + 1, sender.Y, sender.MovementDirection, sender));
                break;
            }

            case (int)Direction.UP:
            {
                ShotsTanks.Add(new ShotView(sender.X, sender.Y - 1, sender.MovementDirection, sender));
                break;
            }

            default:
                break;
            }

            var index = ShotsTanks.Last().InteractWithFixedObjects(Obstacles);

            if (index > 0)
            {
                mapGraphics.FillRectangle(Brushes.Black, Obstacles[index].X * MainForm.sizeCell, Obstacles[index].Y * MainForm.sizeCell, MainForm.sizeCell, MainForm.sizeCell);
                Obstacles.RemoveAt(index);
                ShotsTanks.RemoveAt(ShotsTanks.Count - 1);
            }
        }
Пример #2
0
        public void CreateShotTank(MovebleObj sender)
        {
            switch (sender.DirectionTo)
            {
            case (int)Direction.Down:
            {
                ShotsTanks.Add(new Shot(sender.X, sender.Y + 1, sender.DirectionTo, sender));
                break;
            }

            case (int)Direction.Left:
            {
                ShotsTanks.Add(new Shot(sender.X - 1, sender.Y, sender.DirectionTo, sender));
                break;
            }

            case (int)Direction.Right:
            {
                ShotsTanks.Add(new Shot(sender.X + 1, sender.Y, sender.DirectionTo, sender));
                break;
            }

            case (int)Direction.Up:
            {
                ShotsTanks.Add(new Shot(sender.X, sender.Y - 1, sender.DirectionTo, sender));
                break;
            }

            default:
                break;
            }
            if (ShotsTanks.Last().CollidesWithWalls(Walls))
            {
                ShotsTanks.RemoveAt(ShotsTanks.Count - 1);
            }
        }