Esempio n. 1
0
 public void Update(AStarFinder Find)
 {
     this.field         = Find.field;
     this.startX        = Find.startX;
     this.startY        = Find.startY;
     this.endX          = Find.endX;
     this.endY          = Find.endY;
     this.flying        = Find.flying;
     this.flag          = Find.flag;
     this.findHeuristic = Find.findHeuristic;
 }
Esempio n. 2
0
 public AStarFinder Contains(AStarFinder element)
 {
     for (IIterator it = new IteratorAdapter(queue.GetEnumerator()); it.HasNext();)
     {
         AStarFinder af = (AStarFinder)it.Next();
         if (af.Equals(element))
         {
             return(af);
         }
     }
     return(null);
 }
Esempio n. 3
0
		public void Search(AStarFindHeuristic heuristic, int startx, int starty,
				int endx, int endy, bool flying, bool flag,
				AStarFinderListener callback) {
			AStarFinder pathfinderTask = new AStarFinder(heuristic, field, startx,
					starty, endx, endy, flying, flag, callback);
			AStarFinder existing = pathQueue.Contains(pathfinderTask);
			if (existing != null) {
				existing.Update(pathfinderTask);
			} else {
				pathQueue.Add(pathfinderTask);
			}
			pathfinderThread.Interrupt();
		}
Esempio n. 4
0
        public void Search(AStarFindHeuristic heuristic, int startx, int starty,
                           int endx, int endy, bool flying, bool flag,
                           AStarFinderListener callback)
        {
            AStarFinder pathfinderTask = new AStarFinder(heuristic, field, startx,
                                                         starty, endx, endy, flying, flag, callback);
            AStarFinder existing = pathQueue.Contains(pathfinderTask);

            if (existing != null)
            {
                existing.Update(pathfinderTask);
            }
            else
            {
                pathQueue.Add(pathfinderTask);
            }
            pathfinderThread.Interrupt();
        }
Esempio n. 5
0
 public static List <Vector2f> Find(AStarFindHeuristic heuristic,
                                    int[][] maps, int[] limits, int x1, int y1, int x2, int y2,
                                    bool flag)
 {
     heuristic = ((heuristic == null) ? ASTAR_MANHATTAN : heuristic);
     lock (finderLazy)
     {
         if (finderLazy.Count >= LSystem.DEFAULT_MAX_CACHE_SIZE * 10)
         {
             finderLazy.Clear();
         }
         int             key    = MakeLazyKey(heuristic, maps, limits, x1, y1, x2, y2, flag);
         List <Vector2f> result = (List <Vector2f>)CollectionUtils.Get(finderLazy, key);
         if (result == null)
         {
             AStarFinder astar    = new AStarFinder(heuristic);
             Field2D     fieldMap = new Field2D(maps);
             if (limits != null)
             {
                 fieldMap.SetLimit(limits);
             }
             Vector2f start = new Vector2f(x1, y1);
             Vector2f over  = new Vector2f(x2, y2);
             result = astar.Calc(fieldMap, start, over, flag);
             CollectionUtils.Put(finderLazy, key, result);
             astar.Dispose();
         }
         if (result != null)
         {
             List <Vector2f> newResult = new List <Vector2f>();
             CollectionUtils.AddAll(newResult, result);
             result = newResult;
         }
         return(result);
     }
 }
Esempio n. 6
0
 public static List<Vector2f> Find(AStarFindHeuristic heuristic,
         int[][] maps, int[] limits, int x1, int y1, int x2, int y2,
         bool flag)
 {
     heuristic = ((heuristic == null) ? ASTAR_MANHATTAN : heuristic);
     lock (finderLazy)
     {
         if (finderLazy.Count >= LSystem.DEFAULT_MAX_CACHE_SIZE * 10)
         {
             finderLazy.Clear();
         }
         int key = MakeLazyKey(heuristic, maps, limits, x1, y1, x2, y2, flag);
         List<Vector2f> result = (List<Vector2f>)CollectionUtils.Get(finderLazy, key);
         if (result == null)
         {
             AStarFinder astar = new AStarFinder(heuristic);
             Field2D fieldMap = new Field2D(maps);
             if (limits != null)
             {
                 fieldMap.SetLimit(limits);
             }
             Vector2f start = new Vector2f(x1, y1);
             Vector2f over = new Vector2f(x2, y2);
             result = astar.Calc(fieldMap, start, over, flag);
             CollectionUtils.Put(finderLazy, key, result);
             astar.Dispose();
         }
         if (result != null)
         {
             List<Vector2f> newResult = new List<Vector2f>();
             CollectionUtils.AddAll(newResult, result);
             result = newResult;
         }
         return result;
     }
 }
Esempio n. 7
0
 public void Update(AStarFinder Find)
 {
     this.field = Find.field;
     this.startX = Find.startX;
     this.startY = Find.startY;
     this.endX = Find.endX;
     this.endY = Find.endY;
     this.flying = Find.flying;
     this.flag = Find.flag;
     this.findHeuristic = Find.findHeuristic;
 }
Esempio n. 8
0
			public AStarFinder Contains(AStarFinder element) {
				for (IIterator it = new IteratorAdapter(queue.GetEnumerator()); it.HasNext();) {
                    AStarFinder af = (AStarFinder)it.Next();
					if (af.Equals(element)) {
						return af;
					}
				}
				return null;
			}
Esempio n. 9
0
			public void Add(AStarFinder t) {
				Loon.Utils.CollectionUtils.Add(queue,t);
			}
Esempio n. 10
0
 public void Add(AStarFinder t)
 {
     Loon.Utils.CollectionUtils.Add(queue, t);
 }