Tuesday, 16 October 2018

Implementing basic systems

Over the course of the past two weeks or so I've been working on implementing the basic versions of the systems that will be needed. This way it's easier to break tasks in to smaller tasks to knock out while adding features!

First thing I worked on after the Inventory is the battle system. Creating it in it's basic form was actually very simple. All you really need is a health variable for each enemy and to make attacks take away from that and destroy them when it reaches 0.

So, first thing I did was set up some of the UI and battle screen to get more of an idea of how to code it. I had already designed a rough template before, so it was very quick.

 
Some simple animation added to also make it a tiny bit more alive! 

After this was done, most of the work for it was done in a day, I made an enemy and a player class to feed stats in to. The players stats are stored as a saved PlayerPrefs value in unity, but there has to be an additional way to store the player's stats, at least for now, to allow the player to not lose their health through a battle and then load their save before the battle and still be down health!

The stats for enemies include a stat that determines how far their stats can range. For example, a ghost might have a health range of 7 and a health of 20, this means that when the monster is spawned for the battle, it can have 20 - 27 health.

For the basic system, the player only currently has a normal attack that is calculated from the strength and agility of the player divided by 2. This does flat damage to the enemy but will take in to account the weapon type, relevant player stats and relevant enemy defenses in the future (enemy damage already takes some of this in to account!)

 

Lastly, I implemented turns! This is well, pretty standard. Just some checks on whose turn it is, which is controlled by their variables player turn > is enemy 1 alive? if so, take turn > enemy 2 etc. There's more but I won't go in to too much detail for this one.



Ok, so next, between a few bug fixes and small changes, I worked on a pretty important thing to implement in to many systems - item rewards! 

The first way I implemented this is through a prefab that is created in the reward array script. The reward array is linked to by different event outputs so if the players choose a certain option during an event I can give them a specific reward. 

It starts with a function that creates a UI prefab for holding the items, and then feeding an item array in to the function which decides what items are given. This can be different depending on the option the player chose!


Most of the magic comes from the script attached to the item prefab. There's a few things it does; it pulls the item's data and puts it in the tooltip when hovered, gets rid of the tooltip when the item is no longer hovered and adds the item to the player's inventory when clicked (if there is any space in the inventory)


After this, it was a relatively small amount of work to implement this in to other systems. Between this time and now, I created very basic campfire, treasure and shop systems. Kinda drawing the rest of the owl here but there's more to do! I'm sure to talk about these new systems when I've added a bit more. For now feel free to take a look at the newest showcase!



Progress is a bit slower right now as I'm dealing with some personal problems. Looking forward, the next step is a lot of pollish and new features to the existing systems. Stay tuned!

No comments:

Post a comment