private void PathFinding() { while (true) { if (pathRequests.Count > 0) { for (int i = 0; i < pathRequests.Count; i++) { if (pathRequests[i] != null) { if (pathRequests[i].done && pathRequests[i].callbackDone) { pathRequests.Remove(pathRequests[i]); } else if (!pathRequests[i].done) { PathRequest currentPath = pathRequests[i]; currentPath.path = pathFinding.StartFindPath(instance.grid, currentPath.pathStart, currentPath.pathEnd); currentPath.done = true; } } } } //Thread.Sleep(20); } }
void TryProcessNext() { if (!isProcessingPath && pathRequestQueue.Count > 0) { currentPathRequest = pathRequestQueue.Dequeue(); isProcessingPath = true; pathfinding.StartFindPath(currentPathRequest.pathStart, currentPathRequest.pathEnd); } }
// Method for checking if we can process a new path void TryProcessNext() { if (!isProcessingPath && pathRequestQueue.Count > 0) // If not processing a path and the queue is not empty { currentPathRequest = pathRequestQueue.Dequeue(); // Take off the top item of the queue isProcessingPath = true; pathfinding.StartFindPath(currentPathRequest.pathStart, currentPathRequest.pathEnd); // Pathfinder finds path } }
private static void TryProcessNext() { if (!IsProcessingPath && PathRequestQueue.Count > 0) { CurrentPathRequest = PathRequestQueue.Dequeue(); IsProcessingPath = true; Pathfinding.StartFindPath(CurrentPathRequest.PathStart, CurrentPathRequest.PathEnd, CurrentPathRequest.Map); } }
private void tryProcessNext() { if (!isProcessingPath && prQueue.Count > 0) { currentRequest = prQueue.Dequeue(); isProcessingPath = true; pathFinding.StartFindPath(currentRequest.start, currentRequest.end); } }
void ProcessNext() { if (!IsProcessingPath && Requests.Count > 0) { currentPathRequest = Requests.Dequeue(); IsProcessingPath = true; mPathfinding.StartFindPath(currentPathRequest.mStartPos, currentPathRequest.mEndPos); } }
private void TryProcessNext() { if (!_isProcessingPath && _pathRequestsQueue.Count > 0) { _currentPathRequest = _pathRequestsQueue.Dequeue(); _isProcessingPath = true; _pathfinding.StartFindPath(_currentPathRequest.PathStart, _currentPathRequest.PathEnd); } }
// try the next porcess in the Queue void TryProcessNext() { // don't start the path if we're already processing or the queue is empty if (!isProcessingPath && pathRequestQueue.Count > 0) { currentPathRequest = pathRequestQueue.Dequeue(); isProcessingPath = true; pathfinding.StartFindPath(currentPathRequest.pathStart, currentPathRequest.pathEnd); // start the path searche } }
void Start() { gridObject = GameObject.Find("A*"); ourgrid = gridObject.GetComponent <Grid>(); //PathRequestManager.RequestPath(transform.position, target.position, OnPathFound); //Debug.Log("Have Path? " + pathHolder.GetComponent<Paths>().isPath(pathName)); if (!ourgrid.isPath(pathName)) { ourgrid.CreateGridWithOutName(Creator.name, target.name); pathfinding = GetComponent <Pathfinding>(); pathfinding.StartFindPath(transform.position, target.position); } else { path = ourgrid.getPath(pathName); StopCoroutine("FollowPath"); StartCoroutine("FollowPath"); } }