void Clear() { positions_to_rooms = new Dictionary <Vector2Int, Room>(); adjacent_rooms = new Dictionary <Room, List <Room> >(); possible_neighbors = new Dictionary <Room.Section, List <Room.Section> >(); rooms = new List <Room>(); boss_room_controller = null; teleporter_room_controller = null; tile_set = null; }
void SpawnRooms(Dictionary <Vector2Int, RoomController> room_dict) { positions_to_rooms = new Dictionary <Vector2Int, Room>(); List <Enemy> enemies = new List <Enemy>(); foreach (Vector2Int v in room_dict.Keys) { RoomController new_cont = Instantiate(room_dict[v], new Vector3(v.x * room_width, v.y * room_height, 0), Quaternion.identity); Room new_room = new_cont.room; new_room.position = v; adjacent_rooms.Add(new_room, new List <Room>()); foreach (Vector2Int pos in new_room.GetLocalCoordinatesList()) { positions_to_rooms.Add(pos + v, new_room); foreach (Direction d in System.Enum.GetValues(typeof(Direction))) { if (new_room.HasOpenableDoorway(pos, d)) { new_room.SetDoorwayOpen(pos, d, false); } } } new_room.LoadTileSet(tile_set); new_cont.Init(); enemies.AddRange(new_cont.GetEnemies()); if (new_cont.room_type == RoomType.boss) { boss_room_controller = new_cont as BossRoomController; } else if (new_cont.room_type == RoomType.teleporter) { teleporter_room_controller = new_cont as TeleporterRoomController; } else { rooms.Add(new_room); } } int count = GameManager.instance.level_count - 1; health_buff.SetFlat(3 * count); health_buff.SetMulti((.4f * count)); speed_buff.SetMulti((.25f * count)); armor_buff.SetFlat(1f * count); power_buff.SetFlat(2 * count); power_buff.SetMulti((.2f * count)); foreach (Enemy e in enemies) { power_buff.GetInstance().Apply(e, null); armor_buff.GetInstance().Apply(e, null); speed_buff.GetInstance().Apply(e, null); health_buff.GetInstance().Apply(e, null); } if (boss_room_controller != null) { if (boss_room_controller != null) { boss_room_controller.reward.SetSpawnItem(ItemListSingleton.instance.GetRandomItem(RNGSingleton.instance.item_rng)); } if (teleporter_room_controller != null) { boss_room_controller.teleporter.Link(teleporter_room_controller.teleporter); } foreach (Enemy e in boss_room_controller.GetEnemies()) { enemies.Remove(e); } } if (enemies.Count > 0) { enemies[RNGSingleton.instance.room_gen_rng.GetInt(0, enemies.Count)].AddDropOnDeath(boss_key); } else { if (teleporter_room_controller != null) { teleporter_room_controller.teleporter.SetOpen(true); } } }