refactor dialogue handling for various game entities

This commit is contained in:
2026-03-23 22:58:22 +01:00
parent 04c5192e0e
commit 8961dd0e1b
11 changed files with 98 additions and 49 deletions

View File

@@ -28,31 +28,32 @@ public class ChestObj extends Entity {
solidAreaDefaultY = solidArea.y;
}
public void setDialogue() {
dialogue[0][0] = "You open the chest and find a " + loot.name + "!\nBut your inventory is full...";
dialogue[1][0] = "You open the chest and find a " + loot.name + "!\nYou obtain the " + loot.name + "!";
dialogue[2][0] = "It's already empty...";
}
@Override
public void setLoot(Entity loot) {
this.loot = loot;
setDialogue();
}
@Override
public void interact() {
panel.gameState = GameState.DIALOGUE;
if(this.opened) {
panel.ui.currentDialogue = "It's already empty...";
startDialogue(this,2);
return;
}
panel.playSE(3);
StringBuilder sb = new StringBuilder();
sb.append("You open the chest and find a ").append(loot.name).append("!");
if(!panel.player.canObtainItem(loot)) {
sb.append("\nBut your inventory is full...");
panel.ui.currentDialogue = sb.toString();
startDialogue(this,0);
return;
}
sb.append("\nYou obtain the ").append(loot.name).append("!");
down1 = image2;
opened = true;
panel.ui.currentDialogue = sb.toString();
startDialogue(this,1);
}
}