Exemplo n.º 1
0
    public static IEnumerator CountPath(pathfinding.Pathfinding requester, Vector3 startPos, Vector3 endPos)
    {
        Node start = Grid.instance.ClosestNodeFromWorldPoint(startPos);
        Node end   = Grid.instance.ClosestNodeFromWorldPoint(endPos);

        StartThreadedFunction(() => { FindPath(start, end); });

        while (currentThread.IsAlive)
        {
            yield return(null);
        }
        readyToTakeNewPath = true;

        instance.StartCoroutine(requester.PathCountDelay());
        requester.OnPathFound(currentPath);
    }
Exemplo n.º 2
0
 public static void SearchPathRequest(pathfinding.Pathfinding requester, Vector2 startPos, Vector2 endPos, Grid grid)
 {
     if (grid.useThreading)
     {
         PathRequest request = new PathRequest(requester, startPos, endPos, grid);
         pathRequests.Add(request);
     }
     else
     {
         Node      start   = Grid.instance.ClosestNodeFromWorldPoint(startPos);
         Node      end     = Grid.instance.ClosestNodeFromWorldPoint(endPos);
         Vector2[] newPath = AStar.FindPath(start, end, Grid.instance);
         requester.OnPathFound(newPath);
         instance.StartCoroutine(requester.PathCountDelay());
     }
 }