Пример #1
0
 public Bullet(FiguresAbstract tank)
 {
     this.power = tank.Power;
     this.point = tank.Points[0];
     if (tank.Points[0].Y < tank.Points[1].Y && tank.Points[0].Y < tank.Points[2].Y)
     {
         track = new int[] { 0, -1 };
     }
     else if (tank.Points[0].Y > tank.Points[1].Y && tank.Points[0].Y > tank.Points[2].Y)
     {
         track = new int[] { 0, 1 };
     }
     else if (tank.Points[0].X > tank.Points[1].X && tank.Points[0].X > tank.Points[2].X)
     {
         track = new int[] { 1, 0 };
     }
     else if (tank.Points[0].X < tank.Points[1].X && tank.Points[0].X < tank.Points[2].X)
     {
         track = new int[] { -1, 0 };
     }
 }
Пример #2
0
        public bool CheckLive(int x, int y, FiguresAbstract tank1)
        {
            double a1 = (this.point.X - tank1.Points[0].X) * (tank1.Points[1].Y - tank1.Points[0].Y) - (tank1.Points[1].X - tank1.Points[0].X) * (point.Y - tank1.Points[0].Y),
                   b1 = (this.point.X - tank1.Points[1].X) * (tank1.Points[2].Y - tank1.Points[1].Y) - (tank1.Points[2].X - tank1.Points[1].X) * (point.Y - tank1.Points[1].Y),
                   c1 = (this.point.X - tank1.Points[2].X) * (tank1.Points[0].Y - tank1.Points[2].Y) - (tank1.Points[0].X - tank1.Points[2].X) * (point.Y - tank1.Points[2].Y);

            if ((a1 == 0 && point.Y > tank1.Points[1].Y && point.Y <tank1.Points[0].Y && point.X> tank1.Points[0].X && point.X < tank1.Points[1].X) ||
                (c1 == 0 && point.Y > tank1.Points[0].Y && point.Y <tank1.Points[2].Y && point.X> tank1.Points[2].X && point.X < tank1.Points[0].X) ||
                (b1 == 0 && point.Y > tank1.Points[2].Y && point.Y <tank1.Points[1].Y && point.X> tank1.Points[1].X && point.X < tank1.Points[2].X) ||
                (a1 > 0 && c1 > 0 && b1 > 0) || (a1 < 0 && c1 < 0 && b1 < 0))
            {
                tank1.CheckLife(power);
                return(false);
            }
            else if (this.point.X > x || this.point.X < 0 || this.point.Y > y || this.point.Y < 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Пример #3
0
 public PowerTank(FiguresAbstract tank) : base(tank, tank.Speed, tank.Armor, tank.Power, tank.Live)
 {
     this.Power = tank.Power + 1;
 }
Пример #4
0
 public DecoratorTanks(FiguresAbstract tank, int speed, int armor, int power, int live) : base(tank.Points, tank.Color, tank.Speed, tank.Armor, tank.Power, tank.Live)
 {
     this.tank = tank;
 }