public void TestGetDownMarkItemReturnToGetDown() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; MockItem item = new MockItem(robot.Location); // Hold up robot.Head.Location = player.Disabler.Location = new MockLocation(); ai.State = RobotAiState.HeldUp; ai.Think(); Assert.AreEqual(RobotAiState.HeldUp, ai.State); // Get down ai.GetDownRequested = true; ai.Think(); Assert.AreEqual(RobotAiState.HeldUpGetDown, ai.State); Assert.AreEqual(RobotAnimation.CoweringOnGround, robot.PlayingAnimation); // Mark items ai.MarkItemsRequested = true; player.Items.Add(item); ai.Think(); Assert.AreEqual(RobotAiState.HeldUpDemandMarkAmmo, ai.State); Assert.True(item.HasBeenMarkedForPlayer); // Return to get down ai.Think(); Assert.AreEqual(RobotAiState.HeldUpGetDown, ai.State); Assert.AreEqual(RobotAnimation.CoweringOnGround, robot.PlayingAnimation); }
public void TestHoldUpRefuseReturnToHoldUpAfterAnimationFinishes() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; robot.Head.Location = player.Disabler.Location = new MockLocation(); // Demand something after we've already made a demands ai.State = RobotAiState.HeldUp; ai.MarkEnemiesRequested = true; ai.HasHeldUpDemandBeenMade = true; ai.Think(); Assert.AreEqual(RobotAiState.HeldUpRefuse, ai.State); Assert.AreEqual(RobotAnimation.CoweringRefuse, robot.PlayingAnimation); // Animation is still playing ai.Think(); Assert.AreEqual(RobotAiState.HeldUpRefuse, ai.State); Assert.AreEqual(RobotAnimation.CoweringRefuse, robot.PlayingAnimation); // Animation has finished robot.PlayingAnimation = RobotAnimation.None; ai.Think(); Assert.AreEqual(RobotAiState.HeldUp, ai.State); Assert.AreEqual(RobotAnimation.CoweringStanding, robot.PlayingAnimation); }
public void TestSuspicionSeenThreeTimesStartFollowUp() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; robot.Head.Location = robot.Location = new MockLocation(0, 0, 0); player.Disabler.Location = player.Location = new MockLocation(39, 0, 0); ai.State = RobotAiState.Patrol; for (int i = 0; i < 5; i++) { // true, false, true, false, true robot.CanSeePlayer = robot.CanHearPlayer = i % 2 == 0; ai.Think(); } Assert.AreEqual(RobotAiState.SuspicionCallHeadQuarters, ai.State); Assert.AreEqual(RobotAnimation.AlertCallHeadQuarters, robot.PlayingAnimation); robot.PlayingAnimation = RobotAnimation.None; robot.CanSeePlayer = robot.CanHearPlayer = false; ai.Think(); Assert.AreEqual(RobotAiState.SuspicionFollowUp, ai.State); Assert.AreEqual(ai.PlayerLocations.Last().Location, robot.Target); }
public void TestAttackingPlayerMoves60MetersOutOfLineOfSightFollowUp() { 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); robot.DetectionLineOfSight = robot.CanSeePlayer = true; ai.State = RobotAiState.AlertAttack; ai.Think(); Assert.AreEqual(RobotAiState.AlertFollowUp, ai.State); }
public void TestFinishedCallingHeadquartersStartsAttacking() { RobotAi ai = new MockRobotAi(); MockPlayer player = (MockPlayer)ai.Player; MockRobot robot = (MockRobot)ai.Robot; robot.DetectionLineOfSight = robot.CanSeePlayer = false; robot.PlayingAnimation = RobotAnimation.None; ai.State = RobotAiState.AlertCallHeadQuarters; ai.Think(); Assert.AreEqual(RobotAiState.AlertAttack, ai.State); }
public void TestPatrolCannotMoveToAlertWhenTooFarAway() { RobotAi ai = new MockRobotAi(); MockPlayer player = (MockPlayer)ai.Player; MockRobot robot = (MockRobot)ai.Robot; ai.State = RobotAiState.Patrol; player.Location = new MockLocation(100, 100, 100); robot.Location = new MockLocation(1, 1, 1); robot.DetectionLineOfSight = true; robot.CanSeePlayer = true; Assert.False(ai.Can(RobotAiState.Alert)); }
public void TestHoldUpRefuse() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; robot.Head.Location = player.Disabler.Location = new MockLocation(); ai.State = RobotAiState.HeldUp; ai.MarkEnemiesRequested = true; ai.HasHeldUpDemandBeenMade = true; ai.Think(); Assert.AreEqual(RobotAiState.HeldUpRefuse, ai.State); Assert.AreEqual(RobotAnimation.CoweringRefuse, robot.PlayingAnimation); }
public void TestAlertCallHeadQuartersAfterTwoSeconds() { RobotAi ai = new MockRobotAi(); MockPlayer player = (MockPlayer)ai.Player; MockRobot robot = (MockRobot)ai.Robot; robot.DetectionLineOfSight = robot.CanSeePlayer = false; ai.TimeMarker = (DateTime.Now - TimeSpan.FromSeconds(2.1)); ai.State = RobotAiState.Alert; ai.Think(); Assert.AreEqual(RobotAiState.AlertCallHeadQuarters, ai.State); Assert.AreEqual(RobotAnimation.AlertCallHeadQuarters, robot.PlayingAnimation); }
public void TestSuspicionFollowUpToShrugOff() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; robot.Location = robot.Head.Location = robot.Target = new MockLocation(100, 100, 100); robot.PlayingAnimation = RobotAnimation.None; ai.State = RobotAiState.SuspicionLookAround; ai.Think(); Assert.AreEqual(RobotAiState.SuspicionShrugOff, ai.State); }
public void TestAlertFromPatrol() { RobotAi ai = new MockRobotAi(); MockPlayer player = (MockPlayer)ai.Player; MockRobot robot = (MockRobot)ai.Robot; // The Robot can see the player within 15m via Line of Sight robot.Head.Location = robot.Location = new MockLocation(0, 0, 0); player.Disabler.Location = player.Location = new MockLocation(14, 0, 0); robot.DetectionLineOfSight = robot.CanSeePlayer = true; ai.State = RobotAiState.Patrol; ai.Think(); Assert.AreEqual(RobotAiState.Alert, ai.State); }
public void TestSuspicionShrugOffBackToPatrol() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; robot.Location = robot.Head.Location = robot.Target = new MockLocation(100, 100, 100); robot.PlayingAnimation = RobotAnimation.None; ai.State = RobotAiState.SuspicionShrugOff; ai.Think(); Assert.AreEqual(RobotAiState.Patrol, ai.State); }
public void TestHoldUp() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; robot.Head.Location = player.Disabler.Location = new MockLocation(); ai.State = RobotAiState.Patrol; ai.Think(); Assert.AreEqual(RobotAiState.HeldUp, ai.State); Assert.AreEqual(RobotAnimation.CoweringStanding, robot.PlayingAnimation); Assert.False(robot.DetectionLineOfSight); Assert.False(robot.DetectionAudio); }
public void TestPatrolRobotWasHeardWithin50M() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; robot.Head.Location = robot.Location = new MockLocation(0, 0, 0); player.Disabler.Location = player.Location = new MockLocation(39, 0, 0); robot.DetectionLineOfSight = robot.CanSeePlayer = false; robot.DetectionAudio = robot.CanHearPlayer = true; ai.State = RobotAiState.Patrol; ai.Think(); Assert.AreEqual(RobotAiState.Suspicion, ai.State); }
public void TestHoldUpGetDown() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; robot.Head.Location = player.Disabler.Location = new MockLocation(); ai.State = RobotAiState.HeldUp; ai.GetDownRequested = true; ai.Think(); Assert.AreEqual(RobotAiState.HeldUpGetDown, ai.State); Assert.AreEqual(RobotAnimation.CoweringOnGround, robot.PlayingAnimation); Assert.False(robot.DetectionLineOfSight); Assert.False(robot.DetectionAudio); }
public void TestSuspicionCannotMoveToCallHeadQuartersWhenNeverSeenOrHeard() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; robot.CanHearPlayer = false; robot.CanSeePlayer = false; robot.DetectionLineOfSight = true; robot.DetectionAudio = true; robot.Location = new MockLocation(999, 999, 999); player.Location = new MockLocation(1, 1, 1); ai.State = RobotAiState.Suspicion; Assert.False(ai.Can(RobotAiState.SuspicionCallHeadQuarters)); }
public void TestSuspicionCanMoveToCallHeadQuartersWhenSeenUnder50MetersAway() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; robot.CanHearPlayer = false; robot.CanSeePlayer = true; robot.DetectionLineOfSight = true; robot.DetectionAudio = true; robot.Location = new MockLocation(21, 1, 1); player.Location = new MockLocation(1, 1, 1); ai.State = RobotAiState.Suspicion; Assert.True(ai.Can(RobotAiState.SuspicionCallHeadQuarters)); }
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)); }
public void TestPatrolCannotMoveToSuspicionWhenSeenAndLessThan15Meters() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; robot.CanHearPlayer = false; robot.CanSeePlayer = true; robot.DetectionLineOfSight = true; robot.DetectionAudio = true; robot.Location = new MockLocation(11, 1, 1); player.Location = new MockLocation(1, 1, 1); ai.State = RobotAiState.Patrol; Assert.False(ai.Can(RobotAiState.Suspicion)); }
public void TestPatrolCanMoveToSuspicionWhenHeardAndUnder40MetersAway() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; robot.CanHearPlayer = true; robot.CanSeePlayer = false; robot.DetectionLineOfSight = true; robot.DetectionAudio = true; robot.Location = new MockLocation(21, 1, 1); player.Location = new MockLocation(1, 1, 1); ai.State = RobotAiState.Patrol; Assert.True(ai.Can(RobotAiState.Suspicion)); }
public void TestAlertAttackAndAlertRepositionTooFarOfPlayerCanMoveToFollowUp() { RobotAi ai = new MockRobotAi(); MockPlayer player = (MockPlayer)ai.Player; MockRobot robot = (MockRobot)ai.Robot; player.Location = new MockLocation(100, 100, 100); robot.Location = new MockLocation(1, 1, 1); robot.CanSeePlayer = true; robot.DetectionLineOfSight = true; ai.PlayerLocations.Add(new PlayerLocation(DateTime.Now, player.Location, true, true)); ai.State = RobotAiState.AlertAttack; Assert.True(ai.Can(RobotAiState.AlertFollowUp)); ai.State = RobotAiState.AlertReposition; Assert.True(ai.Can(RobotAiState.AlertFollowUp)); }
public void TestHoldUpDontMarkFarAwayItem() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; MockItem item = new MockItem(new MockLocation(999, 999, 999)); robot.Head.Location = player.Disabler.Location = new MockLocation(); ai.State = RobotAiState.HeldUp; ai.MarkItemsRequested = true; // Item within reach player.Items.Add(item); ai.Think(); Assert.AreEqual(RobotAiState.HeldUpDemandMarkAmmo, ai.State); Assert.False(item.HasBeenMarkedForPlayer); }
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)); }
public void TestHoldUpDontMarkFarEnemy() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; MockRobot otherRobot = new MockRobot(new MockLocation(999, 999, 999)); robot.Head.Location = player.Disabler.Location = new MockLocation(); ai.State = RobotAiState.HeldUp; ai.MarkEnemiesRequested = true; player.Robots.Add(robot); player.Robots.Add(otherRobot); ai.Think(); Assert.AreEqual(RobotAiState.HeldUpDemandMarkEnemies, ai.State); Assert.False(otherRobot.HasBeenMarkedForPlayer); Assert.False(robot.HasBeenMarkedForPlayer); }
public void TestAlertAttackAndAlertCannotRepositionWhenInSightAndInRange() { RobotAi ai = new MockRobotAi(); MockPlayer player = (MockPlayer)ai.Player; MockRobot robot = (MockRobot)ai.Robot; player.Location = new MockLocation(1, 1, 1); robot.Location = new MockLocation(1, 1, 1); robot.CanSeePlayer = true; robot.DetectionLineOfSight = true; ai.PlayerLocations.Add(new PlayerLocation(DateTime.Now, player.Location, true, true)); ai.State = RobotAiState.AlertAttack; Assert.False(ai.Can(RobotAiState.AlertFollowUp)); ai.State = RobotAiState.AlertReposition; Assert.False(ai.Can(RobotAiState.AlertFollowUp)); }
public void TestHurtBeforeStaggerAnimationWaitsForCompletion() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; // Just Hurt ai.State = RobotAiState.Hurt; robot.PlayingAnimation = RobotAnimation.HurtStagger; ai.Think(); Assert.AreEqual(RobotAiState.Hurt, ai.State); // Two seconds pass and animation is finished robot.PlayingAnimation = RobotAnimation.None; ai.TimeMarker = DateTime.Now - TimeSpan.FromSeconds(2.1); ai.Think(); Assert.AreEqual(RobotAiState.Suspicion, ai.State); }
public void TestSuspicionFollowUpCanMoveToLookAround() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; robot.CanHearPlayer = true; robot.CanSeePlayer = false; robot.DetectionLineOfSight = true; robot.DetectionAudio = true; robot.Target = robot.Location = new MockLocation(999, 999, 999); player.Location = new MockLocation(1, 1, 1); ai.PlayerLocations.Add(new PlayerLocation(DateTime.Now, robot.Location, false, true)); ai.State = RobotAiState.SuspicionFollowUp; Assert.True(ai.Can(RobotAiState.SuspicionLookAround)); }
public void TestHoldUpMarkItemsRefuseSecondTime() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; MockRobot otherRobot = new MockRobot(); robot.Head.Location = player.Disabler.Location = new MockLocation(); ai.State = RobotAiState.HeldUp; ai.MarkItemsRequested = true; ai.Think(); Assert.AreEqual(RobotAiState.HeldUpDemandMarkAmmo, ai.State); ai.Think(); Assert.AreEqual(RobotAiState.HeldUp, ai.State); ai.MarkEnemiesRequested = true; ai.Think(); Assert.AreEqual(RobotAiState.HeldUpRefuse, ai.State); }
public void TestSuspicionLookAroundCannotShrugOffIfCanSeePlayerAtLastLocation() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; robot.CanHearPlayer = false; robot.CanSeePlayer = true; robot.DetectionLineOfSight = true; robot.DetectionAudio = true; robot.Location = new MockLocation(999, 999, 999); player.Location = new MockLocation(1, 1, 1); ai.PlayerLocations.Add(new PlayerLocation(DateTime.Now, robot.Location, false, true)); ai.TimeMarker = DateTime.Now - TimeSpan.FromMinutes(1); ai.State = RobotAiState.SuspicionLookAround; Assert.False(ai.Can(RobotAiState.SuspicionShrugOff)); }
public void TestSuspicionLookAroundCannotShrugOffIfLookAroundAnimationPlaying() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; robot.CanHearPlayer = false; robot.CanSeePlayer = false; robot.DetectionLineOfSight = true; robot.DetectionAudio = true; robot.Location = new MockLocation(999, 999, 999); player.Location = new MockLocation(1, 1, 1); ai.PlayerLocations.Add(new PlayerLocation(DateTime.Now, robot.Location, false, true)); robot.PlayingAnimation = RobotAnimation.LookAround; ai.State = RobotAiState.SuspicionLookAround; Assert.False(ai.Can(RobotAiState.SuspicionShrugOff)); }
public void TestSuspicionShrugOffCanMoveToPatrol() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; MockPlayer player = (MockPlayer)ai.Player; robot.CanHearPlayer = false; robot.CanSeePlayer = false; robot.DetectionLineOfSight = true; robot.DetectionAudio = true; robot.Target = robot.Location = new MockLocation(999, 999, 999); player.Location = new MockLocation(1, 1, 1); ai.PlayerLocations.Add(new PlayerLocation(DateTime.Now, robot.Location, false, true)); ai.TimeMarker = DateTime.Now - TimeSpan.FromMinutes(1); ai.State = RobotAiState.SuspicionShrugOff; Assert.True(ai.Can(RobotAiState.Patrol)); }