예제 #1
0
    // Start is called before the first frame update
    public void StartNewPatrol(PatrolRoute route, int unitAP)
    {
        isPatroling  = true;
        patrolPoints = route.GetPatrolPositions();
        //From their current position, they need to find the closest waypoint.
        //Get its index, that is the first destination point.
        nextPatrolPointIndex = FindClosestPatrolPointIndex();
        curDestination       = patrolPoints[nextPatrolPointIndex];

        //patrol has been initiated. Unit needs to being loop of moving to next waypoint.
        //If  not at a waypoint, get path to next waypoint from pathfinder.If path is longer than AP, means wont get there, Truncate path to the end of available AP. Get it cleaned up by path requester. Tell nav agent to move there up to its move speed. End turn
        //If not at a waypoint, get path to next waypoint ... if path is =to or less than available AP, means you will arrive there this turn. clean up path, tell nav agent to move. Set Destination reached flag to true.
        //If destination reached flag is true, Set destination to next waypoint. Get path, get it cleaned up, tell nav agent to move up to its move speed.
        ContinuePatrol(unitAP);
    }