Thursday, 22 February 2018

Shop interface


Once the player approaches the shop, they are prompted to press ‘E’ to open the shop. This will then prompt then with an interface to either buy or sell. The buy menu is currently in place but has no functionality as this is a slightly larger job than the ability to sell.
Upon clicking sell, the interface updates to a selling screen. Slots dynamically appear based on the items currently in the Player’s inventory.














(Fig. 2) shows what the slots look like and as can be seen, the player has two items in their inventory, which have loaded into the shop interface. Upon clicking the ‘Sell’ button underneath any of the items, the items will be removed from the inventory and the player will granted an amount of gold depending on the items worth. With the addition of the shop, the player can now mine and sell ores. The next task for me is to give the player a way to navigate the level, as currently when they dig down there is no way to get back up. This ties in with getting the buy menu updated, as it’ll give me an item to use as a placeholder.


Figure 2

Wednesday, 7 February 2018

Inventory System, Inventory UI


Implementing the inventory system proved to be a far larger challenge than I had anticipated. First off, I had no idea where to start… After doing a bunch of google searches I realised that the code I was about to deal with just shot up in difficulty from beginner to intermediate. Suddenly I was looking at loops and wondering how to make head nor tail of it all. This is when I stumbled upon YouTube user GameGrind, and his playlist on an inventory system.

After tweaking and playing with the fully built system, there were still parts of it that I didn’t understand, and there’s no use implementing a system that I don’t understand cause after all, if I want to modify it in the future then I’m not going to know where to start. This however did give me a much greater understanding of loops, and how object data is stored.
Using this knowledge, as well as a helping hand from YouTube user Brackeys -and his tutorial on scriptable objects, I was able to put together an inventory system that worked, one that I fully understand and one that I am happy to move forward with. One of the issues that I ran into was with the UI system. It felt strange clicking play and seeing the inventory, already open. To change this, I disabled the objects in the scene using gameObject.SetActive(false) although this issued an error. It turns out that this completely disables an object, therefore any scripts attached to said objects cannot be accessed. I did however find a workaround, thanks to Unity Forum user akingdom. The workaround was to add a canvas group to the inventory UI with an alpha of zero and making it noninteractive. This means that anything tied to the canvas group would be fully transparent and couldn’t be clicked on.

The short version of how my inventory system works is that I create a scriptable object of the ore that I want, attach it to the ore prefab and then when mined, the object will be added to a list along with all the data that the object holds. This means that at any given time, each slot in the inventory can be accessed, along with data such as quantity, whether it stacks with other objects etc.
The game now also contains a working UI system that the player can open and close, keeps track of how many items the player has can restricts the amount that they can hold. In addition, I added a cash variable and display ready for the next major update: the shop.

In its current state, the Player can mine ores but has nowhere to take them. This leads the next stage of development to a shop where the player can trade in their ores to purchase equipment upgrades.

Thursday, 1 February 2018

Ores Take Damage, Ore Animations


In the last part of this project I implemented the mining and animations and it was now time to move onto the damaging of the ores. To implement this system, I used a similar system that I used in Unit 603, which was a override method. All ore blocks inherit from an empty script called HealthManager. This allows me to set individual stats up within an ore’s script, and then these values can override the method within the HealthManager script.
The challenge with this part was figuring out the best way to apply damage, and this was the best way that I could see fit. I also implemented the state system, and each state represents 20% of the ore’s health. At each state I set the sprite to change to a cracked or even more cracked version of the current sprite. My reason for using states is that it allows me to add events further down the road, such as explosions from the ore, or gems / valuable items dropping / being found. If I choose to implement this, it will come after the core elements of gameplay have been implemented.

Speaking of core elements of gameplay, this leads me onto the next development that I will be working on; the inventory system. At this current state of the game, the player can mine the ore, but it’s only being destroyed. This means that I need an inventory system so that the ores can be stored, to later be sold to the shop. My next post will demonstrate how I’ve come to implement the inventory system.

Download the game and Project Files!

The project files along with any additional documentation are located in this folder on my Google Drive. To download the game please down...