Example #1
0
    //the path isnt caluculated immediatly but is done over the duration of frames
    //A method will be fed into the Action variable, but it written as an array as there will be more
    //than one vector calculated
    public static void RequestPath(Vector3 pathStart, Vector3 pathEnd, Action <Vector3[], bool> callback)
    {
        PathRequestBFS newRequest = new PathRequestBFS(pathStart, pathEnd, callback);

        instance.pathRequestQueue.Enqueue(newRequest);
        instance.TryProcessNext();
    }
Example #2
0
 //check to see if we are already processing a path, and if not then process the next path
 void TryProcessNext()
 {
     if (!isProcessingPath && pathRequestQueue.Count > 0)
     {
         //get the first item of the request
         currentPathRequest = pathRequestQueue.Dequeue();
         isProcessingPath   = true;
         pathfinding.StartFindPath(currentPathRequest.pathStart, currentPathRequest.pathEnd);
     }
 }