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

generationConfig DungeonGenerationConfig Configuration related to the generation of the dungeon
mapConfig DungeonMapConfig Configuration related to the map of the dungeon
renderConfig DungeonRenderConfig Configuration related to the rendering of the dungeon
journeyRendererFULL version only JourneyRenderer 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

MapCamera Camera ReadOnly
Gets the map camera.
LevelsFULL version only List<Level> ReadOnly
Gets the Levels generated by this Dungeon
LevelLITE version only Level ReadOnly
Gets the Level generated by this Dungeon
LowestCoordinateFULL version only Point ReadOnly
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)
HighestCoordinateFULL version only Point ReadOnly
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)
Generated bool ReadOnly
Indicates whether this Dungeon is generated.
JourneyFULL version only Journey Gets or sets the journey.
JourneyGoFULL version only GameObject ReadOnly
Gets the journey game object. Will return null if the Dungeon is not generated.
GeneratedSpawnableTypes List<SpawnableType> ReadOnly
Gets the generated spawnable types in the Dungeon. Will return null if the Dungeon is not generated.
RoomsWithFilledDungeonConnectors List<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.

Methods

GenerateDungeon
public bool GenerateDungeon();
Return
bool True 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
deleteReport bool If 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
worldPosition Vector3 A world position (local position will not work)
Return
bool True 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
worldPosition Vector3 A world position (local position will not work)
Return
Room The 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
levelName string Name of the Level to search for.
Return
Level The 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
spawnableType SpawnableType The SpawnableType that counted Spawnable must have
Return
int The 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
spawnable Spawnable The Spawnable to count.
Return
int The 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.