示例#1
0
        public void Combat_turnship5()
        {
            Combat_setupbattle();

            Console.WriteLine("doing battle.start from test");

            battle.Start();

            int tick = 0, cmdFreqCounter = 0;

            Compass startHeading = new Compass(180, false);
            Compass wpCompass    = new Compass(270, false);
            Compass endHeading   = new Compass(startHeading.Degrees + (spinrate.Degrees / Battle_Space.TicksPerSecond), false);

            // test 5 ship heading 180 waypoint at 270
            // ship should rotate positive by turn rate but not more than the spinrate.
            testComObj.cmbt_loc  = new PointXd();
            testComObj.cmbt_head = startHeading;

            testComObj.waypointTarget = new CombatWaypoint(wpCompass.Point((Fix16)1));
            battle.ProcessTick(ref tick, ref cmdFreqCounter);
            battle.End(battle.CurrentTick);
            Assert.AreEqual(
                endHeading.Degrees,
                testComObj.cmbt_head.Degrees);
        }
示例#2
0
        public void Combat_turnship2()
        {
            Combat_setupbattle();

            Console.WriteLine("doing battle.start from test");

            battle.Start();

            int tick = 0, cmdFreqCounter = 0;

            Compass startHeading = new Compass(0, false);
            Compass wpCompass    = new Compass(270, false);
            Compass endHeading   = new Compass(startHeading.Degrees - (spinrate.Degrees / Battle_Space.TicksPerSecond), false);

            //test 2 ship heading 0 waypoint at 270
            // ship should rotate negative by turn rate but not past waypoint
            testComObj.cmbt_loc  = new PointXd();
            testComObj.cmbt_head = startHeading;

            testComObj.waypointTarget = new CombatWaypoint(wpCompass.Point((Fix16)1));
            battle.ProcessTick(ref tick, ref cmdFreqCounter);
            //Assert.AreEqual(
            //    Compass.NormalizeDegrees(Fix16.Max((Fix16)360 - spinrate.Degrees, (Fix16)270)),
            //    testComObj.cmbt_head.Degrees);
            Assert.AreEqual(
                endHeading.Degrees,
                testComObj.cmbt_head.Degrees);
        }
示例#3
0
        public void Combat_turnship0()
        {
            Combat_setupbattle();

            battle.Start();

            int tick = 0, cmdFreqCounter = 0;

            Compass startHeading = new Compass(0, false);
            Compass wpCompass    = new Compass(90, false);
            Compass endHeading   = new Compass(startHeading.Degrees + (spinrate.Degrees / Battle_Space.TicksPerSecond), false);

            // test 0 ship heading 0 waypoint at 90
            // ship should rotate positive by turn rate but not past waypoint
            testComObj.cmbt_loc  = new PointXd();
            testComObj.cmbt_head = startHeading;

            testComObj.waypointTarget = new CombatWaypoint(wpCompass.Point((Fix16)1));
            battle.ProcessTick(ref tick, ref cmdFreqCounter);
            Assert.AreEqual(
                endHeading.Degrees,
                testComObj.cmbt_head.Degrees);
        }
示例#4
0
        public void Combat_turnship6() //I think this is a floating point error from when it gets a point from a bearing.
        {
            Combat_setupbattle();

            battle.Start();

            int tick = 0, cmdFreqCounter = 0;

            Compass startHeading = new Compass(0, false);
            Compass endHeading   = new Compass(spinrate.Degrees / Battle_Space.TicksPerSecond, false);

            // test 6 ship heading 0 waypoint at half turn rate
            // ship should rotate to face waypoint
            testComObj.cmbt_loc  = new PointXd();
            testComObj.cmbt_head = startHeading;

            testComObj.waypointTarget = new CombatWaypoint(endHeading.Point((Fix16)5));
            battle.ProcessTick(ref tick, ref cmdFreqCounter);
            battle.End(battle.CurrentTick);
            AssertAngleWithinTolerance(endHeading, testComObj.cmbt_head, 0.01);

            battle.End(battle.CurrentTick);
        }
示例#5
0
 /// <summary>
 /// Asserts that two points are "close enough" within a certain tolerance.
 /// </summary>
 /// <param name="expected"></param>
 /// <param name="actual"></param>
 private void AssertPointWithinTolerance(Compass expectedAngle, Fix16 expectedRadius, Compass actualAngle, Fix16 actualRadius, Fix16 tolerance)
 {
     AssertPointWithinTolerance(expectedAngle.Point(expectedRadius), actualAngle.Point(actualRadius), tolerance);
 }