Exemplo n.º 1
0
        protected override void HandleFrameUpdate(float elapsedTime)
        {
            base.HandleFrameUpdate(elapsedTime);

            // Check if we can see the player
            if (IsPlayerVisible())
            {
                // The player is visible.  Start persuit of the player
                var persuit = new AIStatePersuit(controller);
                stateMachine.MoveTo(persuit);
                return;
            }

            // Check if we are near the last sighting position;
            if (controller.Agent.remainingDistance < controller.destinationArriveProximity)
            {
                // We have reached the last sighting position and still haven't found the player
                // Stand here and wait for a bit before returing to patrolling
                var waitAndSearch = new AIStateWaitAndSearch(controller);
                stateMachine.MoveTo(waitAndSearch);
            }
        }
		protected override void HandleFrameUpdate (float elapsedTime)
		{
			base.HandleFrameUpdate(elapsedTime);

			// Check if we can see the player
			if (IsPlayerVisible()) {
				// The player is visible.  Start persuit of the player
				var persuit = new AIStatePersuit(controller);
				stateMachine.MoveTo(persuit);
	            return;
	        }

			// Check if we are near the last sighting position;
			if (controller.Agent.GetRemainingDistance() < controller.destinationArriveProximity) {
				// We have reached the last sighting position and still haven't found the player
				// Stand here and wait for a bit before returing to patrolling
				var waitAndSearch = new AIStateWaitAndSearch(controller);
				stateMachine.MoveTo(waitAndSearch);
			}
	    }