-
Notifications
You must be signed in to change notification settings - Fork 1
Sprint 2 Inventory System and Consumables Functionality
The goal of this sprint was to complete the base features of the inventory, such as populating the inventory display with the correct items in the correct item slots, and extend functionality, such as offering item descriptions on hover. This sprint also saw the creation of the clue item, which will allow the player to use it to add guilt to an npc, or the time item, which will increase the countdown timer giving the player more time to complete their tasks.
Mermaid Scales -- 5 pieces
The design below is the key items throughout the whole storyline. These are the shattered scales from Nereus - the princess of Atlantis. There are some hidden message inside the scale, player has to collect these items and give them to Metis for identification.
Time Item - gif & png
The item below is a hourglass that will appear on map for players to collect and increase the time limit to avoid game over due to overtime.
Dive Suit
These items below is the set of gear for players to collect before going underwater during their journey . Players are not allowed to go underwater unless they have got complete suited.
Inventory System Layout
These are some layout design of the inventory system for players to view when they access the inventory page.
The current inventory display functionality has been updated since the last sprint. This included additions to allow for items to be populated in the inventory display proper, and changes made to how the player interacts with the inventory to use items. The inventory works by creating 2 rows of imagebuttons on a table, with each button set as an empty inventory slot. This is then updated according to the inventory hashmap to assign these imagebuttons to the item entities. Within the switch statement (of which 1 case is provided below for reference) this assignment is made to drawSlot1 (Inventory item slot 1) and attaches our listener to it. These listeners look for if the mouse is hovering over the item to display its item description, or if the item has been clicked, which removes the item from the inventory and applies its effects to the game.
private Table createInventory() {
//empty slot
Texture texture = new Texture(Gdx.files.internal("images/inventory/emptyInventorySlot.png"));
Drawable emptySlot = new TextureRegionDrawable(new TextureRegion(texture));
//Confirm down <a href="https://www.flaticon.com/free-icons/pixelated" title="pixelated icons">Pixelated icons created by Freepik - Flaticon</a>
Texture confirmTexture = new Texture(Gdx.files.internal("images/inventory/confirm.png"));
Drawable confirmDown = new TextureRegionDrawable(new TextureRegion(confirmTexture));
// instantiating buttons
ImageButton drawSlot1 = new ImageButton(emptySlot);
ImageButton drawSlot2 = new ImageButton(emptySlot);
ImageButton drawSlot3 = new ImageButton(emptySlot);
ImageButton drawSlot4 = new ImageButton(emptySlot);
ImageButton drawSlot5 = new ImageButton(emptySlot);
ImageButton drawSlot6 = new ImageButton(emptySlot);
ImageButton drawSlot7 = new ImageButton(emptySlot);
ImageButton drawSlot8 = new ImageButton(emptySlot);
ImageButton drawSlot9 = new ImageButton(emptySlot);
ImageButton drawSlot10 = new ImageButton(emptySlot);
// Get the entities existing in the game
Array<Entity> entities = ServiceLocator.getEntityService().getEntities();
// used to check each slot for its available item
int slotIncrement = 1;
// Implicitly going up. Should be done 1-10 for each inventory item
for (Map.Entry<Integer, Integer> entry : inventoryHashMap.entrySet()) {
Integer key = entry.getKey();
Integer value = entry.getValue();
for (Entity i: entities)
{
switch (slotIncrement) {
case 1:
// Check if the hashmap value is equal to the entity registered in the entity service to get the appropriate functionality
if (i.getId() == value)
{
Drawable buttonGraphic = new TextureRegionDrawable((i.getComponent(TextureRenderComponent.class)).getTexture());
drawSlot1 = new ImageButton(buttonGraphic, confirmDown);
//Hover popup for item description and Item slot click event
drawSlot1.addListener(new InputListener() {
//Shows item description when mouse hovers item slot
@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
showItemDescription(i);
}
//Removes item description when not hovering
@Override
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
destroyItemDescription();
}
//Uses the item once an item slot is clicked
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
useItem(i, key);
destroyItemDescription();
return true;
}
});
}
Once an item is clicked in the inventory display, the 'useItem' function is ran to determine what item has just been used and what effect function should be applied. Once a 'time item' is used, the useItem function then applies the 'consumeTimeItem' function as shown below. This function locates the time display entity and increases its countdown clock.
public void consumeTimeItem(Entity i, int key){
/// Funky locator magic to identify the entity that contains the time display
Array<Entity> entityLocator = ServiceLocator.getEntityService().getEntities();
for (Entity timeDisplay: entityLocator)
{
if (timeDisplay.getComponent(countdownDisplay.class) != null)
{
float increaseValue = i.getComponent(ConsumeableItemComponent.class).increaseTime();
(timeDisplay.getComponent(countdownDisplay.class)).increaseRemainingTime(increaseValue);
inventoryHashMap.remove(key);
destroyInventory();
}
}
}
This is one of the factories used to create items within the inventory.
public class ConsumableItemFactory extends ItemFactory {
private static int consumeableTimeIncrease = 30;
ConsumableItemFactory() {
super();
}
public static Entity createItem(Entity target, String texturePath) {
Entity item = createBaseItem(target);
item
.addComponent(new TextureRenderComponent(texturePath))
.addComponent(new ColliderComponent());
return item;
}
/**
* Creates a generic item to be used as a base entity by more specific item creation methods.
*
* @return entity
*/
private static Entity createBaseItem(Entity target) {
AITaskComponent aiComponent =
new AITaskComponent()
.addTask(new WanderTask(new Vector2(2f, 2f), 2f));
Entity item =
new Entity()
.addComponent(new PhysicsComponent())
.addComponent(new PhysicsMovementComponent())
.addComponent(new ColliderComponent())
.addComponent(new HitboxComponent().setLayer(PhysicsLayer.Item))
.addComponent(aiComponent)
.addComponent(new AddToInventoryComponent(PhysicsLayer.Item))
.addComponent(new ConsumeableItemComponent(getConsumeableTimeIncrease()));
PhysicsUtils.setScaledCollider(item, 0.9f, 0.4f);
return item;
}
public static int getConsumeableTimeIncrease() {
return consumeableTimeIncrease;
}
}
- 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