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 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 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 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 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 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 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 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)); }
public void TestSearchingFollowUpCannotMoveToLookAroundIfHasNotReachedTarget() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; robot.Target = new MockLocation(10, 10, 10); robot.Location = new MockLocation(1, 1, 1); ai.State = RobotAiState.SearchingFollowUpPointOfInterest; Assert.False(ai.Can(RobotAiState.SearchingLookAroundPointOfInterest)); }
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 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 TestSearchingFollowUpCanMoveToLookAround() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; robot.Target = new MockLocation(10, 10, 10); robot.Location = robot.Target; ai.State = RobotAiState.SearchingFollowUpPointOfInterest; Assert.True(ai.Can(RobotAiState.SearchingLookAroundPointOfInterest)); }
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 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 TestLookAroundAnimationFinishedButTimeoutHasNotElapsedCannotMoveToPatrol() { 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; Assert.False(ai.Can(RobotAiState.Patrol)); }
public void TestSearchingLookAroundShouldFollowUpPlayerPositionIfSeenPlayer() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; ai.PlayerLocations.Add(new PlayerLocation(DateTime.Now, new MockLocation(), true, true)); ai.State = RobotAiState.SearchingLookAroundPointOfInterest; ai.TimeMarker = DateTime.Now - TimeSpan.FromMinutes(10); Assert.True(ai.Can(RobotAiState.SearchingFollowUpPlayerLastSeen)); Assert.False(ai.Can(RobotAiState.SearchingFollowUpPointOfInterest)); }
public void TestPatrolNotReachedWalkingDestinationCannotMoveToLookAround() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; // Still need to continue walking ai.State = RobotAiState.PatrolMarchToStart; robot.Location = new MockLocation(50, 50, 50); robot.PatrolEnd = new MockLocation(100, 100, 100); robot.PatrolStart = new MockLocation(1, 1, 1); Assert.False(ai.Can(RobotAiState.PatrolLookAround)); }
public void TestAlertFollowUpCannotSeeCannotHearAfter1MinuteCanMoveToSearching() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; robot.CanHearPlayer = false; robot.CanSeePlayer = false; ai.TimeMarker = DateTime.Now - TimeSpan.FromMinutes(10); ai.State = RobotAiState.AlertFollowUp; Assert.True(ai.Can(RobotAiState.Searching)); }
public void TestCannotHoldUpOnPatrolOver7Meters() { RobotAi ai = new MockRobotAi(); ai.State = RobotAiState.Patrol; MockDisabler disabler = (MockDisabler)ai.Player.Disabler; MockRobot robot = (MockRobot)ai.Robot; disabler.Location = new MockLocation(10, 10, 10); robot.Head.Location = new MockLocation(1, 1, 1); Assert.False(ai.Can(RobotAiState.HeldUp)); }
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 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 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 TestPatrolLookAroundRestartPatrol() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; robot.PatrolEnd = new MockLocation(0, 0, 0); robot.Target = robot.Location = robot.PatrolStart = new MockLocation(100, 100, 100); ai.State = RobotAiState.PatrolLookAround; ai.TimeMarker = DateTime.Now - TimeSpan.FromMinutes(10); ai.Think(); Assert.AreEqual(RobotAiState.Patrol, ai.State); Assert.True(robot.ReachedTarget()); }
public void TestPatrolTargetEndReached() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; robot.Target = robot.Location = robot.PatrolEnd = new MockLocation(0, 0, 0); robot.PatrolStart = new MockLocation(100, 100, 100); ai.State = RobotAiState.PatrolMarchToEnd; ai.Think(); Assert.AreEqual(RobotAiState.PatrolLookAround, ai.State); Assert.AreEqual(new MockLocation(0, 0, 0), robot.Target); Assert.True(robot.ReachedTarget()); }
public void TestHurtHit() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; robot.Health = 3; robot.Shot = true; ai.State = RobotAiState.Patrol; ai.Think(); Assert.AreEqual(RobotAiState.Hurt, ai.State); Assert.AreEqual(2, robot.Health); Assert.AreEqual(RobotAnimation.HurtStagger, robot.PlayingAnimation); }
public void TestDisableHeadShot() { RobotAi ai = new MockRobotAi(); MockRobot robot = (MockRobot)ai.Robot; robot.Health = 3; robot.Head.Shot = true; ai.State = RobotAiState.Patrol; ai.Think(); Assert.AreEqual(RobotAiState.Disabled, ai.State); Assert.AreEqual(0, robot.Health); Assert.AreEqual(RobotAnimation.RagDoll, 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 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 TestPatrolCanMoveToPatrolWalkToEnding() { RobotAi ai = new MockRobotAi(); ai.State = RobotAiState.Patrol; MockRobot robot = (MockRobot)ai.Robot; robot.Location = new MockLocation(1, 1, 1); robot.PatrolEnd = new MockLocation(100, 100, 100); robot.PatrolStart = new MockLocation(1, 1, 1); Assert.True(ai.Can(RobotAiState.PatrolMarchToEnd)); }