Setup Key-Locks
In this section, we'll add a few key-locks to our dungeon using the flow framework
Open up the flow graph and assign the module database like before
![Ut 11 01 Ut 11 01](dungeon-architect-docs/ut-11-01.png)
Create Treasure Room
We'll create a treasure room that is attached to the main path. We do this by creating a new path (of length 1) that emits out of the main
path
Add a new Create Path
node and link it to the end as shown:
![Ut 11 02 Ut 11 02](dungeon-architect-docs/ut-11-02.png)
Select the node and inspect the properties
![Ut 11 04 Ut 11 04](dungeon-architect-docs/ut-11-04.png)
Set the Min/Max size to
1
since we want a single room to hold the keySet the path name to
treasure
. We'll use this id later to place a key hereStart from Path
is set tomain
so this room is connected to the main pathWe want the treasure room to be isolated and don't want it to converge back to another path. Leave the
End on Path
parameter blankChange the
Node Color
to anything you like
Hit Build
and you'll see a new treasure room created
![Ut 11 03 Ut 11 03](dungeon-architect-docs/ut-11-03.png)
Treasure Room Key/Lock
We want to lock the treasure
room and have the key somewhere in the main
path
Add a new Create Key/Lock
node and link it to the end like shown below:
![Ut 11 06 Ut 11 06](dungeon-architect-docs/ut-11-06.png)
Select the Create Key/Lock
node and inspect the properties
![Ut 11 07 Ut 11 07](dungeon-architect-docs/ut-11-07.png)
Key Path
- Since we want the key to be in the main path, set this tomain
Lock Path
- Since we want to lock the treasure path, set this totreasure
Key Marker Name
- We'll use the Theme Editor to spawn the key prefab. Set the maker name to anything you like, however you'll need to create a corresponding marker node with the same name in the theme file to spawn the key prefab. For this tutorial, set this toKeyYellow
Lock Marker Name
- We'll use the Snap Connection prefab to spawn the locked door prefab. Set the marker name to anything you like, however you'll need to create a corresponding mapping in the snap connection to spawn the locked door prefab. For this tutorial, set this toLockYellow
Hit Build
and inspect the layout graph
![Ut 11 05 Ut 11 05](dungeon-architect-docs/ut-11-05.png)
A blue lock item was created on the link that connects to the yellow treasure node. The key was placed somewhere in the main path (green). The red arrow shows the key-lock relationship
Main Path Key-Lock
We'll create another key lock for the main path. The key would be in the alt
path (orange) and the lock would be somewhere in the main
path (green).
Add a new Create Key/Lock
node and link it to the end as shown below:
![Ut 11 08 Ut 11 08](dungeon-architect-docs/ut-11-08.png)
Update the parameters:
![Ut 11 09 Ut 11 09](dungeon-architect-docs/ut-11-09.png)
Parameter | Value |
---|---|
Key Path | alt |
Lock Path | main |
Key Marker Name | KeyRed |
Lock Marker Name | LockRed |
Description | Main Path |
Hit Build
and inspect the layout graph
![Ut 11 10 Ut 11 10](dungeon-architect-docs/ut-11-10.png)
Spawn Keys
Setup Theme File
Open up the theme file we created earlier
![Ut 11 11 Ut 11 11](dungeon-architect-docs/ut-11-11.png)
![Ut 11 12 Ut 11 12](dungeon-architect-docs/ut-11-12.png)
Create a marker node ane rename it to KeyRed
![Ut 11 13 Ut 11 13](dungeon-architect-docs/ut-11-13.png)
![Ut 11 14 Ut 11 14](dungeon-architect-docs/ut-11-14.png)
Create another marker node and name it KeyYellow
![Ut 11 15 Ut 11 15](dungeon-architect-docs/ut-11-15.png)
We'll place our key prefabs under these.
Navigate to Assets\CodeRespawn\DungeonArchitect_Samples\DemoBuilder_GridFlow\Art\Prefab
and drop in the KeySkull_Red
and KeySkull_Yellow
prefabs on to the theme editor and link them up
![Ut 11 16 Ut 11 16](dungeon-architect-docs/ut-11-16.png)
![Ut 11 17 Ut 11 17](dungeon-architect-docs/ut-11-17.png)
With this mapping, we've defined what key prefab to spawn. Next, we'll create a placeable marker asset to define where to spawn these inside the modules
Create a Placeable Marker
Create a new placeable marker asset and name it PM_Keys
![Ut 11 18 Ut 11 18](dungeon-architect-docs/ut-11-18.png)
![Ut 11 19 Ut 11 19](dungeon-architect-docs/ut-11-19.png)
Select the PM_Keys
asset and inspect the properties
![Ut 11 20 Ut 11 20](dungeon-architect-docs/ut-11-20.png)
Add two markers
KeyRed
andKeyYellow
Set the Debug Color to yellow
Set the Debug Text to
Keys
Place Key Markers
Open up all your room modules and drop in the PM_Key
placeable marker asset, similar to what we've done with the enemy placeable marker in the previous section
Drop in at least 2 of these in a room, in case if both the Red
and the Yellow
keys spawn in the same room
![Ut 11 22 Ut 11 22](dungeon-architect-docs/ut-11-22.png)
Either move this placeable marker game object up by 1 unit (so the key doesn't spawn buried half into the ground), or move the key up in the theme editor by selecting the key nodes and moving it up at Y by 1 unit
Add to the other room modules as well
![Ut 11 23 Ut 11 23](dungeon-architect-docs/ut-11-23.png)
![Ut 11 24 Ut 11 24](dungeon-architect-docs/ut-11-24.png)
![Ut 11 21 Ut 11 21](dungeon-architect-docs/ut-11-21.jpg)
Recompile module database
Since we've modified the module's markers, we need to rebuild the module database cache
Select the module database and click Build Module Cache
![Ut 11 26 Ut 11 26](dungeon-architect-docs/ut-11-26.png)
The system now knows where to spawn the keys in the snap module and what prefabs to spawn at those locations
Spawn Locks
Locks are door prefab with locking support (optionally with different visuals based on your art asset)
We'll setup these locked door prefab in the snap connection
Open Snap Connection Prefab
Open the Snap Connection
prefab that we created in the earlier section
![Ut 11 27 Ut 11 27](dungeon-architect-docs/ut-11-27.png)
![Ut 11 28 Ut 11 28](dungeon-architect-docs/ut-11-28.png)
Inspect the properties of the prefab
![Ut 11 29 Ut 11 29](dungeon-architect-docs/ut-11-29.png)
Setup Locked Door
Similar to the way we've previously setup the one-way door, we'll setup two locked doors
Create an empty game object and rename it to LockRed
. Place it along side the Wall
, Door
and DoorOneWay
game objects
![Ut 11 30 Ut 11 30](dungeon-architect-docs/ut-11-30.png)
![Ut 11 31 Ut 11 31](dungeon-architect-docs/ut-11-31.png)
Reset the transform
![Ut 11 32 Ut 11 32](dungeon-architect-docs/ut-11-32.png)
We'll now register this game object as a locked door with the marker name as LockRed
Select the root Snap Connection object and inpect the properties
![Ut 11 33 Ut 11 33](dungeon-architect-docs/ut-11-33.png)
![Ut 11 34 Ut 11 34](dungeon-architect-docs/ut-11-34.png)
Add a new entry to the Locked Doors array and set the marker name to LockRed
and assign the game object to it
![Ut 11 35 Ut 11 35](dungeon-architect-docs/ut-11-35.png)
Repeat the same for the yellow lock. Set the marker name to LockYellow
, create a new gameobject, reset the transform and assign it
![Ut 11 36 Ut 11 36](dungeon-architect-docs/ut-11-36.png)
Assign Lock prefabs
Navigate to Assets\CodeRespawn\DungeonArchitect_Samples\DemoBuilder_GridFlow\Art\Prefab
and drop in DoorLargeLocked_Red
prefab as a child of LockRed
game object
![Ut 11 37 Ut 11 37](dungeon-architect-docs/ut-11-37.png)
The alignment rules are the same like other doors. Reset the transform of the red door prefab and it should align correctly (red line should face outwards and the origin is in the bottom-center)
![Ut 11 38 Ut 11 38](dungeon-architect-docs/ut-11-38.png)
Do the same for the yellow lock.
Hide the LockRed
game object
![Ut 11 39 Ut 11 39](dungeon-architect-docs/ut-11-39.png)
Drop in the DoorLargeLocked_Yellow
prefab under the LockYellow
gameobject
![Ut 11 40 Ut 11 40](dungeon-architect-docs/ut-11-40.png)
The alignment rules are the same like other doors. Reset the transform of the yellow door prefab and it should align correctly (red line should face outwards and the origin is in the bottom-center)
![Ut 11 41 Ut 11 41](dungeon-architect-docs/ut-11-41.png)
Hide the LockYellow
game object
![Ut 11 42 Ut 11 42](dungeon-architect-docs/ut-11-42.png)
Build dungeon
Open the scene where we previously set up our dungeon. Rebuild the dungeon
Red lock guarding the main path:
![Ut 11 43 Ut 11 43](dungeon-architect-docs/ut-11-43.jpg)
Yellow lock guarding the treasure room:
![Ut 11 44 Ut 11 44](dungeon-architect-docs/ut-11-44.jpg)
Red Key:
![Ut 11 46 Ut 11 46](dungeon-architect-docs/ut-11-46.jpg)
Yellow Key:
![Ut 11 45 Ut 11 45](dungeon-architect-docs/ut-11-45.jpg)