The kit generates random maps that follow a similar structure to those found in Slay the Spire. In this section, we will discuss how this feature works in detail and how you can customize it to the needs of your game.
There are three main elements to the configuration of a map:
- Configuration: The main configuration asset of a map. It specifies the different layers it has, the types of nodes available, the number of starting nodes and the number of pre-boss nodes.
- Layers: A layer is a level/height of the map. A map consists of several layers. You can specify the probabilities of the nodes of this layer to be of a certain type.
- Nodes: A node is an element located in a layer. A layer consists of several nodes. Examples of nodes would be: enemy, elite, boss, merchant, rest, treasure, etc. The kit only provides the enemy/elite/boss nodes by default and you will need to extend it to support any additional, custom nodes.
All these elements are Scriptable Objects that you can create by right-clicking on your Project view and selecting the appropriate Single-Player CCG Kit/Map option. Their data can be modified directly in the Unity Inspector.
The map feature lives in the Map scene. The most important game object in this scene is the one named Map and is composed of the following sub-objects:
- MapScreen: This object is responsible for initializing the scene, including the loading/saving of the relevant game data.
- MapGenerator: This object is responsible for actually generating a random map based on the specified configuration. The generated map is deterministic (i.e., given the same seed, the resulting map will always be the same).
- MapView: This object is responsible for rendering the map on the screen.
- MapTracker: This object is responsible for managing the player progression through the map.
The kit uses Unity's PlayerPrefs to store the seed of the randomly generated map and the player progression through it. You can find the relevant code in the MapScreen script.
Transitioning from the map screen to the battle screen
The transition from the map screen to the battle screen via the selection of a map node happens in the SelectNode and TravelToNode methods of the MapTracker script. These are also the methods you will want to extend when implementing your own, custom map nodes.