public DesignedBuilding(SocialStructure socialStructure) { maxSocialTier = GetMaxSocialTier(socialStructure); var livingQuarters = GetLivingQuarters(socialStructure); var commonSpaces = GetCommonSpaces(socialStructure); DetermineSize(livingQuarters); DetermineSize(commonSpaces); foreach (var room in livingQuarters) { rooms.Add(room); } foreach (var room in commonSpaces) { rooms.Add(room); } var bossRoom = new BossRoom() { size = 100 }; rooms.Add(bossRoom); socialStructure.population[0].quality = 4; socialStructure.population[0].associatedRooms = new List <Room> { bossRoom }; layout = new DesignedBuildingLayout(this); layout.LayoutRooms(); }
public override IEnumerator PlayAnimation(GameObject boss, BossRoom room) { PlayerCamera camera = PlayerCamera.Instance; camera.enabled = false; DungeonCreator.Instance.AdjustMask(new Vector2(room.Border.xMin, room.Border.yMin), room.Border.size); yield return(EnumeratorUtil.GoToInSecondsSlerp(camera.transform, room.Middle, 2.0f)); BossUIManager.Instance.Show(boss.GetComponent <Entity>(), 2.0f); yield return(new WaitForSeconds(2.0f)); if (Player.LocalPlayer.isServer) { List <Player> activePlayers = PlayersDict.Instance.Players; for (int i = 0; i < activePlayers.Count; i++) { activePlayers[i].SmoothSync.teleportAnyObjectFromServer(room.PlayersStartPos, Quaternion.identity, new Vector3(1, 1, 1)); } } yield return(EnumeratorUtil.GoToInSecondsSlerp(camera.transform, Player.LocalPlayer.transform.position, 2.0f)); camera.enabled = true; }
public void OnPlayerReadyToEnterChanged(Player player, bool ready) { if (!ready) { playersReady.Remove(player); } else { if (playersReady.Contains(player) == false) { playersReady.Add(player); } } BossRoom bossRoom = DungeonDict.Instance.BossRoom; if (bossRoom.CurrentState != BossRoom.State.ReadyToEnter) { return; } if (playersReady.Count == PlayersDict.Instance.Players.Count) { bossRoom.OnAllPlayersReadyToEnter(this); } }
void Start() { placed_tiles = new Dictionary <Vector2Int, Tile>(); placed_blocks = new Dictionary <Vector2Int, Block>(); Room load = FindObjectOfType <Room>(); if (load != null) { LoadRoom(load); if (boss_room) { edited_room.gameObject.AddComponent <BossRoom>(); BossRoom br = edited_room.GetComponent <BossRoom>(); br.Copy(edited_room); Destroy(edited_room); edited_room = br; } } else { edited_room = Instantiate(base_room); if (boss_room) { edited_room.gameObject.AddComponent <BossRoom>(); BossRoom br = edited_room.GetComponent <BossRoom>(); br.Copy(edited_room); Destroy(edited_room); edited_room = br; } PlaceBlock(Vector2Int.zero); } current = square; }
void SpawnRooms(Dictionary <Vector2Int, Room> room_dict) { positions_to_rooms = new Dictionary <Vector2Int, Room>(); foreach (Vector2Int v in room_dict.Keys) { Room new_room = Instantiate(room_dict[v], new Vector3(v.x * room_width, v.y * room_height, 0), Quaternion.identity); new_room.grid_position = v; new_room.SetSize(room_width, room_height); adjacent_rooms.Add(new_room, new List <Room>()); foreach (Vector2Int pos in new_room.template.GetCoordinateList()) { positions_to_rooms.Add(pos + v, new_room); new_room.template.GetBlock(pos).DisablePathway(); } new_room.LoadTileSet(ts); new_room.SpawnRandomRoomset(); if (new_room as BossRoom != null) { boss_room = new_room as BossRoom; } else { rooms.Add(new_room); } } item_pool.Shuffle(); List <Room> can_spawn_item = new List <Room>(rooms); int target_items = 3; while (can_spawn_item.Count > 0 && target_items > 0) { can_spawn_item.Shuffle(); ItemSpawner item_spawn = can_spawn_item[0].GetComponentInChildren <ItemSpawner>(); if (item_spawn == null) { can_spawn_item.RemoveAt(0); } else { item_spawn.SpawnItemChest().SetSpawnItem(item_pool[0]); item_pool.RemoveAt(0); target_items--; can_spawn_item.RemoveAt(0); } } if (boss_room.reward) { boss_room.reward.SpawnItemChest().SetSpawnItem(item_pool[0]); item_pool.RemoveAt(0); } foreach (Room r in rooms) { foreach (ItemSpawner ispawn in r.GetComponentsInChildren <ItemSpawner>()) { Destroy(ispawn.gameObject); } } }
private DungeonRoom CreateRandomExit(PlanetData data, DungeonRoom room, bool locked, int lockID, bool bossRoom, bool treasure, PlanetDifficultyModifiers difficultyModifiers) { if (room.ExitCount == 4) { return(room); } List <Direction> directions = new List <Direction> { Direction.Up, Direction.Right, Direction.Down, Direction.Left }; //remove any directions that are not available for (int j = directions.Count - 1; j >= 0; j--) { IntPair roomPos = AddDirection(room.position, directions[j]); if (data.GetRoomAtPosition(roomPos) != null) { directions.RemoveAt(j); } } //if no available directions then we're in a dead end if (directions.Count == 0) { return(room); } Direction randomDirection = directions[Random.Range(0, directions.Count)]; IntPair pos = AddDirection(room.position, randomDirection); DungeonRoom newRoom; if (bossRoom) { newRoom = new BossRoom(pos, room, difficultyModifiers.enemyRoomDifficulty); } else if (treasure) { newRoom = new TreasureRoom(pos, room); } else { newRoom = PickRandomRoom(pos, room, difficultyModifiers); } data.AddRoom(newRoom); if (locked) { ConnectWithLock(room, newRoom, randomDirection, lockID); } else { Connect(room, newRoom, randomDirection); } return(newRoom); }
/// <summary> /// Generates specific values for the DungeonType. /// </summary> /// <param name="room">The current room.</param> /// <param name="dungeonRoomObject">The gameobject to which the room should be generate don.</param> /// <param name="levelNumber">The number of the level.</param> /// <returns>The fully generated DungeonRoom.</returns> private DungeonRoom SetRoomType(Room room, GameObject dungeonRoomObject, int levelNumber, DungeonConfig config) { switch (room.Type) { case RoomType.Start: StartRoom startRoom = dungeonRoomObject.AddComponent <StartRoom>(); if (Player.LocalPlayer.isServer && levelNumber == 0) { startRoom.SpawnItems(RegionDict.Instance.StartingRoomPickables, DungeonCreator.Instance.TilePositionToWorldPosition(room.Position + (room.Layout.Size / 2))); } return(startRoom); case RoomType.Combat: CombatRoom combatRoom = dungeonRoomObject.AddComponent <CombatRoom>(); combatRoom.ThreatLevel = room.TileCount; combatRoom.enemiesToSpawn = new EnemyObject[combatRoom.ThreatLevel / 48]; for (int j = 0; j < combatRoom.enemiesToSpawn.Length; j++) { combatRoom.enemiesToSpawn[j] = RandomUtil.Element(RegionDict.Instance.EnemiesToSpawn); } return(combatRoom); case RoomType.Loot: LootRoom lootRoom = dungeonRoomObject.AddComponent <LootRoom>(); lootRoom.pickables = new Pickable[room.TileCount / 48]; for (int j = 0; j < lootRoom.pickables.Length; j++) { lootRoom.pickables[j] = RandomUtil.Element(RegionDict.Instance.LootingRoomPickables); } return(lootRoom); case RoomType.Shop: ShopRoom shopRoom = dungeonRoomObject.AddComponent <ShopRoom>(); const int numItems = 4; shopRoom.shopItems = new Pickable[numItems]; shopRoom.locations = new Vector2[numItems]; // TODO: Replace Pickabledict with dungeon config shop pickables. for (int j = 0; j < numItems; j++) { int rnd = Random.Range(0, config.shopItems.Length); shopRoom.shopItems[j] = config.shopItems[rnd]; shopRoom.locations[j] = room.Position + new Vector2Int((int)room.GameObjects[j + 4].Position.x, (int)room.GameObjects[j + 4].Position.y); } shopRoom.SpawnItems(); return(shopRoom); case RoomType.Boss: BossRoom bossRoom = dungeonRoomObject.AddComponent <BossRoom>(); bossRoom.bossObjects = new BossObject[] { RandomUtil.Element(RegionDict.Instance.BossesToSpawn) }; DungeonDict.Instance.SetBossRoom(bossRoom); return(bossRoom); case RoomType.Empty: EmptyRoom emptyRoom = dungeonRoomObject.AddComponent <EmptyRoom>(); return(emptyRoom); default: throw new System.Exception("Unknown room type! (" + room.Type + ")"); } }
/// <summary> /// функция создает комнату с монстрами /// </summary> public static RoomType RollRT(List <Hero> party) { RoomSize = 3; if (DgnInfo.RoomNum < 5) { int Rand = Random.Range(0, 100) + 1; if (Rand <= 80) { OrdRoom Room = new OrdRoom(party); return(Room); //Room.Fight(Room); DgnInfo.RoomNum++; } else { Treasury Treasury = new Treasury(party); return(Treasury); //Treasury.Fight(Treasury); DgnInfo.RoomNum++; } } else { BossRoom Boss = new BossRoom(party); return(Boss); //Boss.Fight(Boss); DgnInfo.RoomNum = 1; DgnInfo.DgnLvl++; } }
void PlaceBossRoom(Room connectedRoom) { List <Direction> directions = GetRandomValidCorridorDirections(connectedRoom, Random.Range(1, 5)); if (directions.Count == 0) { return; } foreach (Direction direction in directions) { Vector2 roomPos = FindValidRoomPlacement(connectedRoom, direction, true); if (roomPos == nullVector) { break; } BossRoom bossRoom = ScriptableObject.CreateInstance <BossRoom>(); bossRoom.SetupRoom(roomPos, bossRoomWidth, bossRoomHeight, direction); rooms.Add(bossRoom); Corridor corridor = PlaceCorridor(connectedRoom, bossRoom, direction); if (corridor != null) { spawnedBossRoom = true; bossRoom.AddCorridor(corridor); connectedRoom.AddCorridor(corridor); return; } } }
IEnumerator SpawnBossRoom() { yield return(new WaitUntil(() => SceneManager.GetActiveScene().buildIndex == 2)); if (shuffledBosses.Count > 0) { BossRoom bossRoom = Instantiate(shuffledBosses.Dequeue(), transform.position, Quaternion.identity) as BossRoom; } }
protected override Builder GetBuilder() { var res = new BossLevelBuilder { BossRoom = new BossRoom() }; BossRoom = res.BossRoom; return(res); }
public void SetupRooms(List <RoomDef> Rooms) { Entrance = null; Exit = null; Boss = null; Granny = null; OldMan = null; MultiConnection.Clear(); SingleConnection.Clear(); SubShop.Clear(); foreach (var Room in Rooms) { Room.SetEmpty(); } foreach (var Room in Rooms) { if (Room is BossRoom b) { Boss = b; } else if (Room is OldManRoom) { OldMan = (OldManRoom)Room; } else if (Room is GrannyRoom) { Granny = (GrannyRoom)Room; } else if (Room is EntranceRoom) { Entrance = (EntranceRoom)Room; } else if (Room is ExitRoom) { Exit = (ExitRoom)Room; } else if (Room is SubShopRoom) { SubShop.Add(Room); } else if (Room.GetMaxConnections(RoomDef.Connection.All) == 1) { SingleConnection.Add(Room); } else if (Room.GetMaxConnections(RoomDef.Connection.All) > 1) { MultiConnection.Add(Room); } } WeightRooms(MultiConnection); MultiConnection = new List <RoomDef>(MultiConnection); }
public override void Enter() { UIMng.Instance.CallEvent(UIList.Loading, "StopBlick"); UIMng.Instance.SetActive(UIList.Loading, false); UIMng.Instance.FadeIn(false, 1f, null); UIMng.Instance.CallEvent(UIList.Mouse, "Release"); UIMng.Instance.CallEvent(UIList.Mouse, "SetUp"); UIMng.Instance.SetActive(UIList.HUD, false); _bossRoom = FindObjectOfType <BossRoom>(); _bossRoom.Init(); _bossRoom.CutScene(1); }
private List <Room> CreateRooms() { var output = new List <Room>(); for (int roomNumber = 0; roomNumber < 36; roomNumber++) { output.Add(new VaultRoom() { size = Random.Range(4, 26) }); } var bossRoom = new BossRoom() { size = 100 }; output.Add(bossRoom); return(output); }
// Start is called before the first frame update void Start() { parentTransform = transform.parent; // parentCollider = GetComponentInParent<BoxCollider>(); currentMovement = 0; // collider = GetComponent<BoxCollider>(); originalPoisition = transform.position; renderer = GetComponent <MeshRenderer>(); bossRoom = GameObject.Find("Boss Room Trigger").GetComponent <BossRoom>(); finalDestinationPositions = new float[movementTimeAndDestinations.Length]; for (int i = 0; i < movementTimeAndDestinations.Length; i++) { float f = parentTransform.position.y; for (int j = 0; j <= i; j++) { f += movementTimeAndDestinations[j].destinationPosition; } finalDestinationPositions[i] = f; } }
static Dungeon GetCustomDungeon() { var roomN = new BossRoom() { Coords = new RoomCoords(0, 1) }; var roomNE = new Chamber() { Coords = new RoomCoords(1, 1) }; var roomW = new Chamber() { Coords = new RoomCoords(-1, 0) }; var roomC = new StartRoom() { Coords = new RoomCoords(0, 0) }; var roomE = new Chamber() { Coords = new RoomCoords(1, 0) }; var roomSW = new Chamber() { Coords = new RoomCoords(-1, -1) }; var roomS = new Chamber() { Coords = new RoomCoords(0, -1) }; var roomSE = new Chamber() { Coords = new RoomCoords(1, -1) }; var roomNW = new Chamber() { Coords = new RoomCoords(-1, 1) }; roomNW.AdjacentEast = roomN; roomNW.AdjacentSouth = roomW; roomN.AdjacentWest = roomNW; roomN.AdjacentEast = roomNE; roomNE.AdjacentWest = roomN; roomNE.AdjacentSouth = roomE; roomE.AdjacentNorth = roomNE; roomE.AdjacentWest = roomC; roomC.AdjacentEast = roomE; roomC.AdjacentWest = roomW; roomC.AdjacentSouth = roomS; roomS.AdjacentNorth = roomC; roomS.AdjacentEast = roomSE; roomS.AdjacentWest = roomSW; roomSE.AdjacentWest = roomS; roomW.AdjacentNorth = roomNW; roomW.AdjacentEast = roomC; roomW.AdjacentSouth = roomSW; roomSW.AdjacentNorth = roomW; roomSW.AdjacentEast = roomS; return(new Dungeon() { Rooms = new List <Room> { roomNW, roomN, roomNE, roomW, roomC, roomE, roomSW, roomS, roomSE } }); }
private void Awake() { instance = this; }
public override IEnumerator PlayAnimation(GameObject boss, BossRoom room) { yield break; }
/// <summary> /// Plays the animation. /// </summary> /// <param name="boss">The spawned boss.</param> /// <param name="room">The room where the boss spawned.</param> public abstract IEnumerator PlayAnimation(GameObject boss, BossRoom room);
// Add a boss and KeyRoom away from each other void AddBossAndKeyRooms() { // Create boss room first at the farthest position in the map from the spawnpoint int[] posBoss = FarthestRoomFrom(roomGridY / 2, roomGridX / 2); tabRooms[posBoss[0], posBoss[1]] = new BossRoom(roomWidth, roomHeight, posBoss[1] * (tileSize * roomWidth), posBoss[0] * (tileSize * roomHeight), tileSize); ConnectToExistingRooms(posBoss[0], posBoss[1]); // Create keyRoom at the farthest position from the created boss room int[] posKey = FarthestRoomFrom(posBoss[0], posBoss[1]); tabRooms[posKey[0], posKey[1]] = new KeyRoom(roomWidth, roomHeight, posKey[1] * (tileSize * roomWidth), posKey[0] * (tileSize * roomHeight), tileSize); ConnectToExistingRooms(posKey[0], posKey[1]); }
public void DefineRooms() { HashSet <int> treasureRooms = new HashSet <int>(); //Define what room ids are going to be treasure rooms if (treasureRoomQuantity <= _dungeonRooms.Count) { while (treasureRoomQuantity > 0) { int randomRoomID = Random.Range(2, _dungeonRooms.Count + 1); if (!treasureRooms.Contains(randomRoomID)) { treasureRooms.Add(randomRoomID); treasureRoomQuantity--; } } } int bottomStartRoom = GetRandomSideRoom(3); int topEndRoom = GetRandomSideRoom(1); RoomController roomComponent = null; foreach (DungeonRoom dungeonRoom in _dungeonRooms) { if (treasureRooms.Contains(dungeonRoom.id)) { roomComponent = dungeonRoom.room.AddComponent(typeof(TreasureRoom)) as TreasureRoom; } else { roomComponent = dungeonRoom.room.AddComponent(typeof(EnemiesRoom)) as EnemiesRoom; } _dungeonRoomsComponent.Add(roomComponent); Rect roomFloorsRectangle = new Rect(dungeonRoom.roomRectangle.position, new Vector2(dungeonRoom.roomRectangle.width - 2f, dungeonRoom.roomRectangle.height - 4f)); roomComponent.Initialize(this, tilesPosition, dungeonRoom.id, dungeonRoom.roomRectangle, roomFloorsRectangle); roomComponent.DrawRoomInteriors(); //Set player initial position at a random floor tile of the first room if (dungeonRoom.id == bottomStartRoom) { GameObject initialCorridorInstance = Instantiate(initialCorridor, roomComponent.DestroyRandomSideWall(3), Quaternion.identity, roomComponent.transform.GetChild(0)); GatewayPortal initialCorridorGateway = initialCorridorInstance.GetComponent <GatewayPortal>(); GameObject firstRoomTile = tilesPosition[(int)initialCorridorInstance.transform.position.x, (int)initialCorridorInstance.transform.position.y + 1]; tilesPosition[(int)initialCorridorInstance.transform.position.x, (int)initialCorridorInstance.transform.position.y].tag = "Gateway"; roomComponent.isFirstRoom = true; firstRoomTile.tag = "Gateway"; initialCorridorGateway.Initialize(this, 1, corridorSpeed, tilesPosition, _clsPlayerController.transform, _clsPlayerController, _clsPlayerSpriteManager); initialCorridorGateway.SetSimpleGateway(firstRoomTile); _clsPlayerController.gameObject.transform.position = new Vector3(initialCorridorInstance.transform.position.x, initialCorridorInstance.transform.position.y - 40); } //Set boss room in the last dungeon room if (dungeonRoom.id == topEndRoom) { GameObject bossRoomInstance = Instantiate(bossRoom, roomComponent.DestroyRandomSideWall(1), Quaternion.identity); BossRoom bossRoomComponent = bossRoomInstance.GetComponent <BossRoom>(); GatewayPortal bossRoomGateway = bossRoomInstance.GetComponent <GatewayPortal>(); tilesPosition[(int)bossRoomInstance.transform.position.x, (int)bossRoomInstance.transform.position.y].tag = "Gateway"; bossRoomGateway.Initialize(this, 1, corridorSpeed, tilesPosition, _clsPlayerController.transform, _clsPlayerController, _clsPlayerSpriteManager); bossRoomGateway.SetSimpleGateway(bossRoomComponent.firstPortalStop); bossRoomComponent.Initialize(this, tilesPosition, dungeonRoom.id + 1); roomComponent.roomGateways.Add(bossRoomGateway); } } }
/// <summary> /// Sets the boss room. /// </summary> /// <param name="bossRoom">The boss room to be set.</param> public void SetBossRoom(BossRoom bossRoom) { BossRoom = bossRoom; }
private List <RoomSpawn> SpawnBossRoom(List <RoomSpawn> roomSpawns, int floor) { //pick random boss from floor list BossRoom bossRoom = floorBosses[floor].bossRooms[Random.Range(0, floorBosses[floor].bossRooms.Count - 1)]; //setup RoomSpawn for boss room RoomSpawn bossRoomSpawn = new RoomSpawn(); RoomDescriber bossRoomDescriber = bossRoom.bossRoom.GetComponent <RoomDescriber>(); //add doors List <DoorDescriber> doors = new List <DoorDescriber>(); for (int i = 0; i < bossRoomDescriber.doorways.Count; i++) { doors.Add(bossRoomDescriber.doorways[i].GetComponent <DoorDescriber>()); doors[i].location = new Vector2( bossRoomDescriber.doorways[i].transform.position.x, bossRoomDescriber.doorways[i].transform.position.y); doors[i].doorOpen = true; doors[i].elevatorDoor = false; } bossRoomSpawn.roomSize = bossRoomDescriber.roomSize; bossRoomSpawn.doors = doors; List <Vector2> bossRoomDoorAdjusts = new List <Vector2>(); foreach (DoorDescriber door in bossRoomSpawn.doors) { bossRoomDoorAdjusts.Add(GetDoorAdjust(door)); } List <RoomSpawn> validRooms = new List <RoomSpawn>(); //find all VALID rooms for this particular boss room foreach (RoomSpawn room in roomSpawns) { foreach (DoorDescriber door in room.doors) { bool found = false; foreach (Vector2 bossRoomAdjust in bossRoomDoorAdjusts) { if (IsDoorInverse(GetDoorAdjust(door), bossRoomAdjust)) { validRooms.Add(room); break; } } if (found) { break; } } } bool finished = false; int maxLoops = Constants.LEVELGEN_BOSS_ROOM_MAX_LOOPS; List <int> usableRooms = new List <int>(); for (int i = 0; i < validRooms.Count; i++) { usableRooms.Add(i); } do { //pick random valid room, then pick random valid door int randomPick = Random.Range(0, usableRooms.Count - 1); usableRooms.RemoveAt(randomPick); if (usableRooms.Count == 0) { Debug.LogError("Ran out of usable rooms to spawn boss room: Regenerating level"); GenerateLevel(floor); return(null); } int randomRoom = usableRooms[randomPick]; int bossDoorPick = -1; int roomDoorPick = -1; for (int i = 0; i < validRooms[randomRoom].doors.Count; i++) { for (int j = 0; j < bossRoomDoorAdjusts.Count; j++) { if (IsDoorInverse(GetDoorAdjust(validRooms[randomRoom].doors[i]), bossRoomDoorAdjusts[j])) { bossDoorPick = j; roomDoorPick = i; } } } //spawn boss room Vector2 roomMove = MatchDoorRoomAdjust( bossRoomSpawn.location, bossRoomSpawn.doors[bossDoorPick].location, validRooms[randomRoom].location, validRooms[randomRoom].doors[roomDoorPick].location, GetDoorAdjust(validRooms[randomRoom].doors[roomDoorPick])); bossRoomSpawn.location += roomMove; if (!CheckRoomIntersections(roomSpawns, bossRoomSpawn)) { GameObject bossRoomObj = Instantiate(bossRoom.bossRoom, mapTransform); bossRoomObj.transform.position = bossRoomSpawn.location; bossRoomSpawn.obj = bossRoomObj; bossRoomSpawn.doors[bossDoorPick].doorOpen = false; validRooms[randomRoom].doors[roomDoorPick].doorOpen = false; bossRoomPick = bossRoomSpawn; bossPick = bossRoom.boss; roomSpawns.Add(bossRoomSpawn); graph.AddNodes(bossRoomSpawn.obj.GetComponent <RoomDescriber>().enemyPathPoints, 0); finished = true; } maxLoops--; } while (maxLoops > 0 && !finished && usableRooms.Count > 0); if (maxLoops == 0) { Debug.LogError("Boss room failed to spawn, max iterations passed"); } else if (usableRooms.Count == 0) { Debug.LogError("Boss room failed to spawn, ran out of rooms to search through"); } Debug.Log($"Generating boss room took {Constants.LEVELGEN_BOSS_ROOM_MAX_LOOPS - maxLoops} iterations"); return(roomSpawns); }