Devlog 3.1 Inventory System and Items


Devlog 3.1:Inventory System and Items

Devlog for the game 'Into the Mist', a game project/assignment for KIT109. 

Inventory System

In  'Into the Mist,' we implement an inventory system where the playersPlayer can carry around a bunch of items that they found in the dungeon.  For the inventory system, we add a Canvas object, which will be the Inventory UI (Figure. 1).  When the Player picks up an item, it will show on the inventory UI (Figure. 2). Players can use an item in the Player's turn. The code for the inventory system is primarily based on a YouTube tutorial video [1] [2]. How does the inventory system work?  When a player picks up an item (using onTriggerEnter2D in the script inside the item game object), a game object with a button component is Instantiate in the inventory UI, which can be used later   ( in the Player's turn). When an item is used, we count it as a player turn;

Figure. 1 Player inventory UI

Figure. 2 Player picking up an item

Items

At this point of the development, we only added 2 items, a healing potion and a normal sword. When healing potion is used, it will restore some of the player health (Figure. 3), then the health potion item will be destroyed as it has been used (Figure. 3). The code for this is largely inspired from YouTube tutorial video [1] [2]. The implementation of the sword mechanic is inspired by the movement script, with a bit of tweaking, we get our desired result. 

Figure. 3 Player picking up health potion and using it in the next turn. The health potion is destroyed after usage.
When selected, the sword item will spawn a highlighted tile to indicate where the user can choose to attack. If there is an enemy, it will proceed to attack the enemy (Figure. 5) and vice versa (Figure. 4). We also note that the sword item has a durability mechanic, which means, after a certain amount of usage, the item will be destroyed (Figure. 6) (note that this is a mechanic and feature of the game to make player decide on different scenario to force player's adaptability) .

Figure. 4 Sword item cannot be used when there is no enemy adjacent to the player (i.e., in the attack range of a sword)

Figure. 5 Player attack bat (an enemy) with sword item

Figure. 6 Sword item broke as durability reaches zero
We do note that Items and enemies will scale as you progress through out the dungeon. Health potion will increase more health,  sword item will deal more damage, and enemies will have scaling HP and damage.  

Alternative and Improvement Implementation

I want to make some improvements to the code in the future. In this current state of development, the item code could be more scalable for more extensive item selection. I want to redo all of the item and inventory code to make it more scalable and easier to maintain in the long run.

As to alternative implementations, there are a couple of different implementations I saw on YouTube and online forums; one that might be better is to make an 'enum' for all the items and a build-in inventory script/code under the player-manager script, which is more efficient and scalable for larger item pool. 

Feedback from Peer Review 

Most of the feedback is positive. The main thing that people point out is to describe each item and enemy so that users can plan how to approach a fight/plan their next move. To implement this, we will try to make a UI that pops up when a used mouse hovers over an item/enemy.  Right now, I am unsure if I have the time to implement this hovering mechanic, though making a person not know the description of an item/enemy can make it more challenging for a game, and that is what we aim for in the game design.

Reference

[1] HOW TO MAKE AN INVENTORY WITH UNITY & C# - BEGINNER TUTORIAL - 1/2. (n.d.). Www.youtube.com.

[2]  HOW TO MAKE AN INVENTORY WITH UNITY & C# - BEGINNER TUTORIAL - 2/2. (n.d.). Www.youtube.com. Retrieved May 11, 2024, from

Leave a comment

Log in with itch.io to leave a comment.