Graphics Reference
In-Depth Information
{
SetAIState( AIState.stopped_turning_
left );
} else {
SetAIState( AIState.stopped_turning_
right );
}
}
break;
Functions for turning left and right, TurnLeft() and TurnRight(), respectively, are
used by the cases for AIState.stopped_turning_left and AIState.stopped_turning_right.
The two cases also check obstacleFinderResult to see whether the path ahead is clear. If the
path is clear (when obstacleFinderResult contains zero), the state is changed to AIState.
moving_looking_for_target:
case AIState.stopped_turning_left:
// look for chase target
if( followTarget!=null )
LookAroundFor( followTarget );
// stopped, turning left
TurnLeft();
if( obstacleFinderResult==0 )
{
SetAIState( AIState.moving_looking_for_target );
}
break;
case AIState.stopped_turning_right:
// look for chase target
if( followTarget!=null )
LookAroundFor( followTarget );
// stopped, turning right
TurnRight ();
// check results from looking, to see if path ahead
// is clear
if( obstacleFinderResult==0 )
{
SetAIState( AIState.moving_looking_for_target );
}
break;
The AIState.paused_looking_for_target state does a check to make sure that fol-
low Target is not null and then makes a call out to the LookAroundFor() function to see
whether the target is within range to chase. This code contains no movement code, and
when the bot is in this state, it should just stand still and wait for the player to get close, as
though it were standing guard:
case AIState.paused_looking_for_target:
// standing still, while looking for chase target
// look for chase target
Search WWH ::




Custom Search