Exemple #1
0
            public static NavigationResult GetPath(IMapData Map, Vector3 StartPosition, Vector3 GoalPosition, Number Radius)
            {
                INode goalNode  = Map.GetNode(GoalPosition);
                INode startNode = Map.GetNode(StartPosition);

                NavigationResult.Types type = NavigationResult.Types.Complete;

                if (goalNode == null || (goalNode.State != NodeStates.Walkable && goalNode != startNode))
                {
                    goalNode = Map.GetNearestNode(GoalPosition, Radius, NodeStates.Walkable);
                    type     = NavigationResult.Types.Partial;
                }

                Vector3[] path = CalculatePath(Map, startNode, goalNode);

                if (path == null)
                {
                    return(null);
                }

                return(new NavigationResult(path, type));
            }