Exemplo n.º 1
0
 private void ExploreNeighbours(Stack <Waypoint> waypoints, Waypoint waypoint)
 {
     foreach (Vector2Int direction in directions)
     {
         Vector2Int index = waypoint.GetGridPos() + direction;
         if (grid.ContainsKey(index))
         {
             Waypoint neighbour = grid[index];
             if (neighbour.CanExplore())
             {
                 waypoints.Push(neighbour);
                 neighbour.isExplored = true;
                 neighbour.parent     = waypoint;
             }
         }
     }
 }
Exemplo n.º 2
0
 private void ExploreNeighbours(MinHeap waypoints, Waypoint waypoint)
 {
     foreach (Vector2Int direction in directions)
     {
         Vector2Int index = waypoint.GetGridPos() + direction;
         if (grid.ContainsKey(index))
         {
             Waypoint neighbour = grid[index];
             if (neighbour.CanExplore())
             {
                 neighbour.parent = waypoint;
                 Evaluate(neighbour);
                 if (pathFindAlgorithm == PathFindAlgorithm.Astar)
                 {
                     GiveWeight(neighbour);
                 }
                 waypoints.Insert(neighbour);
                 neighbour.isExplored = true;
             }
         }
     }
 }