finished dialogue system
This commit is contained in:
@@ -33,7 +33,20 @@ public class Entity {
|
||||
}
|
||||
|
||||
public void setAction() {}
|
||||
public void speak() {}
|
||||
|
||||
public void speak() {
|
||||
if(dialogue[dialogueIndex] == null) dialogueIndex = 0;
|
||||
panel.ui.currentDialogue = dialogue[dialogueIndex];
|
||||
dialogueIndex++;
|
||||
|
||||
switch(panel.player.direction) {
|
||||
case UP -> direction = Direction.DOWN;
|
||||
case DOWN -> direction = Direction.UP;
|
||||
case LEFT -> direction = Direction.RIGHT;
|
||||
case RIGHT -> direction = Direction.LEFT;
|
||||
}
|
||||
}
|
||||
|
||||
public void update() {
|
||||
setAction();
|
||||
collisionOn = false;
|
||||
|
||||
@@ -29,8 +29,8 @@ public class OldManNPC extends Entity {
|
||||
|
||||
public void setDialogue() {
|
||||
dialogue[0] = "Hello, lad.";
|
||||
dialogue[1] = "So you've come to this island to find the treasure?";
|
||||
dialogue[2] = "I used to be a great wizard but now... I'm a bit too old for taking an adventure";
|
||||
dialogue[1] = "So you've come to this island to \nfind the treasure?";
|
||||
dialogue[2] = "I used to be a great wizard but now... \nI'm a bit too old for taking an \nadventure";
|
||||
dialogue[3] = "Well, good luck on you.";
|
||||
}
|
||||
|
||||
@@ -45,18 +45,4 @@ public class OldManNPC extends Entity {
|
||||
if(i > 75) direction = Direction.RIGHT;
|
||||
actionLock = 0;
|
||||
}
|
||||
|
||||
public void speak() {
|
||||
if(dialogue[dialogueIndex] == null) dialogueIndex = 0;
|
||||
panel.ui.currentDialogue = dialogue[dialogueIndex];
|
||||
dialogueIndex++;
|
||||
|
||||
switch(panel.player.direction) {
|
||||
case UP -> direction = Direction.DOWN;
|
||||
case DOWN -> direction = Direction.UP;
|
||||
case LEFT -> direction = Direction.RIGHT;
|
||||
case RIGHT -> direction = Direction.LEFT;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -95,12 +95,19 @@ public class Player extends Entity {
|
||||
|
||||
public void interactNPC(int index) {
|
||||
if(index == 999) return;
|
||||
//if(!panel.keyH.spacePressed) return; //Only uncomment if text should only appear if player hits space
|
||||
panel.gameState = GameState.DIALOGUE;
|
||||
panel.npc[index].speak();
|
||||
panel.keyH.spacePressed = false;
|
||||
}
|
||||
|
||||
public void draw(Graphics2D graphics2d) {
|
||||
graphics2d.drawImage(parseSprite(), screenX, screenY, null);
|
||||
}
|
||||
|
||||
public void speak() {
|
||||
//This method only exists for character specific things later...
|
||||
super.speak();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user