예제 #1
0
    public bool run()
    {
        for (int j = 0; j < 3 * creator.roadSize && open.Count != 0; j++)
        {
            RoadNode node = (RoadNode)open.GetByIndex(0);

            if (isEnd(node))
            {
                creator.closePath(node.pathUntilNow, creator.lastChunk, creator.lastRotY, 0);

                Debug.Log("Hay solución");
                removeFinderChunks();
                return(true);
            }
            else
            {
                open.RemoveAt(0);
                if (node.isValid())
                {
                    RoadNode[] children = node.children();
                    for (int i = 0; i < children.Length; i++)
                    {
                        children[i].mountPoint.name = "Astar-" + expanded;
                        open.Add(children[i], children[i]);
                        expanded++;
                    }
                }
            }
        }

        if (open.Count == 0)
        {
            removeFinderChunks();
            Debug.Log("No hay solución");
            return(false);
        }
        removeFinderChunks();
        Debug.Log("No hay solución 2");
        return(false);
    }