public void Regenerate(bool nextLevel) { if (nextLevel) { alreadyGenerated = false; floorNum++; } if (floorNum == 4) { // Win Condition, can be changed in future iterations // Could do things like play a cutscene SceneManager.LoadSceneAsync("Victory"); } else { foreach (GameObject obj in spawnedThings) { Destroy(obj.gameObject); } Room[] rooms = FindObjectsOfType <Room>(); foreach (Room room in rooms) { Destroy(room.gameObject); } GetComponent <SelectRoomPrefab>().deadEnd = new List <Room>(); roomsList = null; occupiedPos = new List <Vector2>(); finalRooms = new List <GameObject>(); spawnedThings = new List <GameObject>(); // Needs a bool to check whether the regeneration is because we're going // To the next level or whether the level didn't have 3 dead ends if (nextLevel) { screenTransition.Setup(); AstarPath obj = FindObjectOfType <AstarPath>(); obj.data.gridGraph.center = new Vector3(0, 0, 0); obj.Scan(); } StartCoroutine("TinyLoadPause"); } }