Пример #1
0
	void TryProcessNext() {
		if (!_ProcessingPath && pathRequestQueue.Count > 0) {
			currentPathRequest = pathRequestQueue.Dequeue();
			_ProcessingPath = true;
			pathfinding.StartFindPath(currentPathRequest.pathStart, currentPathRequest.pathEnd);
		}
	}
    public static void RequestPath(GridNode pathStart, GridNode pathEnd, List<List<GridNode>> pathGrid, Action<GridNode[], bool> callback)
    {
        PathRequest newRequest = new PathRequest(pathStart, pathEnd, pathGrid, callback);

        Instance.pathRequestQueue.Enqueue(newRequest);
        Instance.TryProcessNext();
    }
Пример #3
0
    /* Requested Path from Agents; Action<> store completePaths & call them back hen asked for */
    public static void RequestPath(Vector3 startPath, Vector3 endPath, Action<Vector3[], bool> callback) {
        PathRequest newPathRequest = new PathRequest(startPath, endPath, callback); 

        //Store Path in Queue class context
        managerContext.pathRequestQueue.Enqueue(newPathRequest);
        managerContext.TryNextProcess();
    }
Пример #4
0
	void TryProcessNext(){
		if(!isProcessingPath & pathRequestQueue.Count > 0){
			currentPathRequest = pathRequestQueue[pathRequestQueue.Count - 1];
			pathRequestQueue.RemoveAt(pathRequestQueue.Count - 1);
			isProcessingPath = true;
			//pathFinding.StartFindPath(currentPathRequest.pathStart,currentPathRequest.pathEnd);
		}
	}
Пример #5
0
    public static void RequestPath(Vector3 PathStart, Vector3 PathEnd, Action <Vector3[], bool> CallBack)
    {
        PathRequest newRequest = new PathRequest(PathStart, PathEnd, CallBack);

        Instance.pathRequestQueue.Enqueue(newRequest);

        Instance.TryProcessNext();
    }
Пример #6
0
    public static void RequestPath(PathRequest request)
    {
        ThreadStart threadStart = delegate {
            instance.pathfinding.FindPath(request, instance.FinishedProcessingPath);
        };

        threadStart.Invoke();
    }
    public static void RequestPath(Vector3 pathStart, Vector3 pathEnd, Action <Vector3[], bool> callback)
    {
        PathRequest newRequest = new PathRequest(pathStart, pathEnd, callback);

        //Debug.Log("path request" + instance);
        instance.pathRequestQueue.Enqueue(newRequest);
        instance.TryProcessNext();
    }
Пример #8
0
 public void RequestPath(PathRequest request)
 {
     if (!graphs.ContainsKey(request.unitSize))
     {
         CreateGraph(request.unitSize);
     }
     request.seeker.StartPath(request.start, request.goal, request.callback, GraphMask.FromGraph(graphs[request.unitSize]));
 }
Пример #9
0
    // The action (callback) stores the method that Receives Path in unit so this Manager can call it once it has calculated that unit's path
    public static void RequestPath(Vector3 pathStart, Vector3 pathEnd, GameObject requesterObj, Action <Vector3[], bool> callback)
    {
        PathRequest newRequest = new PathRequest(pathStart, pathEnd, callback, requesterObj);

        Instance.pathRequestQueue.Enqueue(newRequest);
        //print("Path request " + (Instance.pathRequestQueue.Count) + " added.");
        Instance.TryProcessNext();
    }
Пример #10
0
 /// <summary>
 /// Requests a path from the manager and adds it to the queue
 /// </summary>
 /// <param name="pathStart">Path start.</param>
 /// <param name="pathEnd">Path end.</param>
 /// <param name="callback">Callback.</param>
 /// <param name="pathType">Path type.</param>
 /// <param name="lineOfSight">If set to <c>true</c> line of sight.</param>
 /// <param name="id">Identifier to make sure that correct thread grabs it path</param>
 public static void RequestPath(Vector3 pathStart, Vector3 pathEnd, Action<Vector3[], bool> callback, string pathType, bool lineOfSight, int id)
 {
     PathRequest newRequest = new PathRequest(pathStart,pathEnd,callback, pathType, lineOfSight, id);
     enemysInQueue.Add(id);
     instance.pathRequestQueue.Enqueue(newRequest);
     newRequest.sw = Stopwatch.StartNew();
     instance.TryProcessNext();
 }
