Level

Class in ChivalrousGames.DungeonMaster / Inherits from: MonoBehaviour

Description

Usually represents a thematic area in a Dungeon. Levels are created by assembling Rooms.

Fields

generationConfig LevelGenerationConfig The generation config for this Level.
mapConfig LevelMapConfig The map configuration of this Level.
renderConfig LevelRenderConfig The render config for this Level.
NOTE: It would be a good idea to call the DungeonRenderer.Render right away if the LevelRenderConfig of the current Level (or its properties) changes.

Properties

GenerationRandom Random ReadOnly
Gets the generation random. This random is used to generate everything in the Level except for Spawnables.
SpawnRandom Random ReadOnly
Gets the spawn random. This random is used to generate Spawnables in the Level.
Rooms List<Room> ReadOnly
Gets the generated Rooms for this Level.
Generated bool ReadOnly
Gets a value indicating whether this Level is generated.
Dungeon Dungeon ReadOnly
Gets the Dungeon this Level belongs to.
MapGameObject GameObject ReadOnly
Gets the map game object.
MapCharacterPositionGameObject GameObject ReadOnly
Gets the map character position game object.
LowestCoordinate Point ReadOnly
Gets the lowest coordinate of a Room in this Level. This coordinate doesn’t need to have a Room assigned to it. ie: if a Level has two Rooms at coordinates: (0,1,0) and (1,0,0) the lowest coordinate is (0,0,0).
HighestCoordinate Point ReadOnly
Gets the highest coordinate of a Room in this Level. This coordinate doesn’t need to have a Room assigned to it. ie: if a level has two Rooms at coordinates: (0,1,0) and (1,0,0) the highest coordinate is (1,1,0).
LowestFloorNumber int ReadOnly
The lowest floor number, or -1 if level is not generated yet
HighestFloorNumber int ReadOnly
The highest floor number, or -1 if level is not generated yet
LevelWidth float ReadOnly
The width of the Level in real Unity units, or -1 if level is not generated yet
LevelHeight float ReadOnly
The height of the Level in real Unity units, or -1 if level is not generated yet
LevelDepth float ReadOnly
The depth of the Level in real Unity units, or -1 if level is not generated yet
IsDiscovered bool ReadOnly
Gets a value indicating whether this Level was discovered. As soon as one Room in this Level is discovered or visited, the Level is discovered.

Methods

GenerateLevel
public bool GenerateLevel(int dungeonGenerationAttempt);
Parameters
dungeonGenerationAttempt int The number of times the Level will try to generate itself before giving up at each Dungeon generation attempt.
Return
bool True if Level was generated successfully; otherwise, false.
Description

Generates the Level. Usually this is called by the Dungeon itself. There is no need to call this manually.

GetLevelLimitValueByDirection
public int GetLevelLimitValueByDirection(Direction direction);
Parameters
direction Direction The Direction for which the Level limit is requested. “None” Direction will throw an argument exception.
Return
int The Level limit value in a specified Direction.
Description

Gets the Level limit value by Direction. Based on the max sizes defined in the LevelGenerationConfig. The Level limit is the max or min Room index.

FindRoomsWithFilledLevelConnectorsFULL version only
public List FindRoomsWithFilledLevelConnectors();
Return
List<Room> The rooms with filled LevelConnector.
Description

Finds the rooms with filled level connectors.

FindRoomsWithEmptyLevelConnectorsFULL version only
public List FindRoomsWithEmptyLevelConnectors();
Return
List<Room> The rooms with empty LevelConnector.
Description

Finds the rooms with empty level connectors.

FindRoomsWithFilledDungeonConnectors
public List FindRoomsWithFilledDungeonConnectors();
Return
List<Room> The rooms with filled DungeonConnector.
Description

Finds the rooms with filled dungeon connectors.

FindRoomsWithEmptyDungeonConnectors
public List FindRoomsWithEmptyDungeonConnectors();
Return
List<Room> The rooms with empty DungeonConnector.
Description

Finds the rooms with empty dungeon connectors.

FindRoomsWithFilledLevelPositionedConnectors
public List FindRoomsWithFilledLevelPositionedConnectors();
Return
List<Room> The rooms with filled LevelPositioned DungeonConnector.
Description

