Пример #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 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);
        }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
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);
        }
Пример #6
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));
        }
Пример #7
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);
        }
Пример #8
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);
        }
Пример #9
0
        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);
        }
Пример #10
0
        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);
        }
Пример #11
0
        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);
        }
Пример #12
0
        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);
        }
Пример #13
0
        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);
        }
Пример #14
0
        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);
        }
Пример #15
0
        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));
        }
Пример #16
0
        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));
        }
Пример #17
0
        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));
        }
Пример #18
0
        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));
        }
Пример #19
0
        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));
        }
Пример #20
0
        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));
        }
Пример #21
0
        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);
        }
Пример #22
0
        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));
        }
Пример #23
0
        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);
        }
Пример #24
0
        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));
        }
Пример #25
0
        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);
        }
Пример #26
0
        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));
        }
Пример #27
0
        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);
        }
Пример #28
0
        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));
        }
Пример #29
0
        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));
        }
Пример #30
0
        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));
        }