Esempio n. 1
0
        //Loops through nodes to find node with shortest distance to passed position
        public Node CalculateClosestNode(Vec2 objectPos)
        {
            Node  retVal   = null;
            float distance = float.MaxValue;

            for (int i = 0; i < availableNodes.Count; i++)
            {
                float nodeDist = objectPos.DistanceSqr(availableNodes[i].position);
                if (distance > nodeDist)
                {
                    distance = nodeDist;
                    retVal   = availableNodes[i];
                }
            }

            return(retVal);
        }