private void AddRoom(Maze room, Vector3Int mazeOffset, Maze maze, List <Vector3Int> mask) { var roomBounds = room.GetBounds(); var roomOffset = roomBounds.size / 2; var offset = roomOffset + mazeOffset; foreach (var floorPositions in room.GetFloorPositions()) { var offseted = floorPositions + offset; var tile = room.FloorSpriteTilemap.GetTile(floorPositions); maze.PlaceFloorAtPosition(offseted, tile); if (!mask.Contains(offseted)) { mask.Add(offseted); } } foreach (var wallPositions in room.GetWallPositions()) { var offseted = wallPositions + offset; var tile = room.WallSpriteTilemap.GetTile(wallPositions); maze.PlaceWallAtPosition(offseted, tile); if (!mask.Contains(offseted)) { mask.Add(offseted); } } foreach (var floorPositions in room.GetFloorObjectsPositions()) { var offseted = floorPositions + offset; var tile = room.FloorObjectsTilemap.GetTile(floorPositions); maze.PlaceFloorObjectAtPosition(offseted, tile); if (!mask.Contains(offseted)) { mask.Add(offseted); } } foreach (var wallPositions in room.GetWallObjectsPositions()) { var offseted = wallPositions + offset; var tile = room.WallObjectsTilemap.GetTile(wallPositions); maze.PlaceWallObjectAtPosition(offseted, tile); if (!mask.Contains(offseted)) { mask.Add(offseted); } } }
private Vector3Int GetRandomPosForRoom(Maze room, BoundsInt mazeBounds) { var roomBounds = room.GetBounds(); int xMin = mazeBounds.xMin + 1; int xMax = xMin + mazeBounds.size.x - roomBounds.size.x - 1; int yMin = mazeBounds.yMin + 1; int yMax = yMin + mazeBounds.size.y - roomBounds.size.y - 1; int xPos = Random.Range(xMin, xMax); int yPos = Random.Range(yMin, yMax); return(new Vector3Int(xPos, yPos, 0)); }