Time for action – finding the path
Add the
FindPath()
method to thePathFinder
module:#Region "Public Methods" Public Function FindPath( startSquare As Vector2, endSquare As Vector2) As List(Of Vector2) If TileMap.IsWallTile(endSquare) Or TileMap.IsWallTile(startSquare) Then Return Nothing End If openList.Clear() costTracker.Clear() statusTracker.Clear() Dim startNode As PathNode Dim endNode As PathNode endNode = new PathNode(Nothing, Nothing, endSquare, 0) startNode = new PathNode(Nothing, endNode, startSquare, 0) addNodeToOpenList(startNode) Do While openList.Count > 0 Dim currentNode As PathNode = openList(openList.Count - 1) If currentNode.IsEqualToNode(endNode) Then Dim bestPath As List(Of Vector2) = New List(Of Vector2)() Do While Not IsNothing(currentNode) bestPath.Insert(0, currentNode.GridLocation) currentNode = currentNode.ParentNode...