Exemplo n.º 1
0
 public void newMilestonesFromAStar(Vector2 start, Vector2 end)
 {
     //Debug.LogFormat("{0} is Start AStar!",CharacterController.name);
     //Debug.LogFormat("S:{0},E:{1}",start,end);
     CurrentGoalPosition = end;
     if (Vector2.Distance(start, end) <= 1)
     {
         if (CharacterController.canMoveNextPosition(end))
         {
             newMileStones(new Vector2[] { end });
         }
         return;
     }
     int mask = TagList.getLayerMask(TagList.Wall, TagList.Road);
     Debug.logger.Log(CharacterController.name, string.Format("S:{0} E:{1}", start, end));
     var st = Physics2D.OverlapPoint(start,mask).GetComponent<TileEntity>();
     var et = Physics2D.OverlapPoint(end, mask).GetComponent<TileEntity>();
     //Debug.LogFormat("ST:{0},ET:{1}",st.Position,et.Position);
     isOpenRouteFunc isopenroutefunc = isOpenRoute;
     //calcSpecialNodeCostFunc caclspecialnodecostfunc = calcSpecialCost;
     AStarSearch search = new AStarSearch(st, et, SpecialNodeCoseCalculater,null,isopenroutefunc,calcScoreHeuristic);
     var route = new List<Vector2>(search.getRoutePositions(start,end));
     newMileStones(route.ToArray());
     Debug.logger.Log(CharacterController.name, showMileStones());
     //if(MilestonesIncludingEndPosition) route.Add(end);
     //Debug.LogFormat("{0} AStar End:{1},{2},{3}", CharacterController.name, start, end,route[0]);
 }