//获取P点四周为+-out_count(包含边界)以内的可以通过的点 public Vector2Int?FindAroundFreePoint(Vector2Int basePoint, int outCount, List <Vector2Int> exceptPointList, int[] canPassObstacleTypes, int[] canPassTerrainTypes, RandomManager randomManager = null) { return(AStarUtil.FindAroundFreePoint(this, basePoint, outCount, exceptPointList, canPassObstacleTypes, canPassObstacleTypes, randomManager)); }
// 随机获取地图上一点 public Vector2Int GetRandomPos(int[] canPassObstacleTypes, int[] canPassTerrainTypes, RandomManager randomManager = null) { randomManager = randomManager ?? Client.instance.randomManager; int width = GetWidth(); int height = GetHeight(); int x = randomManager.RandomInt(0, width); int y = randomManager.RandomInt(0, height); Vector2Int result = new Vector2Int(x, y); if (canPassObstacleTypes != null || canPassTerrainTypes != null) { if (canPassObstacleTypes == null) { canPassObstacleTypes = AStarMapPathConst.Air_Can_Pass_Obstacle_Types; } if (canPassTerrainTypes == null) { canPassTerrainTypes = AStarMapPathConst.Air_Can_Pass_Terrain_Types; } Vector2Int?freePoint = AStarUtil.FindAroundFreePoint(GetMapPath(), result, null, canPassObstacleTypes, canPassTerrainTypes, randomManager); if (freePoint != null) { result = freePoint.Value; } } return(result); }
public static Action Test_FindAroundFreePoint() { Vector2Int?point = AStarUtil.FindAroundFreePoint(new AStarMapPath(grids), new Vector2Int(2, 2), 2, null, AStarMapPathConst.Critter_Can_Pass_Obstacle_Types, AStarMapPathConst.User_Can_Pass_Terrain_Types); return(() => { if (point != null) { AStarUtil.GUIShowPointList(0, 0, 9, 9, point.Value); } }); }