public void ShowOptimalPath(Vector3 playerPosition)
    {
        AStar aStar = new AStar(data);

        aStar.CreatePath(data, (int)playerPosition.x, (int)playerPosition.y, xExit, yExit);
        if (optimalPath.transform.childCount > 0)
        {
            foreach (Transform child in optimalPath.transform)
            {
                Destroy(child.gameObject);
            }
        }
        for (int i = 0; i < aStar.optimalPath.Count; i++)
        {
            Instantiate(path, new Vector3(aStar.optimalPath[i].x + 0.5f, aStar.optimalPath[i].y + 0.5f, 1), Quaternion.identity, optimalPath.transform);
        }
    }
Esempio n. 2
0
 public List <Spot> GetPath(Vector2Int start, Vector2Int end, int length)
 {
     return(aStar.CreatePath(spots, start, end, length));
 }
 public List <Vector3> GetPath(Vector3 start, Vector3 end, int length)
 {
     return(aStar.CreatePath(aStarPositions, start, end, length));
 }