private WorldData.RoomCell BuildRoomsRecurrent(ref WorldData world, Room.MapPos pos, int length) { var cell = world.RoomMap[pos.x][pos.y]; if (cell.IsEmpty()) { RoomInfo roomInfo = Info.RoomsLeft != world.RoomCount ? RandomizePrefab(ref world) : new RoomInfo() { Prefab = FirstRoom, Type = Room.RoomType.Normal }; var go = Instantiate(roomInfo.Prefab, WorldParent) as GameObject; var room = go.GetComponent <Room>(); room.MapPosition = pos; room.gameObject.SetActive(false); cell = new WorldData.RoomCell(roomInfo.Type, room); world.RoomMap[pos.x][pos.y] = cell; world.AllRooms.Add(room); } if (Info.RoomsLeft > 0 && cell.Type != Room.RoomType.Boss) { BuildChildRooms(ref world, cell, length); } return(cell); }
private WorldData.RoomCell BuildRoomsRecurrent(ref WorldData world, Room.MapPos pos, int length) { RoomInfo roomInfo = Info.RoomsLeft != world.RoomCount ? RandomizePrefab(ref world) : new RoomInfo() { Prefab = FirstRoom, Type = Room.RoomType.Normal }; var go = Instantiate(roomInfo.Prefab, WorldParent) as GameObject; var room = go.GetComponent <Room>(); room.MapPosition = pos; room.gameObject.SetActive(false); var cell = new WorldData.RoomCell(roomInfo.Type, room); /*if (roomInfo.Type == Room.RoomType.Boss) * { * room.KeyLock = new Door.Key() {color = Color.red}; * Info.Keys.Push(new KeyInfo() { Key = room.KeyLock, HasLock = true}); * * for (int i = 0; i < Info.KeysCount; i++) * { * var key = Keys[i]; * * Info.Keys.Push(new KeyInfo() { Key = key }); * } * }*/ world.RoomMap[pos.x][pos.y] = cell; world.AllRooms.Add(room); if (Info.RoomsLeft > 0 && roomInfo.Type != Room.RoomType.Boss) { ProcessRooms(ref world, cell, length); } /*if (Info.HasBoss * && roomInfo.Type != Room.RoomType.Boss * && room != world.FirstRoom * && Info.Keys.Any()) * { * var keyInfo = Info.Keys.Peek(); * if (!keyInfo.HasPickup) * { * keyInfo.HasPickup = true; * room.KeyPickup = keyInfo.Key; * } * * if (!keyInfo.HasLock && !room.IsMainRoom) * { * keyInfo.HasLock = true; * room.KeyLock = keyInfo.Key; * } * * if (keyInfo.HasLock && keyInfo.HasPickup) * { * Info.Keys.Pop(); * } * }*/ return(cell); }