The Dungeon Generator project is a proof of concept. It uses pre-made rooms in a tree structure to create a different dungeon every time.
Each room contains a ‘scriptableObject’ detailing which doors are able to be connected to, at runtime it writes to a struct holding the same information. The helper functions attached to each rooms allow you to check whether a specific side is open, or the opposite side is open
The generation uses a two pass method:
Beginning with the ‘StartRoom’, the generator recursively creates rooms for each open door of the current room. Each time a ‘depth’ integer is passed down, ensuring that the depth from the origin is not exceeded.
Each of the room’s surrounding tiles are scanned to place doors where necessary, as well as place grass so the player has some context to the outside.
Each room evaluates the distance from it to the player and is hidden if it is too far away. To optimize the calculation the x and y distances are evaluated instead of the literal distance. Instead of using the square root the distance is squared to save computation time.