Add loading dialogue

master
John 2022-06-19 14:31:19 -04:00
parent 7a63db1349
commit 80e5b90603
6 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,2 @@
Have you heard of the tragedy of
Darth Charlie the Wise?

View File

@ -0,0 +1,2 @@
Have you heard of the tragedy of
Darth Charlie the Wise?

20
saves/Level3-dialogue.txt Normal file
View File

@ -0,0 +1,20 @@
$Villain
I am having a seizure.
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww

View File

@ -18,12 +18,16 @@ public class DialogueMenu extends TextBox implements Serializable {
public DialogueMenu(int y, int yHeight, Font font, BufferedImageWrapper portrait, boolean isNarrator) { public DialogueMenu(int y, int yHeight, Font font, BufferedImageWrapper portrait, boolean isNarrator) {
super(y, GamePanel.GAME_WIDTH - PORTRAIT_WIDTH - PADDING*3, yHeight, 0, font, null, null); super(y, GamePanel.GAME_WIDTH - PORTRAIT_WIDTH - PADDING*3, yHeight, 0, font, null, null);
PORTRAIT = portrait; PORTRAIT = portrait;
checkForNarrator();
this.isNarrator = isNarrator;
}
public void checkForNarrator() {
if (isNarrator) { if (isNarrator) {
newX = PORTRAIT_WIDTH + PADDING*2; newX = PORTRAIT_WIDTH + PADDING*2;
} else { } else {
newX = PADDING; newX = PADDING;
} }
this.isNarrator = isNarrator;
} }
public void drawCenteredTextBox(Graphics g, String text, Color backgroundColor, Color textColor) { public void drawCenteredTextBox(Graphics g, String text, Color backgroundColor, Color textColor) {
@ -72,6 +76,7 @@ public class DialogueMenu extends TextBox implements Serializable {
} }
public boolean draw(Graphics g, String text, Color backgroundColor, Color textColor) { public boolean draw(Graphics g, String text, Color backgroundColor, Color textColor) {
checkForNarrator();
if (frameCounter >= FREQUENCY) { if (frameCounter >= FREQUENCY) {
frameCounter -= FREQUENCY; frameCounter -= FREQUENCY;
currentFrame += 1; currentFrame += 1;

View File

@ -1,7 +1,10 @@
import javax.imageio.ImageIO;
import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException; import javax.sound.sampled.UnsupportedAudioFileException;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
public class LevelManager implements Serializable { public class LevelManager implements Serializable {
public static int level = 1; public static int level = 1;
@ -34,6 +37,16 @@ public class LevelManager implements Serializable {
} }
try { try {
MapReader.inputMap(filePath); MapReader.inputMap(filePath);
GameFrame.game.dialogueArray = new ArrayList<String>(Arrays.asList(MapReader.inputDialogue(filePath)));
if (GameFrame.game.dialogueArray.get(0).contains("$Villain")) {
GameFrame.game.dialogueArray.remove(0);
GameFrame.game.dialogueMenu.isNarrator = false;
// TODO: move img path to GamePanel
GameFrame.game.dialogueMenu.PORTRAIT = new BufferedImageWrapper("img\\dialogue\\Bouncer.png");
}
GameFrame.game.dialogueMenu.currentFrame = 0;
GameFrame.game.dialogueMenu.frameCounter = 0;
GameFrame.game.isDialogue = true;
} catch (IOException | SpriteException | UnsupportedAudioFileException | LineUnavailableException e) { } catch (IOException | SpriteException | UnsupportedAudioFileException | LineUnavailableException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -109,6 +109,12 @@ public class MapReader implements Serializable {
x+=1; x+=1;
} }
} }
public static String[] inputDialogue(String mapFilePath) throws IOException {
String filePath = mapFilePath.replace(".txt", "-dialogue.txt");
return FileManager.readFile(filePath).split("\n");
}
public static void newTile(String filePath) throws IOException, SpriteException { public static void newTile(String filePath) throws IOException, SpriteException {
GameFrame.game.map[x][y]=(new SingleTile(TileX,TileY, new BufferedImageWrapper((filePath)))); GameFrame.game.map[x][y]=(new SingleTile(TileX,TileY, new BufferedImageWrapper((filePath))));
} }