refactor dialogue handling for various game entities
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user