Since mid-March, I have been working on a prototype for Wrenches and Kings, a 2D Turn-based RPG.
At the beginning of the project, I wanted to start with adding the core functionality of the game first. I started with two scenes, an overworld and battle scene. The overworld would contain the player, levels, enemies, items and more. When the player collided with an enemy, they would move to the battle scene. The battle scene was setup to allow up to three enemies to be fought at once.
Implementing Battles
In order to understand how to start programming stats, the battle system and everything else, I looked at tutorials for turn-based combat. I began, and built most of my understanding off some Brackeys tutorials. With this, I understood the underlying processes to controlling and managing a turn-based combat system in unity.
My battle system started with 5 states: START, FINDTURN, PLAYERTURN, ENEMYTURN, and END. However, turns were simplified for both the player and enemy, and the system moved to 6 states: START, FINDTURN, UNITTURN, CHECKDEAD, WON and LOST. Start begins the battle, setting up variables and moving game objects into place, which moves into FindTurn, which looks for a unit to take a turn, UnitTurn, where an action takes place, and the CheckDead, which looks at which units in the battle have no health left. This cycles until all enemies are dead or until the player dies. (That was the plan)
With the battle system in place, I began setting up the player and the enemies. The player consisted of a movement script and a data script. The movement script handled controls while the data script stored information on the player.
In addition, enemy data and enemy movement scripts were created with a similar idea. These would pass information about the enemies into the battle scene. And with a battle manager in place, the player could run into enemies and be sent into battle.
From here, functionality needed to be added and the player needed to know what was going on. For the player, this was weapons and attacks, and for the enemies it was adding attacks and basic AI.
When the player has a weapon equipped, they are given attack options. The enemy has a set of attacks to choose from.
To help communicate what is happening to the player, a dialogue box and sliders were added to the UI. The dialogue box tells the player about their attacks and enemy attacks. The sliders indicate the turn order, and move back and forth (from left to right) according to each unit's cooldown.
This allowed combat to to be played through until the player died or all enemies were defeated, giving the bare minimum for combat. And at this time, the Items and Equip buttons were for decoration.
Inventory and Equipment
To add the rest of the functionality, an inventory needed to be added, which would track items, weapons and armour, as well as UI to display all the information. An item data class was implemented as well as the inventory to allow item tracking and usage (The inventory was populated test if it worked).
As I was in the process of making menus and items, I implemented equipment, being able to equip weapons and armour. As well as a status menu. (Look not final)
With equipment functionality, adding the ability to change equipment in battle was only a few more lines of code. Lastly, items needed to have effects and needed to be able to be used. An ItemEffect class was added that provided information on what effect and item should produce, certain items could be used outside of battle, while some can only be used in battle.
Overworld and Tilemaps
With a large portion of gameplay functionality added, I set about implementing the overworld more properly. At this point it was a flat surface of tiles the player could move around on.
The overworld would be implemented as 'layers' with different levels of an area able to be traversed by the player. Locations to move up and down through the environment would allow the player to traverse a faux 3D world. The layers above the player would fade out, while the layers below would darken and be taken out of view. The higher the layer the player was on, the further zoomed out the camera would be.
(The above gif shows the player moving up and down through what would be a tower)
Animations
At this point a lot of basic functionality was completed and most of the elements were static, nothing moved or animated. So, I added some animations to the menus and the battle.
Levels
Now that everything looks a little more 'alive' I've started building levels. At this point 'building' just means generally laying out how I would want to level to look.
For now that is where the project is at. All other information available on the project can be found on the Wrenches and Kings page under projects.
Comments