Esempio n. 1
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);
        }
Esempio n. 2
0
        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));
        }
Esempio n. 5
0
        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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
        public void TestInactiveCanMoveToPatrol()
        {
            RobotAi ai = new MockRobotAi();

            ai.State = RobotAiState.Inactive;
            Assert.True(ai.Can(RobotAiState.Patrol));
        }
Esempio n. 9
0
        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));
        }
Esempio n. 11
0
        public void TestAlertCannotMoveToCallHeadQuartersBefore2Seconds()
        {
            RobotAi ai = new MockRobotAi();

            ai.State      = RobotAiState.Alert;
            ai.TimeMarker = DateTime.Now - TimeSpan.FromSeconds(1);
            Assert.False(ai.Can(RobotAiState.AlertCallHeadQuarters));
        }
Esempio n. 12
0
        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));
        }
Esempio n. 14
0
        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));
        }
Esempio n. 16
0
        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));
        }
Esempio n. 21
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));
        }
Esempio n. 22
0
        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));
        }
Esempio n. 27
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));
        }
Esempio n. 28
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));
        }
Esempio n. 29
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));
        }
Esempio n. 30
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));
        }