Check if the position is actually inside the collider (there may be holes).Get a random position inside floor collider bounds.We will use the floor collider that we set up in the previous step to get a random position inside the room. ![]() We will use a very simple approach to a randomized spawn of enemies. That means that we have a floor collider that is set to trigger, and it informs RoomManager when the player enters a room. We will use the same setup as we described in the Current room detection tutorial. The base of this setup is detecting when a player enters a room. Therefore, the doors open after some time even though enemies are still alive. Note: The enemies in this example are very dumb - they just stand there and cannot be killed as there is no combat system implemented. Your browser does not support the video tag. Only after all the enemies are defeated, the doors unlock. First, all the doors to neighbouring rooms get closed and locked. In Enter the Gungeon, when a player visits a (combat-oriented) room for the first time, two things happen. LevelDescription.AddCorridorConnection(connection, corridorRoom, ()) Var corridorRoom = ScriptableObject.CreateInstance() ĬorridorRoom.Type = GungeonRoomType.Corridor Var connection = ScriptableObject.CreateInstance() Prepare the connection between secretRoom and roomToAttachTo LevelDescription.AddRoom(secretRoom, RoomTemplates.GetRoomTemplates(secretRoom).ToList()) SecretRoom.Type = GungeonRoomType.Secret Var secretRoom = ScriptableObject.CreateInstance() Var roomToAttachTo = possibleRoomsToAttachTo (!attachToDeadEnd || graph.GetNeighbors(x).Count() = 1) & x.Type != GungeonRoomType.Entrance Var attachToDeadEnd = Random.NextDouble() ().Where(x => ![]() Decide whether to attach the secret room to a dead end room or not ![]() If (Random.NextDouble() > SecretRoomChance) return Return early if no secret room should be added to the level Private void AddSecretRoom(LevelDescriptionGrid2D levelDescription) Protected override LevelDescriptionGrid2D GetLevelDescription() Public float SecretRoomDeadEndChance = 0.5f The probability that a secret room is attached to a dead-end room The probability that a secret room is added to the level Public GungeonRoomTemplatesConfig RoomTemplates Public class GungeonInputSetupTask : DungeonGeneratorInputBaseGrid2D I may revisit this in the future to make them really secret. Note: Our secret rooms are not really secret as we do not hide them in any way. And third, because we use corridors, we also need to create an instance of the corridor room that is between the two rooms. Second, we create an instance of the connection between the two rooms - this corresponds to an edge in the level graph. First, we create an instance of the secret room - this corresponds to a room node in the level graph. To add the secret room to the level, we first get all the rooms from the level description and randomly choose one of them to attach the secret room to. In Enter the Gungeon, they also choose whether to connect the room to a dead-end room or to any rooms - this is controlled with SecretRoomDeadEndChance. We can add a float SecretRoomChance field to the input setup and configure this value directly in the generator inspector. When we set up the input for the algorithm, we roll a die to determine if we want to add a secret room to the level. ![]() Var inputTask = (GungeonInputSetupTask) generator.CustomInputTask Įven though all the levels are primarily guided by hand-made level graphs, there is a bit of randomness included. Configure the generator with the current stage number Private IEnumerator GeneratorCoroutine(DungeonGeneratorGrid2D generator) Style.BackgroundColor = Color.Lerp(style.BackgroundColor, Color.black, 0.7f) Var backgroundColor = style.BackgroundColor Var style = base.GetEditorStyle(isFocused) Public override RoomEditorStyle GetEditorStyle(bool isFocused) Use the type of the room as its display name. We do not need any room templates here because they are resolved based on the type of the room.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |