Design your first theme

A theme file is a mapping between marker names (like Walls, Ground, Door etc) and the meshes that you provide. The prefabs you map here will be used to build your dungeon

_images/theme_editor_preview.jpg

In the previous section, we created a dungeon with an existing theme file (CandyDungeonTheme). In this section, we’ll create one ourselves

Create a Theme File

Create a new theme file from either the Main menu or the Create menu

_images/create_theme_01.png

Create from Main menu

_images/create_theme_02.png

Create from Create menu

This will create a theme file in the current open directory in the Projects window

_images/032.png

Open the Theme File

Double-click the theme file to open the Theme Editor. Dock the theme editor so you can see both the Scene view and the Theme Editor at the same time

_images/04.jpg

Assign the Theme File

Destroy the existing dungeon by selecting DungeonGrid game object and click Destroy Dungeon button

Assign the theme file that you just created, on to the DungeonGrid game object

_images/051.png

Click Build Dungeon and nothing should appear. That’s because we haven’t added prefab mappings on the theme yet

Design the Theme

Navigate to Assets\DungeonArchitect_Samples\Demo_Theme_Candy\Prefabs. This folder contains a set of mesh prefabs we can use for our dungeon

_images/06.jpg

Add Ground

Drag-drop the ground prefab mesh on to the Theme Editor

_images/071.jpg

Link up the mesh node with the Ground marker node. When you do, you should see a live preview on the scene view with the dungeon using this ground mesh

_images/081.jpg

For the live preview to work, make sure the “Realtime Update” button is enabled in the Theme Editor

_images/091.jpg

Another criteria for the live preview to work is that a dungeon in the scene should reference the theme that is currently being edited in the theme editor

Add More Prefabs

Go ahead and add prefabs under the following markers: Wall, Fence and Door

_images/104.jpg
_images/11.jpg

Add Wall Pillars

Drag drop the Pillar2 prefab to the theme editor and link it to the WallSeparator marker node

_images/12.jpg

We’ll need to make this pillar a bit bigger. Select the node you just dropped and modify the Scale parameter under Offset category

_images/13.jpg
_images/141.jpg

Add Windows

We have two wall meshes in the samples folder

_images/15.jpg

The other one (Wall2) has a window. Lets configure the theme to sometimes use this second mesh so we have windows

Drag drop Wall2 prefab on to the theme editor and place it before (left of) the existing wall prefab node

_images/161.jpg

When you connect this to the Wall marker node, you’ll notice it has picked up the window node for all the walls

_images/17.jpg

This is because Dungeon Architect starts executing the nodes from left to right. When the condition was satisfied to pick the first node, it stopped execution and never came to the second node.

There are multiple ways you can control this condition, the simplest being adjusting the probablity of selection.

Select the node you just dropped and change the probability to 0.5 (this would mean it gets selected 50% of the time). The other 50% of the time, it would not be selected and the execution would then move to the next node, and hence selecting the non-windowed wall node

_images/181.png
_images/19.jpg

Half the walls have windows

Add Wall Decorations

There’s a photo frame prefab we’d like to attach to every wall

_images/20.jpg

Drag drop this prefab to the theme editor before the two existing nodes and link it to the Wall marker node

_images/21.jpg

This will cause all the walls to disappear and be replaced with this photo frame

_images/22.jpg

This is because once the photo frame was selected, the execution stopped and the the wall nodes further down the line were not executed.

Selected the photo frame and uncheck the flag “Consume on Attach”. This will cause the execution to continue further even though this node was selected by the theming engine

_images/23.jpg

Lets adjust the offset of the photo frame (position and rotation) to make it properly align with the inner walls

Select the photo frame node and change the position to (0, 2, -0.22) and rotation to (0, 180, 0)

_images/241.png

The photo frame is aligned with the walls

_images/25.jpg

Marker Emitters

We have an issue with the photo frames. They also spawn near windows

_images/26.jpg

Marker Emitters allow you to emit marker names from any of your dropped prefab nodes. This means, we can define a new marker node (e.g. MyWallDeco) and then emit that marker from the wall node that doesn’t have a window (Wall1 prefab). All our wall decorations can now go under this MyWallDeco marker and it will show up only near solid walls

Right click on an empty area in the theme editor and select Add Marker Node

_images/271.png

Select the node and change its name to MyWallDeco

_images/28.png

Break the link to the photo frame

_images/291.png

Connect this under MyWallDeco marker node. All the future wall decorations can also go under this marker

_images/301.png

Now emit this marker from the wall node that doesn’t contain a window

Drag a link out of the bottom of the solid wall prefab node and release the mouse in an empty area

_images/311.png
_images/321.png

You can follow the same method to create another type of decoration (e.g. MyWindowDeco) and emit it from under the windowed wall node. In this example, I’ve added a flower pot in the windows

_images/33.jpg

Align with Offset

Dungeon Architect can adapt to any modular asset regardless of the prefab pivot position. If the pivots are off, you can always adjust them from the Offset section of the node’s properties

Sometimes, it is difficult to line up the ground node, as there is no point of reference to compare with.

In that case, turn on Debug Draw and build the dungeon.

_images/341.png
_images/35.jpg

This ground asset has its pivot on the corner instead of the center. We’ll add an offset of position (-2, 0, -2) to fix it and align with the debug drawn boundaries

_images/36.jpg

It is important to first align the ground mesh and then use that as a reference to align your walls and fences. If the ground is not aligned correctly, the rest will also not align (since you will be using an incorrect point of reference for aligning the rest)

Recap

In this section we learnt the following:

  • Probablity - Controls the percentage chance of a node being selected. A value of 1 means 100% selection chance. A value of 0.25 means 25% selection chance

  • Execution Order - The theme engine executes all the nodes under a marker node from left to right. If it selects a certain node, it stops executing, unless the Consume on Attach flag is unchecked

  • Marker Emitters - You can create complex hierarchies with your own marker nodes, giving you more freedom to decorate your dungeons