Esempio n. 1
0
    public List <ConnectionPoint> FindPath(ConnectionPoint start, ConnectionPoint end)   //TODO Zero the Cost at Start
    {
        //PREPERATION
        ConnectionPoint current = null;

        open.Clear();
        closed.Clear();
        cycleID++;
        start.resetPathfindingValues();
        open.Add(start);

        //A*
        do
        {
            //Get The Element with the Lowest Cost
            open.Sort(SortByCost);
            current = open[0];
            open.RemoveAt(0);

            //Is this the Target?
            if (current == end)
            {
                return(CalculatePath(current));
            }

            closed.Add(current);
            Expand(current);
        } while (open.Count != 0);

        return(null);
    }