obstacles and chest loot

This commit is contained in:
2025-12-13 00:44:53 +01:00
parent 1d6f53a70e
commit 825b084a68
11 changed files with 169 additions and 38 deletions

View File

@@ -2,6 +2,7 @@ package de.miaurizius.jgame2d.entity.item;
import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.core.enums.EntityType;
import de.miaurizius.jgame2d.core.enums.GameState;
import de.miaurizius.jgame2d.entity.Entity;
public class KeyObj extends Entity {
@@ -11,9 +12,24 @@ public class KeyObj extends Entity {
name = "Normal Key";
description = "[" + name + "]\nIt opens a door.";
type = EntityType.ITEM;
consumable = true;
down1 = initEntitySprites("objects/key");
price = 50;
}
@Override
public void use(Entity entity) {
panel.gameState = GameState.DIALOGUE;
int objIndex = getDetected(entity, panel.obj, "door");
if(objIndex == 999) {
panel.ui.currentDialogue = "What are you doing?\nThere is no door nearby.";
return;
}
panel.ui.currentDialogue = "You used a " + name + "!\nThe door is now open.";
panel.playSE(3);
panel.obj[panel.currentMap.getIndex()][objIndex] = null;
entity.inventory.remove(this);
}
}