示例#1
0
 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));
     }
 }
示例#2
0
        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);
        }
示例#3
0
        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];
        }
示例#4
0
 public CachedPath(GridPoint a, GridPoint b, PathType pathType)
 {
     this.a        = a;
     this.b        = b;
     this.pathType = pathType;
 }
示例#5
0
 static bool PathsHavePoint(GridPoint p, Path <GridPoint>[] paths)
 {
     return(System.Array.Find <Path <GridPoint> > (paths, x => x.Source == p || x.Destination == p) != null);
 }
示例#6
0
 public static List <GridPoint> GetPathNoOverlap(GridPoint a, GridPoint b)
 {
     return(GetPath(a, b, PathType.Clear));
 }
示例#7
0
 public static List <GridPoint> GetCheapestPath(GridPoint a, GridPoint b)
 {
     return(GetPath(a, b, PathType.Default));
 }
示例#8
0
 public PathBehaviour(Transform mover, Settings settings, GridPoint startPoint)
 {
     this.mover      = mover;
     this.settings   = settings;
     this.startPoint = startPoint;
 }
示例#9
0
 public void SetDestination(GridPoint point)
 {
     endPoint = point;
     CalculatePath();
 }
示例#10
0
 public bool ContainsPoints(GridPoint a, GridPoint b)
 {
     return(Points[0] == a && Points[1] == b || Points[0] == b && Points[1] == a);
 }
示例#11
0
 public GridPoint GetOtherPoint(GridPoint point)
 {
     return(System.Array.Find(Points, x => x != point));
 }