Пример #11
0
    // The action (callback) stores the method that Receives Path in unit so this Manager can call it once it has calculated that unit's path
    public static void RequestPath(Vector3 pathStart, Vector3 pathEnd, GameObject requesterObj, Action<Vector3[], bool> callback)
    {
        PathRequest newRequest = new PathRequest(pathStart, pathEnd, callback, requesterObj);

        Instance.pathRequestQueue.Enqueue(newRequest);
        //print("Path request " + (Instance.pathRequestQueue.Count) + " added.");
        Instance.TryProcessNext();
    }
Пример #12
0
    public static void RequestPath(PathRequest request)
    {
        ThreadStart threadStart = delegate {
            GameManager.Instance.GridObj.FindPath(request, instance.FinishedProcessingPath);
        };

        threadStart.Invoke();
    }
 private void TryProcessNext()
 {
     if (!this.isProcessingPath && this.pathRequestQueue.Count > 0) {
         this.currentPathRequest = this.pathRequestQueue.Dequeue();
         this.isProcessingPath = true;
         this.pathfinding.StartFindPath(this.currentPathRequest.pathStart, this.currentPathRequest.pathEnd, this.currentPathRequest.bound);
     }
 }
Пример #14
0
    public static void requestPath(PathRequest request)
    {
        ThreadStart threadStart = delegate {
            manager.pathFinder.FindPath(request, manager.finishedPathFinding);
        };

        threadStart.Invoke();
    }
Пример #15
0
	public static void RequestPath(Vector3 pathStart, Vector3 pathEnd, Action<Vector3[], bool> callback, bool flyable){
		PathRequest newRequest = new PathRequest (pathStart, pathEnd, callback);
		if (instance != null) {
			instance.amIFlyable = flyable;
			instance.pathRequestQueue.Enqueue (newRequest);
			instance.TryProcessNext ();
		}
	}
 void TryProcessNext()
 {
     if (!isProcessingPath && pathRequestQueue.Count > 0){
         currentPathRequest = pathRequestQueue.Dequeue(); // get first item in queue and takes it out
         isProcessingPath = true;
         pathfinding.StartFindPath(currentPathRequest.pathStart, currentPathRequest.pathEnd);
     }
 }
Пример #17
0
    public void FindPath(PathRequest request, Action <PathResult> callback)
    {
        Vector3[] waypoints   = new Vector3[0];
        bool      pathSuccess = false;

        Node startNode  = grid.NodeFromWorldPoint(request.pathStart);
        Node targetNode = grid.NodeFromWorldPoint(request.pathEnd);

        if (startNode.walkable && targetNode.walkable)
        {
            Heap <Node>    openSet   = new Heap <Node>(grid.MaxSize);
            HashSet <Node> closedSet = new HashSet <Node>();
            openSet.Add(startNode);

            while (openSet.Count > 0)
            {
                Node currentNode = openSet.RemoveFirst();
                closedSet.Add(currentNode);

                if (currentNode == targetNode)
                {
                    pathSuccess = true;
                    break;
                }

                foreach (Node neighbour in grid.GetNeighbours(currentNode))
                {
                    if (!neighbour.walkable || closedSet.Contains(neighbour))
                    {
                        continue;
                    }

                    int newMovementCostToNeighbour = currentNode.gCost + GetDistance(currentNode, neighbour) + neighbour.movementPenalty;
                    if (newMovementCostToNeighbour < neighbour.gCost || !openSet.Contains(neighbour))
                    {
                        neighbour.gCost  = newMovementCostToNeighbour;
                        neighbour.hCost  = GetDistance(neighbour, targetNode);
                        neighbour.parent = currentNode;

                        if (!openSet.Contains(neighbour))
                        {
                            openSet.Add(neighbour);
                        }
                        else
                        {
                            openSet.UpdateItem(neighbour);
                        }
                    }
                }
            }
        }
        if (pathSuccess)
        {
            waypoints   = backtrack(startNode, targetNode);
            pathSuccess = waypoints.Length > 0;
        }
        callback(new PathResult(waypoints, pathSuccess, request.callback));
    }
