Time for action – adjacent squares
Add the
findAdjacentNodes()
method to the Helper Methods region of the PathFinder class:static private List<PathNode> findAdjacentNodes( PathNode currentNode, PathNode endNode) { List<PathNode> adjacentNodes = new List<PathNode>(); int X = currentNode.GridX; int Y = currentNode.GridY; bool upLeft = true; bool upRight = true; bool downLeft = true; bool downRight = true; if ((X > 0) && (!TileMap.IsWallTile(X - 1, Y))) { adjacentNodes.Add(new PathNode( currentNode, endNode, new Vector2(X - 1, Y), CostStraight + currentNode.DirectCost)); } else { upLeft = false; downLeft = false; } if ((X < 49) && (!TileMap.IsWallTile(X + 1, Y))) { adjacentNodes.Add(new PathNode( currentNode, endNode, new Vector2(X + 1, Y...