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);
        }
        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. 3
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. 4
0
        public void TestStartMoveToInactive()
        {
            RobotAi ai = new MockRobotAi();

            ai.State = RobotAiState.Start;
            ai.Think();
            Assert.AreEqual(RobotAiState.Inactive, ai.State);
        }
        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);
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        public void TestHoldUpMarkItemReturnToHeldUp()
        {
            RobotAi    ai     = new MockRobotAi();
            MockRobot  robot  = (MockRobot)ai.Robot;
            MockPlayer player = (MockPlayer)ai.Player;
            MockItem   item   = new MockItem(robot.Location);

            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.True(item.HasBeenMarkedForPlayer);

            ai.Think();
            Assert.AreEqual(RobotAiState.HeldUp, ai.State);
        }
Esempio n. 8
0
        public void TestRepositionBackToAttacking()
        {
            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));


            robot.Location = repositionTarget;
            ai.Think();
            Assert.AreEqual(RobotAiState.AlertAttack, ai.State);
        }
Esempio n. 9
0
        public void TestHoldUpMarkEnemyReturnToHeldUp()
        {
            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.MarkEnemiesRequested = true;

            player.Robots.Add(robot);
            player.Robots.Add(otherRobot);
            ai.Think();

            Assert.AreEqual(RobotAiState.HeldUpDemandMarkEnemies, ai.State);
            Assert.True(otherRobot.HasBeenMarkedForPlayer);
            Assert.False(robot.HasBeenMarkedForPlayer);

            ai.Think();
            Assert.AreEqual(RobotAiState.HeldUp, ai.State);
        }
Esempio n. 10
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);
        }
Esempio n. 11
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);
        }
Esempio n. 12
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);
        }
Esempio n. 13
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);
        }
Esempio n. 14
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);
        }
Esempio n. 15
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);
        }
Esempio n. 16
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());
        }
Esempio n. 17
0
        public void TestSuspicionAfter3SightingsCallHq()
        {
            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);

            for (int i = 0; i < 3; i++)
            {
                ai.PlayerLocations.Add(new PlayerLocation(DateTime.Now, player.Location, true, true));
            }

            robot.CanSeePlayer = robot.CanHearPlayer = true;
            ai.State           = RobotAiState.Patrol;
            ai.Think();
            Assert.AreEqual(RobotAiState.Suspicion, ai.State);

            robot.CanSeePlayer = robot.CanHearPlayer = false;
            ai.Think();
            Assert.AreEqual(RobotAiState.SuspicionCallHeadQuarters, ai.State);
        }
Esempio n. 18
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());
        }
Esempio n. 19
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);
        }
Esempio n. 20
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);
        }
Esempio n. 21
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);
        }
Esempio n. 22
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);
        }
Esempio n. 23
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);
        }
Esempio n. 24
0
        public void TestDisableHit()
        {
            RobotAi   ai    = new MockRobotAi();
            MockRobot robot = (MockRobot)ai.Robot;

            robot.Health = 1;
            robot.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);
            Assert.False(robot.DetectionLineOfSight);
            Assert.False(robot.DetectionAudio);
        }
Esempio n. 25
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);
        }
Esempio n. 26
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));
        }
Esempio n. 27
0
        public void TestAttackingPlayerMoves60MetersOutOfLineOfSightFollowUpTargetsLastLocation()
        {
            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);

            var lastSeenPlayerLocation  = new MockLocation(60, 0, 0);
            var lastHeardPlayerLocation = new MockLocation(40, 0, 0);

            ai.PlayerLocations.Add(new PlayerLocation(DateTime.Now, lastHeardPlayerLocation, false, true));
            ai.PlayerLocations.Add(new PlayerLocation(DateTime.Now, lastSeenPlayerLocation, true, false));

            robot.DetectionLineOfSight = robot.CanSeePlayer = true;
            ai.State = RobotAiState.AlertAttack;
            ai.Think();
            Assert.AreEqual(RobotAiState.AlertFollowUp, ai.State);
            Assert.True(robot.Target.Equals(lastSeenPlayerLocation));
        }
Esempio n. 28
0
        public void TestHoldUpMarkMaxThreeItems()
        {
            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.MarkItemsRequested = true;

            // Item within reach
            for (int i = 0; i < 10; i++)
            {
                player.Items.Add(new MockItem(robot.Location));
            }

            ai.Think();

            Assert.AreEqual(RobotAiState.HeldUpDemandMarkAmmo, ai.State);
            Assert.AreEqual(3, player.Items.Count(item => ((MockItem)item).HasBeenMarkedForPlayer));
        }
Esempio n. 29
0
        public void TestHoldUpMarkThreeEnemyMaximum()
        {
            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;

            player.Robots.Add(robot);

            for (int i = 0; i < 3; i++)
            {
                player.Robots.Add(new MockRobot());
            }

            ai.Think();

            Assert.AreEqual(RobotAiState.HeldUpDemandMarkEnemies, ai.State);
            Assert.False(robot.HasBeenMarkedForPlayer);
            Assert.AreEqual(3, player.Robots.Count(r => ((MockRobot)r).HasBeenMarkedForPlayer));
        }