Example #1
0
 public double GetAngleTo(Unit unit)
 {
     return GetAngleTo(unit.x, unit.y);
 }
Example #2
0
 public double GetSpeed(Unit u)
 {
     return Math.Sqrt(u.SpeedX * u.SpeedX + u.SpeedY * u.SpeedY);
 }
Example #3
0
 public double GetDistanceTo(Unit unit)
 {
     return GetDistanceTo(unit.x, unit.y);
 }
Example #4
0
 public static Cell GetCell(Unit p)
 {
     return GetCell(p.X, p.Y);
 }
Example #5
0
 public double GetAngleTo(Unit unit)
 {
     return GetAngleTo(unit.X, unit.Y);
 }
Example #6
0
        public void GoTo(Unit self, double tX, double tY, double tSpeedX, double tSpeedY, out double power, out double turn)
        {
            double Rx = self.X - tX;
            double Ry = self.Y - tY;
            double Vx = self.SpeedX - tSpeedX;
            double Vy = self.SpeedY - tSpeedY;

            double t = (Vx * Vx + Vy * Vy) / (Vx * Vx + Vy * Vy + Rx * Rx + Ry * Ry);
            double Ax = -Rx * (1 - t) - Vx * t;
            double Ay = -Ry * (1 - t) - Vy * t;

            power = Math.Cos(GetAngleBetween(0, 0, Ax, Ay, self.Angle))
                * Math.Sqrt(Ax * Ax + Ay * Ay);

            double Frw = GetAngleBetween(0, 0, Ax, Ay, self.Angle);
            double Bck = GetAngleBetween(0, 0, -Ax, -Ay, self.Angle);

            if (Math.Abs(Frw) < Math.Abs(Bck) + Math.PI / 18.0D)
                turn = Frw;
            else
                turn = -Bck;
        }
Example #7
0
 public void GoTo(Unit self, Unit target, out double power, out double turn)
 {
     GoTo(self, target.X, target.Y, target.SpeedX, target.SpeedY, out power, out turn);
 }
Example #8
0
 public double GetDistance(double X, double Y, Unit U)
 {
     return GetDistance(U.X, U.Y, X, Y);
 }