Ejemplo n.º 1
0
 void ProcessOffense()
 {
     if (this.readyToFire & this.AllowedToFire)
     {
         Vehicle target = this.SelectTarget();
         if (target != null)
         {
             float xDistance = target.Position.X - this.Position.X;
             float yDistance = target.Position.Y - this.Position.Y;
             Vector2 xVector = new Vector2(xDistance, Math.Abs(xDistance) * -1);
             xVector.Normalize();
             int speed = this.Get45Speed(Math.Abs(xDistance), yDistance);
             this.Shoot(xVector, speed);
         }
     }
 }
Ejemplo n.º 2
0
 public static void InterpolateNormal(ref Vector2 vector1, ref Vector2 vector2, float t)
 {
     vector1 += (vector2 - vector1) * t;
     vector1.Normalize();
 }
Ejemplo n.º 3
0
 public static Vector2 Reflect(Vector2 speed, Line2 wall)
 {
     Vector2 _vector = new Vector2(wall._p1.X - wall._p2.X, wall._p1.Y - wall._p2.Y);
     Calculator.RotateVector(ref _vector, 1.57f);
     _vector.Normalize();
     return Reflect(speed, _vector);
 }
Ejemplo n.º 4
0
 //Interpolate normal vectors ...
 public static void InterpolateNormal(ref Vector2 vector1, ref Vector2 vector2, float t, out Vector2 vector)
 {
     vector = vector1 + (vector2 - vector1) * t;
     vector.Normalize();
 }