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.

Monday, 22 January 2018

Mining, few tweaks


The next step is to implement a mining system allowing players to mine rocks. This feature, unlike the previous, is going to be quite challenging. I have been looking around on the internet for help sources and have found very little, therefore a lot of the implementation will come from experimentation.

I am going to treat the ore blocks like enemies to the Player, this will make the implementation easier and I will use ‘health’ as a way of determining the rock’s state. I will incorporate this with the work that I have just done for Unit 603 – Using AI in Computer Games, to which I created a working state machine system. These states can help me to determine the physical state of each rock as it gets damaged, and I’m hoping to be able to use these states to change the sprite.

EDIT - 27/01/2018: Update!
I have implemented the mining part of the system. There is currently no interaction, but there is collision being detected. The solution I found was to fire out a Ray-cast in the direction that the player is facing (determined by movement input). The hit data of the Ray-cast is stored in a variable, which I am currently using to log the name of the object hit to the console. One problem that I have come across is that I’m not sure how to deal with the animations. I believe that I would need to create a totally new set of animations for if the player is walking and mining at the same time. To combat this, as it looks strange, I have made it so that the Player can only mine when not moving (mining interrupts movement).
I also added a nice sky background to the level that I made in GIMP. It was created using a simple gradient of blue to white. Furthermore, the camera now finds the Player in the scene at game start and follows him around. There’s a bit of smoothing time, the camera ‘lags’ behind the Player, I’ve done this because I find that it’s easier on the eyes if the player isn’t always in the centre of the screen. For the duration of the next week, I will be working on implementing the second part to the mining: applying damage to the rocks.

Monday, 8 January 2018

First level, Player Character and Animations


Figure 1
 The first step for this week’s goal was to think of a way to implement my level. At first, I thought that my only option would be to drag and drop each individual sprite into the level. Not only would this have been very time consuming, but it would have also meant that editing the level would have been a lot of effort. This is when I stumbled upon a great tutorial by YouTube user quill18creates. This method involves creating a single sprite, with individual pixels representing the colour of the object which will be placed in world space. An array is made storing all 32-bit colour values (RGB 0 – 255) and it searches the sprite for those colours. These colours each correspond to their own prefab, which will be instantiated, depending where the colour was on the sprite. The sprite that I have created is shown below (fig. 1):
Figure 2
I created the sprite with colours that correspond to their respective ore colours, that way it’s easier to see which ores will spawn at which locations.

Figure 3
To make this work, I had to import all my sprites, creates prefabs out of them (a prefabricated object which acts like a mould / template) and then drag them into the array elements in the Unity inspector. For each of the ores I added a box collider so that it can detect collisions. This allows the player to stand on them and will be used when the mining mechanic is implemented.

Once the level was in place it was time to implement the Player Character and animations. This will enable me to be able to walk around my newly implemented level and open doors to some of the more juicer programming. Implementing the character was easy using the animation and animator windows within Unity.



The animator tool uses ‘States’ and ‘Parameters’ to work. States are the current form or standing that the object is in, while the parameters are conditions which help to transition between those states. I found that these states work better if there is a ‘base’ state – by which I mean a state which is default, has no animations attached to it, and can transition to any state depending on whether the parameters have been met, for this I called it ‘Player_Idle’. After creating the ‘Player_Walk’ animation (fig. 3), I simply then dragged this animation into the animator window and added the parameter of ‘isIdle’, which will transition to the walk state if it’s false. The final step was to add the code for the movement and voila! Our player can now move around the level!

Friday, 22 December 2017

Laying the Foundations


My goals for the first week were to lay down the foundations for the project. This was anything from setting up any folders that I might need, to creating my first scene. This scene is going to be used as a ‘landing screen’ -meaning that it’ll be the first screen that the player sees when the game starts. From here, they will be able to start or quit the game, and possibly even change options such as sound and screen resolution.



I’ve set up a basic start menu with button functionality. Clicking any of these buttons highlights then and runs its appropriate function (see appendix).


Thursday, 7 December 2017

Starting the Development - Introduction


The posts from this point forward will be about the development of the game. Over the past few weeks I’ve researched the game that I would like to create, and now I must put that into practice. For the entirety of this project, I will be learning new and exciting things about the world of programming. I have chosen to develop my project in Unity, using C#.

Each post that I create will contain the features that I have implemented from a summary point of view. I would like you to bear in mind that the development process won’t be as straightforward as portrayed in my posts, but I will do my best to document the struggles I have encountered along the way. I expect this project, Mini Miner, will be a great challenge given the time frame.

During the course of this year I will be researching mainly from two sources: a course that I have purchased on Udemy, and also the YouTube user GamesPlusJames. The Udemy course will be a great step towards learning the basics of the programming language, and once I have this knowledge I will be doing research on GamesPlusJames’ YouTube playlist titled “Learn to make an RPG game & learn C#”. The next week or so I will be starting my research before the actual development begins.

References to all help sources will be posted at the end of the blog, upon completion of the project.


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