Development: Turn-Based Combat
I’m at the early stages of development, so Pop Art is sadly lacking Art, but I’m already happy with the systems I’ve been coding.
Over the last 6 months I dedicated more time into improving my C# and Unity skills, so that I could come into a larger project fully equipped. What that means is Pop Art is implementing state machines to track activity. This greatly improves the scalability of this project and I can already see that in early testing.
In the example below I’ve implemented a Battle Manager, Turn Manager, and relevant state machines for both to track which Entity is active and if it is the Player’s turn or the Enemy’s turn.
Each object in the scene inherits from an Entity script and each Entity will also have a Stats script.
The Turn Manager will find all Entities in the scene and pull their initiative from their Stats script. It will then sort a turn order list from highest to lowest. The Entity with the highest initiative will go first and continue until all Entities have taken a turn.
Whenever the Turn Manager activates an Entity on the turn order list it will check if they are an enemy. Depending on the result, the Battle Manager will be called to change the battle state to either the Player or Enemy being active. When one is the active state, the other will be in the idle state. This keeps scripts independent since we only need to check which state is active when attempting to invoke player or enemy functions.
This system is also recognizing each Entity as distinct objects, so each Entity will be able to have their own turn, states, turn, actions, ailments, stats, etc. The player will be able to control a party of distinct characters that will take actions on their own turns.