public void BSP_initLevel() { LevelEndUI.SetActive(false); // destroy previous level if there is one, and make a new one. if (currentLevel != 0) { GameObject.Destroy(tilesHolderInstance); GameObject.Destroy(enemyHolderInstance); GameObject.Destroy(potionsHolderInstance); print(generateStats()); } tilesHolderInstance = Instantiate(holderTemplate); tilesHolderInstance.transform.name = "Tiles Holder"; enemyHolderInstance = Instantiate(holderTemplate); enemyHolderInstance.transform.name = "Enemy Holder"; potionsHolderInstance = Instantiate(holderTemplate); potionsHolderInstance.transform.name = "Potions Holder"; currentLevel++; updateSeed(); rand = GetComponent <PseudoRandom>(); rand.randomInit(rand.hasher, seed, 2); levelMap = new bool[width, height]; levelMap = mapInit(levelMap); levelMap = partition(levelMap, 1, height - 2, 1, width - 2); setSpawnCounts(); // once logic'd out, draw it as a Unity level, put the player in, and let's dance. GenerateUnityMap(); placeStartAndExit(); }
public void initLevel(string seed) { rand = GetComponent <PseudoRandom>(); rand.randomInit(rand.hasher, seed, 2); cellmap = new bool[width, height]; cellmap = mapInit(cellmap); for (int i = 0; i < cycles; i++) { cellmap = doSimulationStep(cellmap); } potionsHolderInstance = levelHolderInstance.transform.Find("Potions").gameObject; skeletonsHolderInstance = levelHolderInstance.transform.Find("Skeletons").gameObject; tilesHolderInstance = levelHolderInstance.transform.Find("MapTiles").gameObject; cellmap = giveBorder(cellmap); skeletons = numberOfSkeletons(); GenerateUnityMap(); spawnSkeletons(cellmap); }