Пример #18
0
    public void FindPath(PathRequest request, Action <PathResult> callback)
    {
        Vector3[] waypoints   = new Vector3[0];
        bool      pathSuccess = false;

        Node startNode  = grid.NodeFromWorldPoint(request.pathStart);
        Node targetNode = grid.NodeFromWorldPoint(request.pathEnd);

        startNode.parent = startNode;         // NEW!!!!!

        //if (startNode == null || targetNode == null) Debug.LogWarning("Node does not exist");

        Heap <Node>    openSet   = new Heap <Node>(grid.MaxSize); // Set to be evaluated
        HashSet <Node> closedSet = new HashSet <Node>();          // Set already evaluated

        openSet.Add(startNode);

        while (openSet.Count > 0)
        {
            Node current = openSet.RemoveFirst();
            closedSet.Add(current);
            if (current == targetNode)
            {
                pathSuccess = true;
                break;                 // We finish
            }
            List <Node> neighbours = grid.GetNeighbours(current);
            foreach (Node neighbour in neighbours)
            {
                if (closedSet.Contains(neighbour))
                {
                    continue;
                }
                // If new path to neighbour is shorter OR neighbour not in openSet
                int newDist = current.gCost + GetDistance(current, neighbour);
                if (newDist < neighbour.gCost || !openSet.Contains(neighbour))
                {
                    neighbour.gCost  = newDist;
                    neighbour.hCost  = GetDistance(neighbour, targetNode);
                    neighbour.parent = current;
                    if (!openSet.Contains(neighbour))
                    {
                        openSet.Add(neighbour);
                    }
                    else
                    {
                        openSet.UpdateItem(neighbour);                      // NEW!!!!!
                    }
                }
            }
        }
        if (pathSuccess)
        {
            waypoints   = RetracePath(startNode, targetNode);
            pathSuccess = waypoints.Length > 0;
        }
        callback(new PathResult(waypoints, pathSuccess, request.callback));
    }
Пример #19
0
 private void TryProcessNext()
 {
     if (!this.isProcessingPath && this.pathRequestQueue.Count > 0)
     {
         this.currentPathRequest = this.pathRequestQueue.Dequeue();
         this.isProcessingPath   = true;
         this.pathfinding.StartFindPath(this.currentPathRequest);
     }
 }
Пример #20
0
    //Starts the threading process (Lague, 2017)
    public static void RequestPath(PathRequest pathRequest)
    {
        ThreadStart threadStart = delegate
        {
            PThreader.pathfinding.DrawPath(pathRequest, PThreader.Finished);
        };

        threadStart.Invoke();
    }
Пример #21
0
 //After done with pathfinding for one in the queue, do the next one
 private void TryProcessNext()
 {
     if (!m_isProcessingPath && m_requestQueue.Count > 0)
     {
         m_currentProcess   = m_requestQueue.Dequeue();
         m_isProcessingPath = true;
         m_pathFinder.StartFindPath(m_currentProcess.StartPos, m_currentProcess.EndPos);
     }
 }
Пример #22
0
    // Need to call this every set number of frames (expensive calculation if done per frame)
    public static void RequestPath(Vector3 start, Vector3 end, Action <Vector3[], bool> callback)
    {
        // Create a new path request
        PathRequest request = new PathRequest(start, end, callback);

        // Add the request into the request queue
        instance.pathRequestQueue.Enqueue(request);
        instance.TryProcessNext();
    }
