Zones, Levels, and LevelThemes are now implemented as described in the last post.  As with other things, my goal is to get infrastructures in place and fill them in later; so there are still a few loose ends to tie down, mostly things that I can’t easily do until other systems come online.  For instance, for now it just uses the first level in the zone definition rather than determining the ‘right’ one based on level number.  I’ll tie that one down when the game supports ascending/descending between Levels in a Zone.

Themes are working and although not fleshed out yet, it’s cool to see the infrastructure working.  Take the following example LevelThemes (defined in LevelThemes.xml):

  <LevelTheme Id="Dungeon" AmbientSounds="DungeonSounds">
    <MonsterClasses RefIds="MonsterClass3" />
    <CellAdornments RefIds="TortRack1, TortRack2, Lamp1, Lamp2" />
    <CellDefaults DefaultFloor="StoneFloor" DefaultWall="StoneWall" DefaultDoor="StoneDoor" />
  <LevelTheme Id="Cave" AmbientSounds="CaveSounds">
    <MonsterClasses RefIds="MonstClass8, AllSpiders" />
    <CellAdornments RefIds="SpiderWeb3, SpiderWeb2" />
    <CellDefaults DefaultFloor="DirtFloor" DefaultWall="DirtWall" DefaultDoor="DirtDoor" />

The values in the CellDefaults element define the Tiles to use for floors, walls, and doors (and more later).

You can then select which theme to apply to a Level, referenced by the Id tag above:

  <LevelDefinition Id="CaveFiller" ThemeId="Cave" Width="100" Height="100">
    <LayoutGeneration LayoutGenerator="Default"/>
    <RoomGeneration RoomGenerator="CaveRoomGenerator" SmallestPartitionSize = ".25"
                    MaxPartitionSizeRatio = "1.25" PercentOfSmallRoomsToNotSplit = ".1"
                    HomogeneityFactor = "0.25"/>
    <CorridorGeneration CorridorGenerator="CaveCorridorGenerator"/>

You then reference the Level (by Level Id from above) from within a Zone Definition:

  <ZoneDefinition Id="AbandonedMine" NumberOfLevels="20"
        Description="Kill the evil spider Tslith">
      <ZoneLevel LevelId="CaveFiller" Appears="Filler" LevelDepth="1-Bottom"/>
      <ZoneLevel LevelId="Tslith's Lair" Appears="1" LevelDepth="Bottom" />

Switching the ThemeId in the LevelDefinition from “Cave” to “Dungeon” changes the look-and-feel from this:

… to this:

Updated executable:

Source code: