public void MaxExtents() { var ship = new Ship(new Corporation()); var hardPoint = new HardPoint(ship, HardPointPosition.Right); var aimAt = new Location(1, 1, 0); // 45* forward Assert.IsTrue(hardPoint.AimAt(aimAt), "Position: {0:n2}", hardPoint.Inclination); hardPoint.Reset(); aimAt = new Location(1, -1, 0); // 45* behind Assert.IsTrue(hardPoint.AimAt(aimAt), "Position: {0:n2}", hardPoint.Inclination); // now test we can't move further downward aimAt = new Location(1, -1.1d, 0); Assert.IsFalse(hardPoint.AimAt(aimAt), "Position: {0:n2}", hardPoint.Inclination); }
public void TestMovesToExtent() { var ship = new Ship(new Corporation()); var hardPoint = new HardPoint(ship, HardPointPosition.Right); var aimAt = new Location(0, 1, 0); // 90* forward Assert.IsFalse(hardPoint.AimAt(aimAt), "Position: {0:n2}", hardPoint.Inclination); // assert we moved 45* Assert.AreEqual(Math.Round(Math.PI / 4, 4), Math.Round(Vector.Angle(hardPoint.Origin, hardPoint.Orientation), 4)); // assert we moved forward Assert.Greater(hardPoint.Orientation.Y, 0d); // now make sure the hard point knows this =) Assert.AreEqual(45d, hardPoint.Inclination); hardPoint.Reset(); aimAt = new Location(0, -1, 0); // 90* back Assert.IsFalse(hardPoint.AimAt(aimAt), "Position: {0:n2}", hardPoint.Inclination); // assert we moved 45* Assert.AreEqual(Math.Round(Math.PI / 4, 4), Math.Round(Vector.Angle(hardPoint.Origin, hardPoint.Orientation), 4)); // assert we moved back Assert.Less(hardPoint.Orientation.Y, 0d); // now make sure the hard point knows this =) Assert.AreEqual(-45d, hardPoint.Inclination); }