Finds the rooms with filled level positioned connectors. Both LevelConnector and DungeonConnector can be level positioned.

GetRoomsPerSpawnableType
public Dictionary> GetRoomsPerSpawnableType();
Return
Dictionary<SpawnableType, List<Room>> Gets all Rooms per SpawnableType.
Description

Gets all Rooms per SpawnableType. This is useful to know in which Rooms Spawnables with a certain SpawnableType were spawned.

GetFloorNumber
public int GetFloorNumber(Room room);
Parameters
room Room The Room for which the floor number is requested.
Return
int The floor number or -1 if can’t be determined.
Description

The floor number on which a specified Room is located.

GetFloorNumber
public int GetFloorNumber(Point coordinate);
Parameters
coordinate Point The coordinate for which the floor number is requested.
Return
int The floor number or -1 if can’t be determined.
Description

The floor number for a specified coordinate is located.

GetFloorGameObject
public GameObject GetFloorGameObject(int floorNumber);
Parameters
floorNumber int The floor number for which the floor game object is requested.
Return
GameObject The floor game object if found; otherwise, null.
Description

Gets the floor game object. The floor game object is where room map game objects are found.

GetFloorGameObject
public GameObject GetFloorGameObject(Room room);
Parameters
room Room The Room for which the floor game object is requested.
Return
GameObject The floor game object if found; otherwise, null.
Description

Gets the floor game object. The floor game object is where room map game objects are found.

GetFloorGameObject
public GameObject GetFloorGameObject(Point coordinate);
Parameters
coordinate Point The coordinate for which the floor game object is requested.
Return
GameObject The floor game object if found; otherwise, null.
Description

Gets the floor game object. The floor game object is where room map game objects are found.

GetRoom
public Room GetRoom(Point coordinate);
Parameters
coordinate Point The coordinate for which the Room is requested.
Return
Room The Roomif found; otherwise, null.
Description

Get a Room by its coordinate in the Level.

GetRoomFromPresetRoomFULL version only
public Room GetRoomFromPresetRoom(PresetRoom presetRoom);
Parameters
presetRoom PresetRoom The PresetRoom for which the corresponding generated Room is requested.
Return
Room The Room that was generated following the configurations of the specified PresetRoom.
Description

Gets the Room that was generated following the configurations of the specified PresetRoom. Works when the Level is generated.

GetPresetRoomFromRoomFULL version only
public PresetRoom GetPresetRoomFromRoom(Room room);
Parameters
room Room The Room that was generated from the configuration of the requested PresetRoom.
Return
PresetRoom The preset room if any, or null.
Description

Gets the PresetRoom a Room was created from if any. Will return null if Room was not created from a PresetRoom.

GetDiscoveredOrVisitedRooms
public List GetDiscoveredOrVisitedRooms();
Return
List<Room> The discovered or visited Rooms of this Level.
Description

Gets the Rooms that are either discovered or visited in this Level.

CountGeneratedSpawnableWithType
public int CountGeneratedSpawnableWithType(SpawnableType spawnableType);
Parameters
spawnableType SpawnableType The SpawnableType with which generated Spawnable instances must be counted.
Return
int The number of Spawnable generated in the Level with a specified SpawnableType.
Description

Counts number of Spawnables generated in the Level with a specified SpawnableType.

CountGeneratedSpawnable
public int CountGeneratedSpawnable(Spawnable spawnable);
Parameters
spawnable Spawnable The Spawnable for which generated instances must be counted.
Return
int The number of Spawnable generated in the Level.
Description

Counts number of a specified Spawnable instances generated in the Level.

IsCoordinateValid
public bool IsCoordinateValid(Point coordinate);
Parameters
coordinate Point The coordinate to verify.
Return
true True if coordinate is valid (within the bounds of the Level); otherwise, false.
Description

Determines if coordinate is valid within this Level (between 0 and level max value for all axis) according to the LevelGenerationConfig.

IsPositionWithinLevel
public bool IsPositionWithinLevel(Vector3 worldPosition);
Parameters
worldPosition Vector3 A world position (local position will not work)
Return
bool True if worldPosition is located within a Level Room; otherwise, false.
Description

Verifies if a world position is located within the bounding box of a Level 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.