コード例 #1
0
 public override void BlowUp()
 {
     dead = true;
     Erase();
     Sound.BoomSoundFlag = true;
     BadaBoom Blow = new BadaBoom(Direction, TankSpeed, TankColor, Position, 1);
 }
コード例 #2
0
        protected override bool FaceTank()
        {
            lock (Program.ListLocker)
            {
                int counter = 0;
                switch (FriendOrFoe)
                {
                case 1:
                {
                    foreach (Tank element in Program.MyTanks)
                    {
                        COORD DimensionsLeftTop     = new COORD(element.GetPosition().x - 2, element.GetPosition().y - 2);
                        COORD DimensionsRightBottom = new COORD(element.GetPosition().x + 2, element.GetPosition().y + 2);
                        if (position.x >= DimensionsLeftTop.x && position.x <= DimensionsRightBottom.x && position.y >= DimensionsLeftTop.y && position.y <= DimensionsRightBottom.y)
                        {
                            element.Index = counter;
                            element.Hit();
                            BadaBoom Boom = new BadaBoom(direction, speed, ShotColor, position, FriendOrFoe);
                            return(true);
                        }
                        counter++;
                    }
                    break;
                }

                case 2:
                {
                    foreach (Tank element in Program.EnemyTanks)
                    {
                        COORD DimensionsLeftTop     = new COORD(element.GetPosition().x - 2, element.GetPosition().y - 2);
                        COORD DimensionsRightBottom = new COORD(element.GetPosition().x + 2, element.GetPosition().y + 2);
                        if (position.x >= DimensionsLeftTop.x && position.x <= DimensionsRightBottom.x && position.y >= DimensionsLeftTop.y && position.y <= DimensionsRightBottom.y)
                        {
                            element.Index = counter;
                            element.Hit();
                            BadaBoom Boom = new BadaBoom(direction, speed, ShotColor, position, FriendOrFoe);
                            return(true);
                        }
                        counter++;
                    }
                    break;
                }
                }
                return(false);
            }
        }
コード例 #3
0
 protected override bool FaceWall()
 {
     lock (Program.ListLocker)
     {
         int counter = 0;
         foreach (Wall element in Program.Walls)
         {
             COORD DimensionsLeftTop     = element.Dimensions[0];
             COORD DimensionsRightBottom = element.Dimensions[1];
             if (position.x >= DimensionsLeftTop.x && position.x <= DimensionsRightBottom.x && position.y >= DimensionsLeftTop.y && position.y <= DimensionsRightBottom.y)
             {
                 Program.Walls[counter].Erase();
                 Program.Walls.RemoveAt(counter);
                 BadaBoom Boom = new BadaBoom(direction, speed, ShotColor, position, FriendOrFoe);
                 return(true);
             }
             counter++;
         }
         return(false);
     }
 }