Dungeon
Class in ChivalrousGames.DungeonMaster / Inherits from: MonoBehaviour

Description

This is the main element in the Dungeon Master asset. It ties everything together. It is the starting point to generate the game. A Dungeon is made up of Levels. Levels are made up of Rooms. Rooms connect toward other Rooms, Levels and outside of the Dungeon via RoomConnectors, LevelConnectors and DungeonConnectors. Rooms are populated with Spawnables.

Fields

generationConfigDungeonGenerationConfigConfiguration related to the generation of the dungeon
mapConfigDungeonMapConfigConfiguration related to the map of the dungeon
renderConfigDungeonRenderConfigConfiguration related to the rendering of the dungeon
journeyCalculatorJourneyCalculatorFULL version only
The script responsible to calculate journeys on the map (sort of a GPS feature). Can be re sub-classed if another behavior is desired (DefaultJourneyCalculator is using a custom A* implementation). Added automatically on the Dungeon if the Dungeon Creation wizard is used.
journeyRendererJourneyRendererFULL version only
The script responsible to render journeys on the map (sort of a GPS feature). Can be re sub-classed if another behavior is desired (using Unity’s LineRenderer by default which isn’t great). Added automatically on the Dungeon if the Dungeon Creation wizard is used.

Properties

MapCameraCameraReadOnly
Gets the map camera.
LevelsList<Level>FULL version onlyReadOnly
Gets the Levels generated by this Dungeon
LevelLevelLITE version onlyReadOnly
Gets the Level generated by this Dungeon
LowestCoordinatePointFULL version onlyReadOnly
Gets the lowest coordinate of a Level in this Dungeon. This coordinate doesn’t need to have a Level assigned to it. ie: if a dungeon has two levels at coordinates: (0,1,0) and (1,0,0) the lowest level is (0,0,0)
HighestCoordinatePointFULL version onlyReadOnly
Gets the highest coordinate of a Level in this Dungeon. This coordinate doesn’t need to have a Level assigned to it. ie: if a dungeon has two levels at coordinates: (0,1,0) and (1,0,0) the highest coordinate is (1,1,0)
GeneratedboolReadOnly
Indicates whether this Dungeon is generated.
JourneyJourneyFULL version only
Gets or sets the journey.
JourneyGoGameObjectFULL version onlyReadOnly
Gets the journey game object. Will return null if the Dungeon is not generated.
GeneratedSpawnableTypesList<SpawnableType>ReadOnly
Gets the generated spawnable types in the Dungeon. Will return null if the Dungeon is not generated.
RoomsWithFilledDungeonConnectorsList<Room>ReadOnly
Gets the rooms with filled dungeon connectors. A filled DungeonConnector is a dungeon connector that was spawned during dungeon generation. Will return null if Dungeon is not Generated.
RoomsList<Room>ReadOnly
Gets all the rooms in the dungeon

Methods

GenerateDungeon
public bool GenerateDungeon();
Return
boolTrue if dungeon was generated successfully; otherwise, false.
Description
Generates the Dungeon with all its Levels, Rooms, Connectors, maps and Spawnables. It renders nothing.
Usage Example
public Dungeon dungeon;
void Start() {
	if (!dungeon.Generated) {
		dungeon.GenerateDungeon ();
		if(!dungeon.Generated) {
			Debug.LogError ("Dungeon was not generated successfully.", dungeon);
			return;
		}
	}
}
ResetDungeonGeneration
public void ResetDungeonGeneration(bool deleteReport);
Parameters
deleteReportboolIf true, will delete the dungeon generation report as well. For more information about the dungeon generation report, see DungeonGenerationConfig.
Description
Resets the dungeon generation. It is automatically called by GenerateDungeon also. This method is used to cleanup everything in the Dungeon and start over fresh.
RenderAll
public void RenderAll();
Description
Renders all levels. This should mostly be used for tests since rendering all levels at once will most likely be too heavy. Use a DungeonRenderer to manage rendering in your game.
UnrenderAll
public void UnrenderAll();
Description
Unrenders everything, should only be used as a rollback from RenderAll during tests.
UnrenderAllDetachedSpawnables
public void UnrenderAllDetachedSpawnables();
Description
Unrenders all detached spawnables of the Dungeon. For more information on Detached Spawnable, please see Spawnable.
IsPositionWithinDungeon
public bool IsPositionWithinDungeon(Vector3 worldPosition);
Parameters
worldPositionVector3A world position (local position will not work)
Return
boolTrue if worldPosition is located within a dungeon Room; otherwise, false.
Description
Verifies if a world position is located within the bounding box of a Dungeon Room. It will not verify the depth of walls and such, only the bounding box.
GetRoomByPosition
public Room GetRoomByPosition(Vector3 worldPosition);
Parameters
worldPositionVector3A world position (local position will not work)
Return
RoomThe Room that contains the worldPosition if any, or null if none.
Description
Gets the Room that contains the specified world position.
GetLevelByName
public Level GetLevelByName(string levelName);
Parameters
levelNamestringName of the Level to search for.
Return
LevelThe level that was found, or null if no level is found.
Description
Searches the Dungeon’s Levels for a specific one and returns it if found. Will return nothing if no level of the specified name is found.
GetDiscoveredLevels
public List GetDiscoveredLevels();
Return
List<Level>The discovered levels.
Description
Gets the discovered levels of the Dungeon. A Level is discovered when at least one of its Rooms is discovered.
CountGeneratedSpawnableWithType
public int CountGeneratedSpawnableWithType(SpawnableType spawnableType);
Parameters
spawnableTypeSpawnableTypeThe SpawnableType that counted Spawnable must have
Return
intThe total amount of Spawnables that were generated in the Dungeon that have the specified SpawnableType.
Description
Counts number of spawnables generated in the Dungeon with a specified spawnable type.
CountGeneratedSpawnable
public int CountGeneratedSpawnable(Spawnable spawnable);
Parameters
spawnableSpawnableThe Spawnable to count.
Return
intThe number of a specified Spawnable instances generated in the Dungeon.
Description
Counts number of a specified Spawnable instances generated in the Dungeon.
CollectAllJourneyCandidatesFULL version only
public List CollectAllJourneyCandidates();
Return
List<JourneyCandidate>The list of all journey candidates in the Dungeon.
Description
Collects all journey candidates. Candidates will all have at least one type that allows journey.