Was going to respond to Michael Flores post because his solution was similar to the one I came up with for this challenge.
Unless it’s needed for something else in a later lecture, what is the purpose of using the dictionary in ExploreNeighbors(), when we have already created a GetNode() method that checks to see if the coordinates are within the dictionary bounds? It returns null if it gets coordinates for which it doesn’t have a key, so it seems much simpler to just check if GetNode() returned a node or a null.
My method ended up looking like:
void ExploreNeighbors()
{
List<Node> neighbors = new List<Node>();
foreach (Vector2Int direction in directions)
{
Vector2Int neighborCoord = currentSearchNode.coordinates + direction;
Node neighbor = gridManager.GetNode(neighborCoord);
if (neighbor != null)
{
neighbors.Add(neighbor);
//TODO Remove after testing
neighbor.isExplored = true;
Node currentNode = gridManager.GetNode(currentSearchNode.coordinates);
currentNode.isPath = true;
}
}
}
That seems to work, because my nodes are being colored correctly.