Пример #1
0
 public MockLocation(float x = 0.0f, float y = 0.0f, float z = 0.0f, MockLocation randomLocation = null)
 {
     _x = x;
     _y = y;
     _z = z;
     this._randomLocation = randomLocation;
 }
Пример #2
0
        public float DistanceFrom(ILocation location)
        {
            if (location.GetType() == typeof(MockLocation))
            {
                MockLocation l = (MockLocation)location;
                return((float)Math.Sqrt(
                           Math.Pow(_x - l._x, 2.0f) +
                           Math.Pow(_y - l._y, 2.0f) +
                           Math.Pow(_z - l._z, 2.0f)
                           ));
            }

            throw new NotImplementedException("MockLocation cannot calculate distance from ILocation");
        }
Пример #3
0
        public void TestAttackingFired4BurstsShouldReposition()
        {
            RobotAi    ai     = new MockRobotAi();
            MockPlayer player = (MockPlayer)ai.Player;
            MockRobot  robot  = (MockRobot)ai.Robot;

            MockLocation repositionTarget = new MockLocation(-999, -999, -999);

            robot.Location = new MockLocation(0, 0, 0, repositionTarget);
            ai.BurstsFired = 4;
            ai.State       = RobotAiState.AlertAttack;
            ai.Think();


            Assert.AreEqual(RobotAiState.AlertReposition, ai.State);
            Assert.True(robot.Target.Equals(repositionTarget));
        }
Пример #4
0
        public void TestAttackingThreeSecondsPassedShouldReposition()
        {
            RobotAi    ai     = new MockRobotAi();
            MockPlayer player = (MockPlayer)ai.Player;
            MockRobot  robot  = (MockRobot)ai.Robot;

            MockLocation repositionTarget = new MockLocation(-999, -999, -999);

            robot.Location = new MockLocation(0, 0, 0, repositionTarget);
            ai.BurstsFired = 0;
            ai.State       = RobotAiState.AlertAttack;
            ai.TimeMarker  = DateTime.Now - TimeSpan.FromSeconds(3);
            ai.Think();


            Assert.AreEqual(RobotAiState.AlertReposition, ai.State);
            Assert.True(robot.Target.Equals(repositionTarget));
        }
Пример #5
0
        public void TestAttackingPlayerMoves60MetersOutOfLineOfSightFollowUpTargetsLastLocation()
        {
            RobotAi    ai     = new MockRobotAi();
            MockPlayer player = (MockPlayer)ai.Player;
            MockRobot  robot  = (MockRobot)ai.Robot;

            robot.Location  = new MockLocation(0, 0, 0);
            player.Location = new MockLocation(61, 0, 0);

            var lastSeenPlayerLocation  = new MockLocation(60, 0, 0);
            var lastHeardPlayerLocation = new MockLocation(40, 0, 0);

            ai.PlayerLocations.Add(new PlayerLocation(DateTime.Now, lastHeardPlayerLocation, false, true));
            ai.PlayerLocations.Add(new PlayerLocation(DateTime.Now, lastSeenPlayerLocation, true, false));

            robot.DetectionLineOfSight = robot.CanSeePlayer = true;
            ai.State = RobotAiState.AlertAttack;
            ai.Think();
            Assert.AreEqual(RobotAiState.AlertFollowUp, ai.State);
            Assert.True(robot.Target.Equals(lastSeenPlayerLocation));
        }
Пример #6
0
 protected bool Equals(MockLocation other)
 {
     return(_x == other._x && _y == other._y && _z == other._z);
 }