예제 #1
0
 public List <Cell> FindPath(List <Cell> cells, Cell destination)
 {
     if (destination.gameObject.transform.position.x >= transform.position.x)
     {
         if (PlayerNumber == 0)
         {
             transform.rotation = Quaternion.Euler(0, 0, 0);
         }
         else
         {
             transform.rotation = Quaternion.Euler(0, 0, 0);
         }
     }
     else
     {
         if (PlayerNumber == 0)
         {
             transform.rotation = Quaternion.Euler(0, 180, 0);
         }
         else //prawy gracz
         {
             transform.rotation = Quaternion.Euler(0, 180, 0);
         }
     }
     if (catchedPaths != null && catchedPaths.ContainsKey(destination))
     {
         return(catchedPaths[destination]);
     }
     else
     {
         return(_fallbackPathfinder.FindPath(GetGraphEdges(cells), Cell, destination));
     }
 }
예제 #2
0
    void GeneratePath()
    {
        ClearNodes();

        _route = _pathfinding.FindPath(startNode, endNode);

        DisplayVisitedUnVisitedNodes();

        if (_route != null)
        {
            foreach (var path in _route)
            {
                var tile = Map[(int)path.x, (int)path.y];

                ChangeColorOnObject(tile, Color.gray);
                WriteInfoOnObject(path, tile);
            }
        }



        if (endNode != null)
        {
            var endNodeObject = Map[(int)endNode.x, (int)endNode.y];
            ChangeColorOnObject(endNodeObject, Color.blue);
            WriteInfoOnObject(endNode, endNodeObject);
        }

        if (startNode != null)
        {
            var startNodeObject = Map[(int)startNode.x, (int)startNode.y];
            ChangeColorOnObject(startNodeObject, Color.green);
            WriteInfoOnObject(startNode, startNodeObject);
        }
    }
예제 #3
0
 public List <Cell> FindPath(List <Cell> cells, Cell destination)
 {
     if (cachedPaths != null && cachedPaths.ContainsKey(destination))
     {
         return(cachedPaths[destination]);
     }
     return(_fallbackPathfinder.FindPath(GetGraphEdges(cells), Cell, destination));
 }
예제 #4
0
    private void GeneratePath()
    {
        _algorithm?.Cleanup(); // cleanup algorithm's edits to node grid

        _runtime   = 0f;
        _algorithm = new AStar(_grid);
        _path      = _algorithm.FindPath(_start, _end);
        _state     = _algorithm.ChangeController;
    }
예제 #5
0
 public List <Cell> FindPath(List <Cell> cells, Cell destination)
 {
     return(_pathfinder.FindPath(GetGraphEdges(cells), Cell, destination));
 }