コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        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));
        }
コード例 #10
0
        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));
        }
コード例 #11
0
        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));
        }
コード例 #12
0
        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));
        }
コード例 #13
0
        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));
        }
コード例 #14
0
        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));
        }
コード例 #15
0
        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));
        }
コード例 #16
0
        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));
        }
コード例 #17
0
        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));
        }
コード例 #18
0
        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));
        }
コード例 #19
0
        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));
        }
コード例 #20
0
        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));
        }
コード例 #21
0
        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);
        }
コード例 #22
0
        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);
        }
コード例 #23
0
        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);
        }
コード例 #24
0
        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());
        }
コード例 #25
0
        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());
        }
コード例 #26
0
        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);
        }
コード例 #27
0
        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);
        }
コード例 #28
0
        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);
        }
コード例 #29
0
        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));
        }
コード例 #30
0
        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));
        }