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); } } }
public static void InterpolateNormal(ref Vector2 vector1, ref Vector2 vector2, float t) { vector1 += (vector2 - vector1) * t; vector1.Normalize(); }
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); }
//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(); }