Closest() 공개 정적인 메소드

public static Closest ( List inNodes, Vector3 toPoint ) : int
inNodes List
toPoint Vector3
리턴 int
예제 #1
0
    public void WaypointSystemChangedCallback()
    {
        WaypointManager wg         = GameObject.Find("WaypointManager").GetComponent <WaypointManager>();
        var             sources    = wg.pathNodes;
        int             startIndex = -1;
        int             endIndex   = -1;

        if (actualStartNode == null || !actualStartNode.nodeValid)
        {
            startIndex      = PathfindingManager.Closest(sources, startNodePosition);
            actualStartNode = sources[startIndex];
        }
        if (actualTargetNode == null || !actualTargetNode.nodeValid)
        {
            endIndex         = PathfindingManager.Closest(sources, endNodePosition);
            actualTargetNode = sources[endIndex];
        }

        bool found = false;

        if (path != null)
        {
            //foreach (PathNode pn in path)
            for (int i = 0; i < path.Count; i++)
            {
                PathNode pn = path[i];

                if (pn == null || !pn.nodeEnabled || !pn.nodeValid)
                {
                    found = true;
                    break;
                }
            }
            if (found)
            {
                path.Clear();
            }
        }
    }