Пример #23
0
 void TryProcessNext()
 {
     if (!isProcessingPath && pathRequestQueue.Count > 0)                                     //If a path is not being processed and the queue is not empty...
     {
         currentPathRequest = pathRequestQueue.Dequeue();                                     //Take the path request out of the queue
         isProcessingPath   = true;                                                           //A path is now being processed
         pathfinding.StartFindPath(currentPathRequest.pathStart, currentPathRequest.pathEnd); //Call the method that starts to find a path
     }
 }
Пример #24
0
 void ProcessNext()
 {
     if(!processing && PathQueue.Count > 0)
     {
         currentPath = PathQueue.Dequeue();
         processing = true;
         myAlgorithm.StartFindPath(currentPath.start, currentPath.end, currentPath.distanceType, currentPath.simplified);
     }
 }
Пример #25
0
 void TryProcessNext()
 {
     if (!isProcessingPath && pathRequestQueue.Count > 0)
     {
         currentPathRequest = pathRequestQueue.Dequeue();
         isProcessingPath = true;
         pathfinding.StartFindPath(currentPathRequest.pathStart, currentPathRequest.pathEnd,currentPathRequest.unwalkable,currentPathRequest.dynamicException);
     }
 }
Пример #26
0
 private void TryProcessNext()
 {
     if (!isProcessingPath && pathRequestQueue.Count > 0)
     {
         currentPathRequest = pathRequestQueue.Dequeue();
         isProcessingPath   = true;
         pathfinding.StartFindPath(currentPathRequest.pathStart, currentPathRequest.pathEnd);
     }
 }
Пример #27
0
 void ProcessNext()
 {
     if (!processing && PathQueue.Count > 0)
     {
         currentPath = PathQueue.Dequeue();
         processing  = true;
         myAlgorithm.StartFindPath(currentPath.start, currentPath.end, currentPath.distanceType, currentPath.simplified);
     }
 }
 void TryFindNextPath()
 {
     if (!m_IsSearchingForPath && m_PathRequestQueue.Count > 0)
     {
         m_CurrentRequest     = m_PathRequestQueue.Dequeue();
         m_IsSearchingForPath = true;
         m_Pathfinding.StartFindPath(m_CurrentRequest.m_StartPos, m_CurrentRequest.m_EndPos);
     }
 }
Пример #29
0
 /* Process another Path available */
 void TryNextProcess() {
     
     //When not processing anything, get the 1st path in the queue
     if(!isProcessingPath && pathRequestQueue.Count > 0) { 
        pathRequest = pathRequestQueue.Dequeue();
        isProcessingPath = true;
        targetFinder.StartFindPath(pathRequest.startPath, pathRequest.endPath);
     }
 }
Пример #30
0
 void TryProcessNext()
 {
     if (!isProcessingPath && pathRequestQueue.Count > 0)
     {
         currentPathRequest = pathRequestQueue.Dequeue();    // zwraca pierwszy element z kolejki i usuwa go z niej
         isProcessingPath   = true;
         pathFinding.StartFindPath(currentPathRequest.pathStart, currentPathRequest.pathEnd);
     }
 }
Пример #31
0
    //Action will hold a method contained in the caller. will be called after map data found.
    public static void RequestPath(Vector3 pathStart, Vector3 pathEnd, Action <Vector3 [], bool> callback)
    {
        //create a new PathRequest using all the data passed to the script.
        PathRequest newRequest = new PathRequest(pathStart, pathEnd, callback);

        //add this new PathRequest to the que.
        instance.pathRequestQue.Enqueue(newRequest);
        instance.TryProcessNext();
    }
Пример #32
0
 //Try to process the next path request.
 void TryProcessNext()
 {
     if (!isProcessingPath && pathRequestQueue.Count > 0)                                      //If there is not already a path being processed and the queue isn't empty.
     {
         currentPathRequest = pathRequestQueue.Dequeue();                                      //Dequeue the path request.
         isProcessingPath   = true;                                                            //We are now processing the path.
         pathfinding.StartFindPath(currentPathRequest.pathStart, currentPathRequest.pathEnd);  //Execute StartFindPath in the pathfinder class and pass in the values we got.
     }
 }
