-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor inventory system
In sprint3, interacting with NPCs involves submitting relevant clue items to NPCs, which are not supported by the previous inventory system. Because in the previous inventory system, a unique id was not allocated to items in the game, the two existing items time item and scales were distinguished by different components bound to these two entities, which is very inconvenient. Therefore, the inventory system is reconstructed to achieve necessary functions.
First, we assign ids to each item in the game, and manage items in the form of configuration files. The path of the configuration file is configs/items.json.
{
"itemList": [
{
"class": "com.deco2800.game.components.player.entity.ConsumableItem",
"id": 1,
"name": "Time Item",
"description": "Time Item - This item can be used to increase the countdown clock!",
"textureLocation": "images/inventory/time_item.png"
},
.....
.....
.....
{
"class": "com.deco2800.game.components.player.entity.ClueItem",
"id": 9,
"name": "Mysterious Key",
"description": "Mysterious Key - This key can be used to win the game!",
"textureLocation": "images/KEY.png"
}
]
}
The configuration file will be read when the InventoryComponent is loaded, and each object in items.json will be serialized into an Item class object. In this way we combine the item's id, description and material path in one object. Compared with the previous inventory system, the information of an item is scattered in different classes, which improves the degree of aggregation of information and is more in line with the object-oriented idea.
I defined an Inventory interface to specify various basic functions that the inventory system should have. The InventoryComponent class and the Backpack class implement this interface. At the same time, the Backpack class is aggregated in the InventoryComponent class. In InventoryComponent class, the implementation of abstract methods in Inventory is to call the corresponding method in backpack property. In addition, in the add(int id) method, we have added log related operations before calling the method corresponding to the backpack. This uses the static proxy design pattern.
@Override
public boolean add(int id) {
boolean ret = backpack.add(id);
logger.info(backpack.toString());
return ret;
}
Before designing the Item class. I analyzed the possible types of items in the game, and finally divided the items into three types, consumable items, clue items and equipment items. At the same time, I also wrote instructions about adding new items to the game to help other students add new item in the future. Instructions on how to use the inventory system
For the display of inventory in the game, in the previous system, when the player picked up two identical items, two identical item icons would be displayed on the backpack interface. After the code refactoring, we can clearly know the library quantity of an item, so when there are multiple items of the same item, only one icon will be displayed and the number of the item hovered over by the mouse will be displayed in front of the item description.
- Uniform Pixel Grid Resolution
- Storyline
- Instruction
- NPC info
- NPC Communication Script
- Inventory-System-and-Consumables
- Storyline User Test
- Traitor Clues
- Game Characters
- Player Profile User Test
- Player Eviction Menu Sprint1: User survey (Team 7)
- Player Eviction Menu Sprint2: User survey (Team 7)
- Sprint3 - Win/lose Condition: User survey (Team 7)
- Sprint4 - Polishing-tasks: User survey (Team 7)
- Transition Animation/Special Effects/Sound Effects: Feature Overviews
- Transition Animation and Effects: Design Process & Guideline
- Sprint 4 User Testing
- Transition Animation & Effect: Code Guideline-Sprint4
- Sound effect when players complete npc tasks and hover over npc cards
- Fixing the clue bug
- Music Test
- Player Eviction Menu: Design Process & Guideline
- Player Eviction Menu (Feature Overviews)
- Player Eviction Menu: Code Guideline - Sprint1
- Sprint 1 User Testing
- Detailed Eviction Card: Design Process & Guideline
- Detailed Eviction Card: Feature Overviews
- Sprint 2 User Testing
- Player Eviction Menu: Code Guideline - Sprint2
- Sprint 2 Inventory System and Consumables Items User Testing
- Sprint 2 Inventory System and Consumables Items Functionality
- NPC interaction testing plan sprint3
- NPC interaction testing results sprint3
- NPC Dialogue Scripts
- Code Guideline
- Win/lose Condition: Design Process & Guideline
- Win/lose Condition: Feature Overviews
- Sprint 3 User Testing
- Win/lose condition: Code Guideline - Sprint3
- Enemy List
- User Testing 1: Enemy Image Filter
- User Testing 2: Enemy Animation and AI
- User Testing 3: Basic Attack