-
Notifications
You must be signed in to change notification settings - Fork 9
Player Inventory
Player Inventory is used to switch between weapons and get details on the equipped weapon. The Player Inventory adds further levels of depth to the game by allowing the player to hold melee, ranged, and buildables in an easily accessible manner - with keyboard buttons 1
, 2
, and 3
to equip each respectively. Building from Sprint 2, an UpgradeDisplayComponent
was created to cater to UX design principles such as ease of use.
Weapons can be equipped by simply clicking on a weapon/buildable on the hotbar UI, or by using number keys 1
, 2
, or 3
to directly switch to a weapon or building hammer.
Equipped weapons can be switched or upgraded the upgrade tree, which can be accessed through the upgrade tree UI button on screen.
Stores functional weapon details like weapon type, available ammo and attack cooldown
InventoryComponent
class:
- convertSave: Converts the saved map into a map containing the item's slot, and assigned ammo.
- getSlotTypeMap: Returns a map containing the weapon's slot, and its type
- getConfigs: Gets weapon configs
- getEquipped: Gets the equipped weapon's assigned slot
- setEquipped: Changes active inventory slot to a specific slot
- replaceSlotWithWeapon: Replaces the specified slot with a given weapon
- getEquippedWMap: Returns a mapping of item and its respective slot
- getEquippedWeapons: Returns the current equipped weapons represented in an array
- changeEquipped: Updates active weapon.
- getEquippedType: Returns the equipped weapon type
- getCurrentAmmo: Get the currently equipped weapons current ammo
- changeEquippedAmmo: Changes the amount of ammo in current weapon slot by change
- getCurrentAmmoUse: Returns the amount of ammo the currently equipped weapon uses per shot
- getCurrentMaxAmmo: Returns the amount of max ammo for the current weapon slot
- getEquippedCooldown: Returns the remaining tick cooldown for the currently equipped weapon slot
- setEquippedCooldown: Sets the cooldown for the currently equipped weapon slot
- reloadWeapon: Relaods weapons after 2 seconds
- getReloading: Return if the weapon is being reloaded
InventoryComponent.InventoryItem
class:
Private class to store inventory items
- InventoryItem: Constructor to create inventory item
- getItem: Returns weaponType of inventory item
- changeItem: Updates inventory items weaponType
- getAmmo: Returns ammo count of inventory item
- changeAmmo: Updates available ammo for inventory item
- setMaxAmmo: Sets max ammo capacity of inventory item
- getMaxAmmo: Returns max ammo capacity of inventory item
- setAttackCooldown: Sets attack cooldown for inventory item
- getAttackCooldown: Returns attack cooldown for inventory item
- decCoolDown: Decreases attack cooldown for inventory item
InventoryDisplayComponent
class:
Displays a UI hotbar interface on the current equipped melee, ranged and building hammer.
- makeTable : Creates a table with three buttons, each button including a label and image specific to the currently equipped item in that slot.
- updateButtonTableColour : Changes each buttons colour based on whether it is equipped or not - greyed-out for unequipped, else normal.
- equipEvent : Is a listener function which updates the table if it detects an item change in any slot.
KeyboardPlayerInputComponent
class:
- triggerInventoryEvent: Updates player inventory based on user input; can cycle between weapons or equip a specific weapon.
PlayerActions
class:
- updateInventory: Updates Inventory.
Game: Counter Strike: Global Offensive
Note: updated as of 29/09/2023
From the Sprint 3 iteration of the Hotbar, there were found to be a few drawbacks. One of which was that the user had no clear idea of what items they had unlocked. The user was required to visit the upgrade menu to see what they currently have unlocked. Additionally, the user could only swap between items currently equipped in the respective slot. To allow the user to have a seamless experience, we adhered to UX design principles such as ease of visibility. In collaboration with Team 7, we implemented an unlocked items hotbar, which was inspired by popular existing solutions such as Minecraft or Terraria. The Hotbar is located centrally at the bottom of the screen and allows the user to see/switch to their items as soon as they're unlocked. This was implemented with an Observer design pattern, with the concrete observer being the Hotbar UI, and the subject being the Upgrade Tree, which notifies the Hotbar of any changes (new unlocks).
Inspiration; Minecraft hotbar
![](https://private-user-images.githubusercontent.com/94519823/276434363-a04523c0-6521-4718-add4-38eef3b6538c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0NDU2MjgsIm5iZiI6MTczOTQ0NTMyOCwicGF0aCI6Ii85NDUxOTgyMy8yNzY0MzQzNjMtYTA0NTIzYzAtNjUyMS00NzE4LWFkZDQtMzhlZWYzYjY1MzhjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDExMTUyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdkOWIzNTJiMTM1MmExYzliMTFhMGVmNjc0NWRjZGMyMzI0OTA4MTc2NjhkNGZiYTk2ZTJjODZkNzI3MzkyYTYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.E5DzRiRwKmqLBST8l86wDZ1fjN0HxHXe34xVSVeIX9s)
Sprint 4 Implementation: Ranged weapons equipped
PlayerInventory
and PlayerInventoryDisplay
have been tested in accordance with the Player Inventory Testing Plan
Escape Earth Game
Interaction Controller and Interactable Components
Game and Entity Configuration Files
Loading Game Configuration Files