Example #1
0
    private void CalculatePath(NodeComponent start, NodeComponent currentNode)
    {
        //Traversing the path from goal to start
        List <Connection> connections = new List <Connection>();

        while (currentNode != start)
        {
            currentNode.MarkAsPath();
            connections.Add(currentNode.NodeInfo.connection);
            currentNode = currentNode.NodeInfo.connection.From;
        }
        currentNode.MarkAsPath();
        //Reversing the path
        connections.Reverse();
        path = connections.ToArray();
    }