Devlog 9: Corridor Node
This week’s focus shifted to the final piece in creating a functional dungeon layout, the CorridorNode class. Its primary role is to model the corridors connecting rooms, ensuring that the dungeon layout is traversable.
The CorridorNode class is a specialized type of Node that handles the generation of corridors between two room nodes, struct1 and struct2. These corridors connect different parts of a dungeon, ensuring navigability and logical flow.
The GenerateCorridor method determines the relative position of struct2 in relation to struct1. Based on whether the relative position is up, down, left, or right, it delegates corridor generation to ProcessRoomUpOrDown or ProcessRoomLeftOrRight. These methods identify valid neighboring points in the respective nodes and calculate the coordinates of the corridor. The process involves traversing child nodes using helper methods, identifying possible neighbors, and calculating valid X or Y positions for the corridor using geometric constraints. The result is a corridor that connects the two nodes dungeon structure.
Both the DungeonCreator and DungeonGenerator classes are then updated to accomodate corridors.
Reference List
Sunny Valley Studio. (2019). Unity 3d procedural dungeon generator. [YouTube playlist]. Available from: https://www.youtube.com/playlist?list=PLcRSafycjWFfEPbSSjGMNY-goOZTuBPMW [accessed 27 November 2024].