Inventory Implementation - UQdeco2800/2022-studio-1 GitHub Wiki

The inventory consists of multiple sections, the equipment sections on the left half of the inventory, Artefacts are on the right-top side of the inventory and the Buildings are located at the right-bottom side of the screen.

Inventory Item display

Two main types of display are used in the inventory, the list form of represetation and the carousel form of representation.

List representation is used for Artefact Hashmap, where all the availble <Artefact, Amount> pairs are displayed to the player at once, the players can click the button next to the desired item and the effect will be applied immediately. The amount of items are directly pulled from the inventoryComponent, when the player uses an item, the useItem function will also be called, confirming that the selected item is available in the inventory and subtract the item from the inventory and returns a boolean. When true, the corresponding item ability function will be triggered.

image

The carousel representation is used for both equipment list and buildings list.

The carousel visually displays all the equipment previously owned by the player, and when the equip/disarm button is being pressed, the relevant json file will be brought up and read, and changes the relevant combatstat component accordingly.

image

Aside from the carousel, two slots are also reserved for the player's currently equipped weapon and armor, this is to allow the players to visaully see the changes in the inventory. Once equipment has been changed, the image displayed will also change accordingly.

the buildingList is a Hashmap like Artefact, but has the same carousel representation as the equipment list

image

All the available keys in the buildings are being displayed to the player, when the player pressed the place button, the structure will be placed at where the player is standing and when no more of the same building are available, it will be removed from the carousel.

UML diagram

Inventory drawio