// Use this for initialization void Start() { if (debug) { AStarSearch astar = new AStarSearch(starttile, endtile); Debug.Log("Start!"); int count = 0; foreach (IAStarNode node in astar.Route) { Debug.Log(string.Format("[{0}]: ",count++)+node.Position+ ", Rechable: " + astar.reachableTo(node, 2)); } Debug.Log("End!"); } }
private bool reachableTest(List<Room> rooms) { //var rooms = mapgenerator.GeneratingFloor.Rooms; List<TileEntity> tiles = new List<TileEntity>(); foreach (Room r in rooms) { Vector2 pos = r.CenterToInt; TileEntity tile = Physics2D.OverlapPoint(pos, TagList.getLayerMask(TagList.Road)).GetComponent<TileEntity>(); tiles.Add(tile); } TileEntity start = tiles[0]; TileEntity end = tiles[1]; AStarSearch astar = new AStarSearch(start, end); bool rechable = astar.reachableTo(end, Int32.MaxValue); if (rechable) { for (int i = 2; i < tiles.Count; i++) { end = tiles[i]; astar.routeRenew(end); rechable = rechable && astar.reachableTo(end, Int32.MaxValue); if (!rechable) return false; } return true; } return false; }