public void CreateTilemap() { wfc.CreateNewTileMap(); }
// Start is called before the first frame update void Start() { Mode gameMode = LevelModeSetup.mode; List <CellMode> proceduralGeneration = new List <CellMode>(); /* * WAVE FUNCTION COLLAPSE */ if (gameMode == Mode.Wfc) { wfc = new WaveFunctionCollapse(inputTilemap, outupTilemap, 1, LEVEL_WIDTH, LEVEL_HEIGHT, 500, true); wfc.CreateNewTileMap(); Tilemap tl = wfc.GetOutputTileMap(); BoundsInt bounds = tl.cellBounds; TileBase[] allTiles = tl.GetTilesBlock(bounds); // 5 tries to create a level with wfc int triesMax = 5; int tries = 0; while (allTiles.Length == 0 || tries < triesMax) { Debug.Log("tries"); Debug.Log(tries); wfc.CreateNewTileMap(); tl = wfc.GetOutputTileMap(); bounds = tl.cellBounds; allTiles = tl.GetTilesBlock(bounds); tries++; } // Create a level with wfc tiles if (allTiles.Length > 0) { setPGFromWFCOutput(allTiles, proceduralGeneration); } else { proceduralGeneration = generateMap(); } } /* * Safety */ if (gameMode == Mode.Safety) { proceduralGeneration = generateMap(); } // Instantiate level for (int i = 0; i < proceduralGeneration.Count; i++) { instantiateFor(proceduralGeneration[i], i); } // Place end portal PlacePortal(proceduralGeneration); }