Пример #1
0
        public bool TryAlterDestination(Vector2 destination)
        {
            int           final_index;
            Pathfinding2D pathfinding = Pathfinding2D.GetInstance();

            if (waypoints.Offset(waypoint_index).TryApproximateEarliestEdge(
                    p => pathfinding.IsConnection(p, destination), out final_index)
                )
            {
                waypoints.RemoveEnding(waypoint_index + final_index + 1);
                waypoints.Add(destination);
                return(true);
            }

            return(false);
        }
Пример #2
0
        static public PathNavigator2D GetPathNavigatorToDestination(this Pathfinding2D item, Vector2 origin, Vector2 destination)
        {
            if (item.IsConnection(origin, destination))
            {
                return(new PathNavigator2D(destination));
            }
            else
            {
                PathNode2D origin_node      = item.GetConnectionNear(origin);
                PathNode2D destination_node = item.GetConnectionNear(destination);

                if (origin_node != null && destination_node != null)
                {
                    return(new PathNavigator2D(
                               origin_node.GetOptimalPathTo(destination_node),
                               destination
                               ));
                }
            }

            return(null);
        }
Пример #3
0
 static public bool IsConnection(this Pathfinding2D item, Component component1, Component component2)
 {
     return(item.IsConnection(component1.GetPlanarPosition(), component2.GetPlanarPosition()));
 }
Пример #4
0
 static public bool IsConnection(this Pathfinding2D item, Vector2 position, Component component)
 {
     return(item.IsConnection(position, component.GetPlanarPosition()));
 }