void ReplaceLayoutSpawner(GameObject replacement, int roomIndex) { GameObject targetRoom = spawnedRooms[roomIndex].gameObject; LayoutSpawner layout = GetLayoutSpawner(targetRoom); Destroy(layout.gameObject); Instantiate(replacement, targetRoom.transform); spawnedRooms.Remove(targetRoom); }
void ClearAllChild(LayoutSpawner layout) { foreach (Transform child in layout.transform) { if (child.CompareTag("Enemy")) { layout.enemies.Remove(child.GetComponent <Enemy>()); } Destroy(child.gameObject); } }
void SpawnSpecialRooms() { // alter the last spawned room to exit room ReplaceLayoutSpawner(exit, spawnedRooms.Count - 1); // alter a random room to bonus room ReplaceLayoutSpawner(bigBonusCase, Random.Range(0, spawnedRooms.Count - 1)); spawnedSpecial = true; // alter a random room to boss room GameObject randRoom = spawnedRooms[Random.Range(0, spawnedRooms.Count - 1)].gameObject; LayoutSpawner layout = GetLayoutSpawner(randRoom); Enemy spawnedBoss = Instantiate(boss, randRoom.transform); spawnedBoss.layout = layout; layout.enemies.Add(spawnedBoss); spawnedRooms.Remove(randRoom); }