Here is an example for a generation call using the fluent API and receiving the result asynchronously: And an example for a map generated from that call:
The DungeonGenerator class is a generic class that builds a map of any type that implements the interface ICell. You can
use the basic Cell implementation supplied with Karcero, inherit the Cell class or implement the ICell
interface yourself.
The ICell interface contains three basic properties, all of which will be filled during the map creation process:
The map is generated by creating a matrix of cells with TerrainType.Wall as their terrain, then running a series of map processors on it.
If you would like to extend the map generation you can implement the IMapProcessor interface which contains a single ProcessMap method
and adding it to the DungeonGenerator.
For example, let's say we want to place treasure as part of the map generation. Here's an implementation of a treasure placing processor:
And now just add it before calling generate:
There are many parameters that influence the map generation process. Following is a brief description of each one:
Parameter | Description | Type | Range |
---|---|---|---|
Height/Width | The map's size | Int | Larger than 0 |
Randomness | Controls how many twists and turns the dungeon contains | Double | 0-1 |
Sparseness | Controls how sparse the map is | Double | 0-1 |
Chance to remove dead-ends | Controls how many dead ends will be left in the map | Double | 0-1 |
Room width (min/max) | Room width size | Int | Larger than 0 |
Room height (min/max) | Room height size | Int | Larger than 0 |
RoomCount | Controls how many rooms should be generated | Int | 0 or larger |
There are several ways to use Karcero:
PM> Install-Package Karcero
If you encounter any issues please post them to repository. If you would like to contribute or collaborate contact me here.
Huge Map | 10 Rooms | 15 Rooms | 20 Rooms | 25 Rooms | 30 Rooms | 35 Rooms | 40 Rooms |
---|---|---|---|---|---|---|---|
Small Rooms | 112 | 133 | 121 | 131 | 127 | 145 | 148 |
Medium Rooms | 109 | 112 | 119 | 129 | 142 | 144 | 148 |
Large Rooms | 118 | 127 | 114 | 123 | 142 | 141 | 149 |
Large Map | 10 Rooms | 15 Rooms | 20 Rooms | 25 Rooms | 30 Rooms | 35 Rooms | 40 Rooms |
---|---|---|---|---|---|---|---|
Small Rooms | 14 | 15 | 17 | 18 | 19 | 20 | 22 |
Medium Rooms | 14 | 16 | 20 | 22 | 29 | 35 | - |
Large Rooms | 16 | 19 | - | - | - | - | - |
Medium Map | 10 Rooms | 15 Rooms | 20 Rooms | 25 Rooms | 30 Rooms | 35 Rooms | 40 Rooms |
---|---|---|---|---|---|---|---|
Small Rooms | 7 | 8 | 8 | 10 | 11 | 12 | 16 |
Medium Rooms | 8 | 11 | - | - | - | - | - |
Large Rooms | - | - | - | - | - | - | - |