Beispiel #1
0
            private static INode GetNode(IMapData Map, INode Node, int X, int Z)
            {
                if (X != 0)
                {
                    Node = Map.GetNode(Node.Position, X, Directions.East);
                    if (Node == null)
                    {
                        return(null);
                    }
                }

                if (Z != 0)
                {
                    Node = Map.GetNode(Node.Position, Z, Directions.North);
                    if (Node == null)
                    {
                        return(null);
                    }
                }

                return(Node);
            }
Beispiel #2
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));
            }
Beispiel #3
0
            private static INode GetNode(IMapData Map, INode Node, Vector3 Offset)
            {
                if (Offset.X != 0)
                {
                    Node = Map.GetNode(Node.Position, Offset.X, Directions.East);
                    if (Node == null)
                    {
                        return(null);
                    }
                }

                if (Offset.Z != 0)
                {
                    Node = Map.GetNode(Node.Position, Offset.Z, Directions.North);
                    if (Node == null)
                    {
                        return(null);
                    }
                }

                return(Node);
            }