This is a grid inventory inspired by games such as Path Of Exile, No Man's Sky, Escape From Tarkov or any other game that uses grid based inventory. The reason for this project is to learn how to use the Unity UI Builder, which is designed around building UI using HTML, UXML and CSS.
- Creating a grid based inventory system.
- Improving my UI skills and exploring newly implemented systems.
The inventory has a defined amount of inventory slots. This is defined by the width and the height. Items will fit within these slots and can occupy more than 1 slot. As shown in the example image the ammo item occupies 1 block while the assault rifle occupies 5x2 slots.
Items are created in the form of Assets (scriptable objects) and it is in the asset were we define details such as slot dimensions.
Items can move around inside of the Inventory to give access to the player to sort the inventory to their liking. This is important when the inventory gets full and the player needs to organize things to their liking. Given more time I would have liked to add sorting algorithms to aid the player in organizing the inventory automatically if they prefer that.
This is a quality of life feature added to the inventory system to once again give more sorting and organizing options to the player. Being able to rotate items opens a new dimension to sorting where the player can figure out tight corners to store items and create more space in their limited inventory. This feature would also help my yet to be added sorting algorithms to have more options.
With information provided from the Expansion and Scoring methods it is very easy to implement the algorithm now. The algorithm essentially creates board clones using the Expand method and rates them based on score. Finally picking the board that scored highest.
Items can be taken in and out of the containers and the containers take space in the main inventory. Containers are still items so they inherit everything an item has, such as having the ability to be moved around in the main inventory and to rotate.
The inventory is decent but it's not perfect. Flaws in the code are present. Given more time and knowledge I would have improved on this system drastically. The situation is that I was learning new things about the UI-Builder as I was coding it and this led to some systems not being built as efficiently as I'd like. With my improved UI-builder knowledge though I could easily rebuild this Inventory system but better and more proper.