Пример #33
0
 public PathFinderA2(PathRequest r)
 {
     //Debug.Log(nodesAreOK(getNodesFromLocation(r.start.position)));
     start = r.start;
     goal  = r.end;
     size  = r.requestee.size;
     code  = r.requestee.occCode;
     startThread();
 }
Пример #34
0
 //see if currently processing a path, if not move to next one
 void TryProcessNext()
 {
     if (!isProcessingPath && pathRequestQueue.Count > 0)
     {
         currentPathRequest = pathRequestQueue.Dequeue();                    //first item in queue and takes it out
         isProcessingPath   = true;
         pathfinding.StartFindPath(currentPathRequest.pathStart, currentPathRequest.pathEnd);
     }
 }
Пример #35
0
 private void TryProcessNextPath()
 {
     if (!isProcessingPath && pathRequestQueue.Count > 0)
     {
         currentPathRequest = pathRequestQueue.Dequeue();
         isProcessingPath   = true;
         pathfinder.StartFindPathCoroutine(currentPathRequest.start, currentPathRequest.end);
     }
 }
 private void TryProcessNext()
 {
     if (!bProcessingPath && PathReuqestQueue.Count > 0)
     {
         currentPathRequest = PathReuqestQueue.Dequeue();
         bProcessingPath    = true;
         pathFinding.StartFindPath(currentPathRequest.PathStart, currentPathRequest.PathEnd);
     }
 }
Пример #37
0
 void TryProcessNext()
 {
     if (!IsProcessingPath && PathRequestQueue.Count > 0)
     {
         CurrentPathRequest = PathRequestQueue.Dequeue();
         IsProcessingPath = true;
         PathFinder.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
     }
 }
 void TryProcessNext()
 {
     if (!isProcessing && pathRequestQueue.Count > 0)
     {
         currentPathRequest = pathRequestQueue.Dequeue();
         isProcessing = true;
         pathFinder.StartFindPath(currentPathRequest.pathStart, currentPathRequest.pathEnd, currentPathRequest.pathGrid);
     }
 }
Пример #40
0
 /// <summary>
 /// Try next process.
 /// </summary>
 private void TryProcessNext()
 {
     if (!mIsProcessingPath && mPathRequestQueue.Count > 0)
     {
         mCurrentPathRequest = mPathRequestQueue.Dequeue();
         mIsProcessingPath   = true;
         mPathfinding.StartFindPath(mCurrentPathRequest.pathStart, mCurrentPathRequest.pathEnd);
     }
 }
 private void TryProcessNext()
 {
     if (!IsProcessingPath && PathRequestQueue.Count > 0)
     {
         CurrentPathRequest = PathRequestQueue.Dequeue();
         IsProcessingPath   = true;
         Pathfinding.StartFindPath(CurrentPathRequest.PathStart, CurrentPathRequest.PathEnd);
     }
 }
Пример #42
0
 void TryNext()
 {
     if (!processingPath && pathQueue.Count > 0)
     {
         processingPath     = true;
         currentPathRequest = pathQueue.Dequeue();
         pathfinder.StartFindingPath(currentPathRequest.pathStart, currentPathRequest.pathEnd);
     }
 }
 private void TryProcessNext()
 {
     if (!_isProcessingPath && _pathRequestQueue.Count > 0)
     {
         _currentPathRequest = _pathRequestQueue.Dequeue();
         _isProcessingPath   = true;
         _pathFinding.StartFindPath(_currentPathRequest.pathStart, _currentPathRequest.pathEnd);
     }
 }
Пример #44
0
    //TODO Maybe limit the concurrent requests to cpucores - 1
    public static void RequestPath(PathRequest request)
    {
        ThreadStart threadStart = delegate {
            Instance.pathfinding.FindPath(request, Instance.FinishedProcessingPath);
        };
        Thread thread = new Thread(threadStart);

        thread.Start();
    }
