Preparation State
In this Battle State, from a ScriptableBattlePosition it will be possible to make enemy characters appear in certain positions of the board. The enemy created in a specific cell will be chosen randomly from a group of possible ones. Once created, the player will be able to buy, move and equip his own characters, until the time runs out, which will proceed to the next Battle State.
Create a Scriptable Battle Position
A Battle Position is a Scriptable Object that contains the positions of the cells where one of the members of a group of enemy characters can spawn. The character to spawn will be chosen at random.
The usual practice in this type of game is to place the ranged characters in the farthest part of the enemy, and the melee characters closer to the enemy. In this example we will make the following groups:
- A first group composed of Warriors and Monks, who may appear in the central ranks.
- A second group composed of Rangers and Wizards, who will attack from a distance.
1. Right click on a project folder and click on "Create/Auto-Battle Framework/BattlePosition/BattlePosition". This will create a new Scriptable Battle Position.
Create the Scriptable Battle Position.
2. Select the newly created Scriptable Battle Position. In its Inspector a grid similar to the battlefield will be displayed.
Scriptable Battle Position Inspector.
3. At the bottom is a list of Character Groups.
- Create a new Character Group, and add the Warrior and Monk Shop Character (WarriorShopItem and MonkShopItem).
- Create a second group and add the Shop Character of the Ranger and the Wizard (RangerShopItem and WizardShopItem).
Create two groups, containing Warrior and Monk Shop Character, and Ranger and Wizard Shop Character, respectively.
4. Select a cell that belongs to the enemy zone, for example, the one that is more centered. Once selected a dropdown will appear below, select Group 0. The image of the first character of the group will appear in the cell.
- This means that during the game, in a Preparation State with this Scriptable Battle Position, one of the characters belonging to Group 0 will be randomly selected and spawned in this same cell.
Choosing the cells to display characters from Group 0. Since there are melee characters, the cells closest to the center are chosen.
5. Similarly, we will choose the two corners farthest from the center, and select Group 1.
- Note that the image of the first member of Group 1 will now be displayed.
Choosing the cells to display characters from Group 1. Since there are ranged characters, the cells farthest to the center are chosen.
6. The Scriptable Battle Position is ready to be used in a Preparation State by adding it to the Battle Positions list.
Add the Scriptable Battle Position to the Battle Positions list of a Preparation State.
In the next section we will create a Preparation State, and use the Scriptable Battle Position created here
Create a new Preparation State
1. Right click on a project folder and click on "Create/Auto-Battle Framework/BattleStates/PreparationState". This will create a new Preparation State.
Create the Preparation State.
2. Select the newly created Preparation State. The following can be configured in its Inspector:
- Time: Duration of the state.
- Show in UI: If true, show the state in the Stage UI. Leave it unchecked.
- UI Prefab: Prefab that represents the image of the state. If Show in UI is disabled, attach the EmptyImage prefab, found in "Auto-Battle Framework/Prefabs/UI/EmptyImage" to avoid errors. Otherwise, you can use any prefab in the same folder. If you want to modify a prefab, we recommend you to make a duplicate of it (CTRL + D) and modify it from there.
- Battle Positions: List of Scriptable Battle Positions, where characters belonging to the enemy team will be spawned. One will be chosen at random. Add the Scriptable Battle Position created in the previous section to this list.
- Gold Per Round: Amount of currency earned at the beginning of this state.
- Interest Rate: Interest earned based on the amount of currency the player has at the beginning of this state. For example, if the Interest Rate is 0.1 and you have 20 gold, you earn 2 extra gold.
- Exp Per Round: Store experience gained at the beginning of this state.
Preparation State configuration. Add the previously created Scriptable Battle Position to the Battle Positions list.
3. The state is ready to be added to a Battle Stage. This is explained in detail in the section Creating a new Battle Stage.
Add the Preparation State to the Battle Stage.