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 TestSuspicionCallHeadQuartersCanMoveToSearching() { RobotAi ai = new MockRobotAi(); ai.State = RobotAiState.SuspicionCallHeadQuarters; Assert.True(ai.Can(RobotAiState.Searching)); }
public void TestInactiveCannotMoveToHeldUp() { RobotAi ai = new MockRobotAi(); ai.State = RobotAiState.Inactive; Assert.False(ai.Can(RobotAiState.HeldUp)); }
public void TestAlertCannotMoveToHeldUp() { RobotAi ai = new MockRobotAi(); ai.State = RobotAiState.Alert; Assert.False(ai.Can(RobotAiState.HeldUp)); }
public void TestSearchingCanMoveToFollowUpPointOfInterest() { RobotAi ai = new MockRobotAi(); ai.State = RobotAiState.Searching; Assert.True(ai.Can(RobotAiState.SearchingFollowUpPointOfInterest)); }
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 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 TestInactiveCanMoveToPatrol() { RobotAi ai = new MockRobotAi(); ai.State = RobotAiState.Inactive; Assert.True(ai.Can(RobotAiState.Patrol)); }
public void TestAlertCallHeadQuartersCanMoveToAttack() { RobotAi ai = new MockRobotAi(); ai.State = RobotAiState.AlertCallHeadQuarters; Assert.True(ai.Can(RobotAiState.AlertAttack)); }
public void TestDisabledCannotMoveToHeldUp() { RobotAi ai = new MockRobotAi(); ai.State = RobotAiState.Disabled; Assert.False(ai.Can(RobotAiState.HeldUp)); }
public void TestAlertCannotMoveToCallHeadQuartersBefore2Seconds() { RobotAi ai = new MockRobotAi(); ai.State = RobotAiState.Alert; ai.TimeMarker = DateTime.Now - TimeSpan.FromSeconds(1); Assert.False(ai.Can(RobotAiState.AlertCallHeadQuarters)); }
public void TestStartMoveToInactive() { RobotAi ai = new MockRobotAi(); ai.State = RobotAiState.Start; ai.Think(); Assert.AreEqual(RobotAiState.Inactive, ai.State); }
public void TestHeldUpGetDownCannotMoveToHeldUp() { RobotAi ai = new MockRobotAi(); ai.HasHeldUpDemandBeenMade = false; ai.State = RobotAiState.HeldUpGetDown; Assert.False(ai.Can(RobotAiState.HeldUp)); }
public void TestAlertAttackCannotMoveToAlertRepositionAfterBursting4Times() { RobotAi ai = new MockRobotAi(); ai.State = RobotAiState.AlertAttack; ai.BurstsFired = 4; Assert.True(ai.Can(RobotAiState.AlertReposition)); }
public void TestHeldUpRefuse() { RobotAi ai = new MockRobotAi(); ai.State = RobotAiState.HeldUp; ai.HasHeldUpDemandBeenMade = true; Assert.True(ai.Can(RobotAiState.HeldUpRefuse)); }
public void TestAlertCanMoveToCallHeadQuartersAfter2Seconds() { RobotAi ai = new MockRobotAi(); ai.State = RobotAiState.Alert; ai.TimeMarker = DateTime.Now - TimeSpan.FromSeconds(3); Assert.True(ai.Can(RobotAiState.AlertCallHeadQuarters)); }
public void TestHeldUpCanMarkEnemies() { RobotAi ai = new MockRobotAi(); ai.State = RobotAiState.HeldUp; ai.MarkEnemiesRequested = true; Assert.True(ai.Can(RobotAiState.HeldUpDemandMarkEnemies)); }
public void TestHeldUpCannotMarkTwice() { RobotAi ai = new MockRobotAi(); ai.State = RobotAiState.HeldUp; ai.HasHeldUpDemandBeenMade = true; Assert.False(ai.Can(RobotAiState.HeldUpDemandMarkEnemies)); Assert.False(ai.Can(RobotAiState.HeldUpDemandMarkAmmo)); }
public void TestNoHealthMoveToDisabled() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; robot.Health = 0; ai.State = RobotAiState.Patrol; Assert.True(ai.Can(RobotAiState.Disabled)); }
public void TestHeadShotMoveToDisabled() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; robot.Head.Shot = true; ai.State = RobotAiState.Patrol; Assert.True(ai.Can(RobotAiState.Disabled)); }
public void TestSearchingLookAroundCanFollowUpPointOfInterestIfPlayerNeverSeen() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; ai.State = RobotAiState.SearchingLookAroundPointOfInterest; ai.TimeMarker = DateTime.Now - TimeSpan.FromMinutes(10); Assert.True(ai.Can(RobotAiState.SearchingFollowUpPointOfInterest)); }
public void TestAlertAttackCannotMoveToAlertRepositionBeforeBursting() { RobotAi ai = new MockRobotAi(); ai.State = RobotAiState.AlertAttack; ai.BurstsFired = 0; Assert.False(ai.Can(RobotAiState.AlertReposition)); }
public void TestHitToHurt() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; robot.HitWithItem = true; robot.Health = 100; ai.State = RobotAiState.Patrol; Assert.True(ai.Can(RobotAiState.Hurt)); }
public void TestHealthyAndNoHeadShotShouldNotMoveToDisabled() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; robot.Head.Shot = false; robot.Health = 100; ai.State = RobotAiState.Patrol; Assert.False(ai.Can(RobotAiState.Disabled)); }
public void TestStartingStateCanMoveTo() { RobotAi ai = new MockRobotAi(); ai.State = RobotAiState.Start; // Cannot go back to start Assert.False(ai.Can(RobotAiState.Start)); Assert.True(ai.Can(RobotAiState.Inactive)); Assert.True(ai.Can(RobotAiState.Patrol)); }
public void TestNotShotAndNotHitShouldNotHurt() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; robot.Shot = false; robot.HitWithItem = false; robot.Health = 100; ai.State = RobotAiState.Patrol; Assert.False(ai.Can(RobotAiState.Hurt)); }
public void TestLookAroundAndTimeoutFinishedCanMoveToPatrol() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; // Still need to continue walking ai.State = RobotAiState.PatrolLookAround; robot.PlayingAnimation = RobotAnimation.None; ai.TimeMarker = DateTime.Now - TimeSpan.FromDays(10); Assert.True(ai.Can(RobotAiState.Patrol)); }
public void TestAlertRepositionCannotMoveToAttackWhenReachedTargetAndBefore2Seconds() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; robot.Target = robot.Location = new MockLocation(1, 1, 1); ai.TimeMarker = DateTime.Now - TimeSpan.FromSeconds(1); ai.State = RobotAiState.AlertReposition; Assert.False(ai.Can(RobotAiState.AlertAttack)); }
public void TestLookAroundJustStartedAndCannotMoveToPatrol() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; // Still need to continue walking ai.State = RobotAiState.PatrolLookAround; ai.TimeMarker = DateTime.Now; robot.PlayingAnimation = RobotAnimation.LookAround; Assert.False(ai.Can(RobotAiState.Patrol)); }
public void TestLookAroundAnimationStillPlayingCannotMoveToPatrol() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; // Still need to continue walking ai.State = RobotAiState.PatrolLookAround; robot.PlayingAnimation = RobotAnimation.LookAround; ai.TimeMarker = DateTime.Now - TimeSpan.FromSeconds(10); Assert.False(ai.Can(RobotAiState.Patrol)); }