Пример #45
0
 void TryProcessNext()
 {
     // check if we are currently processing a path, if we are NOT it tells us we can process the next one
     if (!isProcessingPath && pathRequestQueue.Count > 0)
     {
         currPathRequest = pathRequestQueue.Dequeue();
         isProcessingPath = true;
         pathfinding.StartFindPath(currPathRequest.pathStart, currPathRequest.pathEnd);
     }
 }
Пример #46
0
 /// <summary>
 /// Try to processNext requesti in the quee
 /// </summary>
 void TryProcessNext()
 {
     // If not processing a path and que is not empty
     if(!isProcessingPath && pathRequestQueue.Count > 0)
     {
         currentPathRequest = pathRequestQueue.Dequeue(); // takes first item out of the queue
         isProcessingPath = true;
         pathfinding.StartFindPath(currentPathRequest.pathStart, currentPathRequest.pathEnd);
     }
 }
Пример #47
0
 void TryProcessNext()
 {
     if (!isProcessingPath && pathRequestQueue.Count > 0)
     {
         currentPathRequest = pathRequestQueue.Dequeue();
         isProcessingPath = true;
         pathfinding.StartFindPath(currentPathRequest.pathStart, currentPathRequest.pathEnd);
         Debug.Log("Current Path ID: " + CurrentPathID);
     }
 }
		void TryProcessNext()
		{
			//Debug.Log("TryProcessNext called");
			if(!isProcessingPath && pathRequestQueue.Count > 0)
			{
				
				currentPathRequest = pathRequestQueue.Dequeue();
				isProcessingPath = true;
				//Debug.Log("calling start find path");
				pathfinding.StartFindPath(currentPathRequest.pathStart, currentPathRequest.pathEnd);
			}
		}
Пример #49
0
 /// <summary>
 /// Process the next pathRequest in-line.
 /// </summary>
 private void Process()
 {
     if (currentPathRequest == null && pathRequests.Count > 0)
     {
         currentPathRequest = pathRequests.Dequeue();
         StartCoroutine(FindThePath(currentPathRequest.pathStart, currentPathRequest.pathEnd, currentPathRequest.grid));
     }
 }
Пример #50
0
 /// <summary>
 /// Called when the processing of the current path is done.
 /// </summary>
 /// <param name="p">The path that has been worked on.</param>
 /// <param name="Success">Whether it was a success or not.</param>
 private void OnProccesingDone(Path p, bool Success)
 {
     p.Success = Success;
     p.Update(); //Only smooth if the grid is a plane.
     if (p.Vector3Path.Length == 0)
     {
         p.Success = false;
     }
     if (currentPathRequest != null)
     {
         currentPathRequest.callback(p);
         currentPathRequest = null;
     }
     Process();
 }
 public static void RequestPath(Vector3 pathStart, Vector3 pathEnd, Action<Vector3[],bool> callback)
 {
     PathRequest newRequest = new PathRequest (pathStart, pathEnd, callback);
     instance.pathRequestQueue.Enqueue (newRequest);
     instance.TryProcessNext ();
 }
 public static void RequestPath(Node pathStart, Node pathEnd, Action<Stack<Node>, bool> callBack)
 {
     PathRequest newRequest = new PathRequest(pathStart, pathEnd, callBack);
     instance.pathRequestQueue.Enqueue(newRequest);
     instance.TryProcessNext();
 }
