Saturday, 28 April 2018

Pickaxe Upgrades, Stamina, Consumables


A lot of the features that were mentioned in my initial design have now been implemented and now seemed like the appropriate time to add the win conditions. These win conditions meant adding a timer in game. I experimented with this timer, such as its size, positioning and different colouring. I settled on reducing the size of the milliseconds, and only displaying the appropriate values as necessary i.e. only displaying hours once the Player had been playing for more than one hour.

The win condition for this game was to add the ‘Motherload’, a golden block which is considered to be extremely valuable! Once the Player has collected this, a prompt is added one screen instructing the Player to visit the shop in order to turn it in. Turning this into the shop will end the game and transition the Player to the win screen. This is just a simply screen which tells the Player what their completion time was. This was a tricky solution to find as I didn’t know how to carry data across scenes. The solution to my problem was using a static variable which I found from the StackExchange forum user (Çetin, 17). In his post he explained that the best way to carry data between scenes is to store it on an object which isn’t destroyed when loading a new scene. This object contains a script of static variables. These variables can be accessed from any script without getting a specific reference to it, this is done by calling [script name].[variable name] which in my case, for example I would call PublicData.finalMinutes. Once the Motherload has been handed in, before the new scene is loaded, the timer is paused, and the time is passed from the timer to this script.

Thursday, 19 April 2018

Stamina, Pause Menu

Within the last week or so I have been working on implementing a stamina system. This stamina system gives the Player a reason to go back up to the surface and allows me to implement a use for the consumable items. Upon starting my development of this system, I outlined three potential interactions for this stamina system:

·         Stamina will drain at a steady rate over time.
·         Increased further when mining, even if not hitting a target ore.
·         Increased even more if the Player is actually mining a rock.

In order to get this system to work the way I wanted it to, some of the mining code needed to be restructured as I couldn’t get it to work with the current system. To implement this solution, I first needed to move all of the mining code off of the Player and into a new script. Not only was this for peace of mind and clarity, but also to segregate the process so that the logic could be more easily determined. I separated the mining code into three logical steps:

1.       Every frame, check if the Player is mining.
2.       If they are then run the MineRock() function, which fires a raycast.
3.       If the raycast hits nothing, then stamina will decay at a flat rate but if it did hit, then the decay rate will be determined by the rock that they are mining.







EDIT: shortly after implementing this change and submitting this post I noticed a bug with the stamina drain rate. The stamina decay rate was fluctuating constantly, sometimes it would drain quicker than normal. I couldn’t figure out the exact cause of this problem, but by moving stamina to its own script fixed this issue.

I have also implemented a pause menu as there was no way to pause / exit out of the game up to this point.

Monday, 9 April 2018

Pickaxe Upgrades, Consumables

In its current state, the game feels very… slow. Mining takes forever, especially when mining more valuable blocks. This progression through the game is intended, which is why the Player needs a way to upgrade their mining equipment so that they can mine blocks faster.

In this section I have added Player pickaxe upgrades which are buyable from the shop. I’ve given these upgrades some basic stats which will need to be more thoroughly tested once the game is in a stable condition -this also goes for the cost. One issue that I had with this system, although not necessarily a problem, is that the objects that are created must all be the same type in order to add them to the inventory. This is because the objects of the list are scriptable objects and aren’t subject to monobehaviours, therefore they don’t have a script attached to them and they don’t have their own behaviours. Because of this, I decided not to add them to any menu or inventory, but rather just display the pickaxe that the Player currently has equipped.















Another unintended repercussion of the inventory system are the consumables and ladders that I have added to the shop, which derive from the same script as the pickaxes and other consumables. These consumables are added to a list which is displayed on-screen in the upper-right hand corner of the screen. When used, the amount (which is stored on the object as quantity) is decremented by 1 for each item used. My solution is this problem, to distinguish which item was consumed is that each item has an enumerated ‘state’ which is defined as a category. Then whenever an item is bought from the shop, the item’s category is checked, which helps to determine the behaviour which will follow. For example, if it’s a pickaxe then the appropriate stats will be applied whereas if it’s a consumable or ladder then the quantity variable on the object is increased.

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...