public static void AddPoint(GridPoint p) { if (points.Contains(p)) { return; } if (points.Count < 2) { points.Add(p); } else { points[first ? 0 : 1] = p; first = !first; } if (points.Count == 2) { // path = Pathfinder.GetShortestPath (points[0], points[1]); // Instance.Line.UpdatePositions (path.ConvertAll (x => x.Position)); } }
public static List <GridPoint> CalculatePath(GridPoint a, GridPoint b, PathType pathType) { #if UNITY_EDITOR if (a == b) { throw new System.Exception("No path could be found because the two points are the same"); } #endif Path <GridPoint>[] pathToUse = GetConnections(pathType); var path = Engine.CalculateShortestPathBetween <GridPoint> (a, b, pathToUse); List <GridPoint> pathList = new List <GridPoint> (); foreach (Path <GridPoint> gp in path) { pathList.Add(gp.Source); } pathList.Add(path.Last.Value.Destination); return(pathList); }
void UpdateTerminus() { Connection c = connections.FirstOrDefault(x => x.Points[0].HasRoad || x.Points[1].HasRoad); Terminus = c.Points[0].HasRoad ? c.Points[0] : c.Points[1]; }
public CachedPath(GridPoint a, GridPoint b, PathType pathType) { this.a = a; this.b = b; this.pathType = pathType; }
static bool PathsHavePoint(GridPoint p, Path <GridPoint>[] paths) { return(System.Array.Find <Path <GridPoint> > (paths, x => x.Source == p || x.Destination == p) != null); }
public static List <GridPoint> GetPathNoOverlap(GridPoint a, GridPoint b) { return(GetPath(a, b, PathType.Clear)); }
public static List <GridPoint> GetCheapestPath(GridPoint a, GridPoint b) { return(GetPath(a, b, PathType.Default)); }
public PathBehaviour(Transform mover, Settings settings, GridPoint startPoint) { this.mover = mover; this.settings = settings; this.startPoint = startPoint; }
public void SetDestination(GridPoint point) { endPoint = point; CalculatePath(); }
public bool ContainsPoints(GridPoint a, GridPoint b) { return(Points[0] == a && Points[1] == b || Points[0] == b && Points[1] == a); }
public GridPoint GetOtherPoint(GridPoint point) { return(System.Array.Find(Points, x => x != point)); }