Пример #53
0
 /// <summary>
 /// Request a path from point pathStart to point pathEnd, in a specific grid.
 /// </summary>
 /// <param name="pathStart">The starting point of the path</param>
 /// <param name="pathEnd">The ending point of the path</param>
 /// <param name="callback">A function with the parameters (Path)</param>
 /// <param name="grid">The specific grid you want to find the path on.</param>
 public static void RequestPath(Vector3 pathStart, Vector3 pathEnd, Action<Path> callback, GridGraph grid = null)
 {
     if (grid == null)
     {
         grid = Grid;
     }
     if (grid.Scanning)
     {
         return;
     }
     string Name = callback.GetHashCode().ToString();
     PathRequest newRequest = new PathRequest(pathStart, pathEnd, callback, Name, grid);
     PathRequest contains = instance.pathRequests.Contains(Name);
     if (contains != null)
     {
         instance.pathRequests.Remove(contains);
     }
     instance.pathRequests.Enqueue(newRequest);
     instance.Process();
 }
 private void OnRequestCompleted(PathRequest request, bool bSucceeded)
 {
     if (bSucceeded)
     {
         OnRequestSucceeded(request);
     }
     else
     {
         OnRequestFailed(request);
     }
 }
 public static void RequestPath(Vector3 pathStart, Vector3 pathEnd, BBCoordinate bound, Action<Vector3[], bool> callback)
 {
     PathRequest newRequest = new PathRequest(pathStart, pathEnd, bound, callback);
     BBPathRequestController.instance.pathRequestQueue.Enqueue(newRequest);
     BBPathRequestController.instance.TryProcessNext();
 }
Пример #56
0
    private void OnProccesingDone(Path p, bool Success)
    {
        p.Success = Success;
        p.Update();
        if (p.Vector3Path.Length == 0)
        {
            p.Success = false;
        }

        currentPathRequest.callback(p);
        currentPathRequest = null;
    }
    private void OnRequestFailed(PathRequest request)
    {
		request.Agent.OnPathAgentRequestFailed();
    }
Пример #58
0
 public static void RequestPath(Vector3 _start, Vector3 _end, DistanceHeuristic _distanceType, bool _simplifiedPath, Action<Vector3[], bool> callback)
 {
     PathRequest newRequest = new PathRequest(_start, _end, _distanceType, _simplifiedPath, callback);
     instance.PathQueue.Enqueue(newRequest);
     instance.ProcessNext();
 }
    private void OnRequestSucceeded(PathRequest request)
    {
        // Hold on to this request until it gets consumed.
        System.Diagnostics.Debug.Assert(!m_completedRequests.Contains(request));
        m_completedRequests.AddFirst(request);
		
		request.Agent.OnPathAgentRequestSucceeded(request);
    }
Пример #60
0
    private IEnumerator ScanA(GridGraph grid)
    {
        grid.Scanning = true;
        Vector3 Size = grid.Size;
        if (grid.gridType == GridGraph.GridType.Plane)
        {
            for (int x = 0; x < Size.x; x++)
            {
                for (int y = 0; y < Size.y; y++)
                {
                    grid.ScanNode(x, y);
                }
                if (x % 25 == 0)
                {
                    yield return null;
                }
            }
        }
        else if (grid.gridType == GridGraph.GridType.Sphere)
        {
            //-Z
            for (int y = 0; y <= Size.x; y++)
            {
                for (int x = 0; x <= Size.x; x++)
                {
                    grid.ScanNode(x, y, 0, 0);
                }

                //+X
                for (int z = 0; z <= Size.x; z++)
                {
                    grid.ScanNode(Mathf.RoundToInt(Size.x), y, z, 1);
                }

                //+Z
                for (int x = Mathf.RoundToInt(Size.x); x >= 0; x--)
                {
                    grid.ScanNode(x, y, Mathf.RoundToInt(Size.x), 2);
                }

                //-X
                for (int z = Mathf.RoundToInt(Size.x); z >= 0; z--)
                {
                    grid.ScanNode(0, y, z, 3);
                }
            }
            //+Y
            for (int z = 0; z <= Size.x; z++)
            {
                for (int x = 0; x <= Size.x; x++)
                {
                    grid.ScanNode(x, Mathf.RoundToInt(Size.x), z, 4);
                }
            }
            //-Y
            for (int z = 0; z <= Size.x; z++)
            {
                for (int x = 0; x <= Size.x; x++)
                {
                    grid.ScanNode(x, 0, z, 5);
                }
            }
        }
        grid.OnScanDone();
        pathRequests = new queue();
        currentPathRequest = null;
        grid.Scanning = false;
    }