improved map loading and custcene loading
This commit is contained in:
parent
489ddd6f28
commit
3f39e8b183
@ -1,6 +1,7 @@
|
||||
package ruscz.game.gameOfProd.Cells;
|
||||
|
||||
import ruscz.game.gameOfProd.Image.ImageCell;
|
||||
import ruscz.game.gameOfProd.Map.Map;
|
||||
import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
|
||||
|
||||
import java.awt.*;
|
||||
@ -10,16 +11,16 @@ public class Block extends Cell {
|
||||
private boolean paint;
|
||||
private String partial;
|
||||
|
||||
public Block(int x, int y, ImageCell imageCell, boolean paint) {
|
||||
public Block(int x, int y, Map map, boolean paint) {
|
||||
super(x, y, WindowOfFreeMove.CELL_SIZE, Color.BLUE);
|
||||
this.imageCell = imageCell;
|
||||
this.imageCell = map.getImageCell();
|
||||
this.paint = paint;
|
||||
this.partial = "";
|
||||
}
|
||||
|
||||
public Block(int x, int y, ImageCell imageCell, String partial, boolean paint) {
|
||||
public Block(int x, int y, Map map, String partial, boolean paint) {
|
||||
super(x, y, WindowOfFreeMove.CELL_SIZE, Color.BLUE);
|
||||
this.imageCell = imageCell;
|
||||
this.imageCell = map.getImageCell();
|
||||
this.partial = partial;
|
||||
this.paint = paint;
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
package ruscz.game.gameOfProd.Cells;
|
||||
|
||||
import ruscz.game.gameOfProd.Dialog.Dialog;
|
||||
import ruscz.game.gameOfProd.Image.ImageCell;
|
||||
import ruscz.game.gameOfProd.Inventory.InventoryManager;
|
||||
import ruscz.game.gameOfProd.Inventory.Item;
|
||||
import ruscz.game.gameOfProd.Map.Map;
|
||||
import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
|
||||
|
||||
import java.awt.*;
|
||||
@ -17,16 +17,16 @@ public class ChestCell extends InteractionCell {
|
||||
private boolean showItem;
|
||||
private boolean isActive;
|
||||
|
||||
public ChestCell(int x, int y, String inventory, Dialog dialog, ImageCell imageCell, WindowOfFreeMove window, boolean paint) {
|
||||
super(x, y, null, dialog, imageCell, window, paint);
|
||||
public ChestCell(int x, int y, String inventory, Dialog dialog, Map map, WindowOfFreeMove window, boolean paint) {
|
||||
super(x, y, null, dialog, map, window, paint);
|
||||
this.showItem = false;
|
||||
this.chestInventory = new LinkedList<>();
|
||||
this.isActive = true;
|
||||
fillChest(inventory);
|
||||
}
|
||||
|
||||
public ChestCell(int x, int y, String inventory, Dialog dialog, ImageCell imageCell, WindowOfFreeMove window) {
|
||||
super(x, y, null, dialog, imageCell, window, false);
|
||||
public ChestCell(int x, int y, String inventory, Dialog dialog, Map map, WindowOfFreeMove window) {
|
||||
super(x, y, null, dialog, map, window, false);
|
||||
this.showItem = true;
|
||||
this.chestInventory = new LinkedList<>();
|
||||
this.isActive = true;
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package ruscz.game.gameOfProd.Cells;
|
||||
|
||||
import ruscz.game.gameOfProd.Dialog.Dialog;
|
||||
import ruscz.game.gameOfProd.Image.ImageCell;
|
||||
import ruscz.game.gameOfProd.Inventory.Item;
|
||||
import ruscz.game.gameOfProd.Map.Map;
|
||||
import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
|
||||
|
||||
import java.awt.*;
|
||||
@ -12,18 +12,21 @@ public class DoorCell extends InteractionCell {
|
||||
private boolean isLocked;
|
||||
private boolean directionVert;
|
||||
private String sound;
|
||||
private String soundOpen;
|
||||
private String soundClose;
|
||||
private String soundLocked;
|
||||
private float volume;
|
||||
|
||||
public DoorCell(int x, int y, boolean directionVert, String message, Dialog dialog, ImageCell imageCell, WindowOfFreeMove window) {
|
||||
super(x, y, message, dialog, imageCell, window, true);
|
||||
public DoorCell(int x, int y, boolean directionVert, String message, Dialog dialog, Map map, WindowOfFreeMove window) {
|
||||
super(x, y, message, dialog, map, window, true);
|
||||
this.isOpen = false;
|
||||
this.isLocked = true;
|
||||
this.directionVert = directionVert;
|
||||
setSound();
|
||||
}
|
||||
|
||||
public DoorCell(int x, int y, boolean directionVert, ImageCell imageCell, WindowOfFreeMove window) {
|
||||
super(x, y, null, null, imageCell, window, true);
|
||||
public DoorCell(int x, int y, boolean directionVert, Map map, WindowOfFreeMove window) {
|
||||
super(x, y, null, null, map, window, true);
|
||||
this.isOpen = false;
|
||||
this.isLocked = false;
|
||||
this.directionVert = directionVert;
|
||||
@ -47,19 +50,31 @@ public class DoorCell extends InteractionCell {
|
||||
|
||||
private void setSound() {
|
||||
if (isOpen) {
|
||||
sound = "qubodup-DoorOpen01-changed.wav";
|
||||
sound = super.getSoundManager().getSoundMap().get("doorOpen");
|
||||
volume = -8.0f;
|
||||
}
|
||||
else if (!isOpen && !isLocked) {
|
||||
sound = "qubodup-DoorClose02-changed.wav";
|
||||
sound = super.getSoundManager().getSoundMap().get("doorClose");
|
||||
volume = -8.0f;
|
||||
}
|
||||
else if (isLocked) {
|
||||
sound = "doorLocked.wav";
|
||||
sound = super.getSoundManager().getSoundMap().get("doorLocked");
|
||||
volume = -10.0f;
|
||||
}
|
||||
}
|
||||
|
||||
// public void setSoundOpen(String soundOpen) {
|
||||
// this.soundOpen = soundOpen;
|
||||
// }
|
||||
//
|
||||
// public void setSoundClose(String soundClose) {
|
||||
// this.soundClose = soundClose;
|
||||
// }
|
||||
//
|
||||
// public void setSoundLocked(String soundLocked) {
|
||||
// this.soundLocked = soundLocked;
|
||||
// }
|
||||
|
||||
public boolean isOpen() {
|
||||
return isOpen;
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import ruscz.game.gameOfProd.Image.ImageDialog;
|
||||
import ruscz.game.gameOfProd.Inventory.InventoryManager;
|
||||
import ruscz.game.gameOfProd.Inventory.Item;
|
||||
import ruscz.game.gameOfProd.Map.Map;
|
||||
import ruscz.game.gameOfProd.Sounds.SoundManager;
|
||||
import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
|
||||
|
||||
import javax.swing.*;
|
||||
@ -19,29 +20,31 @@ public class InteractionCell extends Cell {
|
||||
protected ruscz.game.gameOfProd.Dialog.Dialog dialog;
|
||||
protected Scanner scanner;
|
||||
private ImageCell imageCell;
|
||||
private SoundManager soundManager;
|
||||
private WindowOfFreeMove window;
|
||||
protected boolean paint;
|
||||
private Timer timer;
|
||||
|
||||
public InteractionCell(int x, int y, String message, Dialog dialog, ImageCell imageCell, WindowOfFreeMove window, boolean paint) {
|
||||
public InteractionCell(int x, int y, String message, Dialog dialog, Map map, WindowOfFreeMove window, boolean paint) {
|
||||
super(x, y, WindowOfFreeMove.CELL_SIZE, Color.ORANGE);
|
||||
this.message = message;
|
||||
this.dialog = dialog;
|
||||
this.imageCell = imageCell;
|
||||
this.imageCell = map.getImageCell();
|
||||
this.soundManager = map.getSoundManager();
|
||||
this.window = window;
|
||||
this.paint = paint;
|
||||
}
|
||||
|
||||
public void startEvent() {
|
||||
if (message != null) {
|
||||
if (message.equals("error")) {
|
||||
if (message.contains("cutscene")) {
|
||||
final int[] i = {0};
|
||||
timer = new Timer(1000, actionEvent -> {
|
||||
errorEvent(i[0] +1);
|
||||
playCustscene(message,i[0] +1);
|
||||
i[0]++;
|
||||
});
|
||||
timer.start();
|
||||
readDialogFile(message);
|
||||
readDialogFile("empty");
|
||||
}
|
||||
else {
|
||||
window.setCanPersonMove(false);
|
||||
@ -203,39 +206,48 @@ public class InteractionCell extends Cell {
|
||||
}
|
||||
}
|
||||
|
||||
private void errorEvent(int i) {
|
||||
if (i == 1) {
|
||||
WindowOfFreeMove.setCanPersonMove(false);
|
||||
window.getForegroundPanel().setImageForeground("error");
|
||||
window.getForegroundPanel().setVisible(true);
|
||||
window.repaintCanvas();
|
||||
}
|
||||
else if (i == 3) {
|
||||
Map openspace = Map.findMapByName("openspace", window);
|
||||
window.getMapManager().setMap(openspace);
|
||||
openspace.getPerson().set(openspace.getSpawnPoint()[0], openspace.getSpawnPoint()[1]);
|
||||
openspace.getPerson().setDirectionSight(4);
|
||||
openspace.setIdExit(0);
|
||||
dialog.hideText();
|
||||
dialog.setText("Shit..");
|
||||
dialog.showText();
|
||||
}
|
||||
else if (i == 5) {
|
||||
window.getForegroundPanel().setVisible(false);
|
||||
dialog.hideText();
|
||||
}
|
||||
else if (i == 6) {
|
||||
dialog.setText("I have to take a break. It's lunch time anyway.");
|
||||
dialog.showText();
|
||||
}
|
||||
else if (i == 10) {
|
||||
dialog.hideText();
|
||||
WindowOfFreeMove.setCanPersonMove(true);
|
||||
}
|
||||
else if (i == 11) {
|
||||
window.getMusicManager().playMusic();
|
||||
window.getMusicManager().fadeIn(10);
|
||||
timer.stop();
|
||||
public void playCustscene(String name, int i) {
|
||||
try {
|
||||
File cutsceneFile = new File("src/main/resources/dialogs/cutscenes/" + name + ".txt");
|
||||
scanner = new Scanner(cutsceneFile);
|
||||
while (scanner.hasNextLine()) {
|
||||
String[] data = scanner.nextLine().split(" ");
|
||||
if (data[0].contains("<" + i + ">")) {
|
||||
if (data[1].contains("<text>")) {
|
||||
if (data[2].equals("null")) dialog.hideText();
|
||||
else {
|
||||
dialog.setText(data[2].replaceAll("-", " "));
|
||||
dialog.showText();
|
||||
}
|
||||
}
|
||||
else if (data[1].contains("<foreground>")) {
|
||||
if (data[2].equals("null")) window.getForegroundPanel().setVisible(false);
|
||||
else {
|
||||
window.getForegroundPanel().setImageForeground(data[2]);
|
||||
window.getForegroundPanel().setVisible(true);
|
||||
}
|
||||
}
|
||||
else if (data[1].contains("<personmove")) {
|
||||
WindowOfFreeMove.setCanPersonMove(Boolean.parseBoolean(data[2]));
|
||||
}
|
||||
else if (data[1].contains("<moveto>")) {
|
||||
Map map = Map.findMapByName(data[2], window);
|
||||
window.getMapManager().setMap(map);
|
||||
map.getPerson().set(map.getSpawnPoint()[0], map.getSpawnPoint()[1]);
|
||||
map.getPerson().setDirectionSight(Integer.parseInt(data[3]));
|
||||
map.setIdExit(0);
|
||||
}
|
||||
else if (data[1].equals("<music>")) {
|
||||
window.getMusicManager().playMusic();
|
||||
window.getMusicManager().fadeIn(10);
|
||||
}
|
||||
else if (data[1].equals("<end>")) {
|
||||
timer.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,4 +266,6 @@ public class InteractionCell extends Cell {
|
||||
public ImageCell getImageCell() {
|
||||
return imageCell;
|
||||
}
|
||||
|
||||
public SoundManager getSoundManager() { return soundManager; }
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package ruscz.game.gameOfProd.Cells;
|
||||
|
||||
import ruscz.game.gameOfProd.Dialog.Dialog;
|
||||
import ruscz.game.gameOfProd.Image.ImageCell;
|
||||
import ruscz.game.gameOfProd.Map.Map;
|
||||
import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
|
||||
|
||||
import java.awt.*;
|
||||
@ -9,8 +9,8 @@ import java.awt.*;
|
||||
public class TriggerCell extends InteractionCell {
|
||||
private boolean isActive;
|
||||
|
||||
public TriggerCell(int x, int y, String message, Dialog dialog, ImageCell imageCell, WindowOfFreeMove window) {
|
||||
super(x, y, message, dialog, imageCell, window, false);
|
||||
public TriggerCell(int x, int y, String message, Dialog dialog, Map map, WindowOfFreeMove window) {
|
||||
super(x, y, message, dialog, map, window, false);
|
||||
this.isActive = true;
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +38,11 @@ public class ImageCell {
|
||||
String[] mapInfo = data.split(" ");
|
||||
imageItem(mapInfo);
|
||||
}
|
||||
else {
|
||||
else if (data.contains("<cellmap>")) {
|
||||
String[] mapInfo = data.split(" ");
|
||||
loadCellMap(mapInfo);
|
||||
}
|
||||
else if (!data.contains("<soundmap>")) {
|
||||
String[] mapColumn = data.split(" ");
|
||||
for (int i = 0; i < mapColumn.length; i++) {
|
||||
mapBackground[i][j] = Integer.parseInt(mapColumn[i]);
|
||||
@ -46,7 +50,6 @@ public class ImageCell {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
loadCellMap(name);
|
||||
imageObjectset(name);
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("An error occurred.");
|
||||
@ -103,32 +106,24 @@ public class ImageCell {
|
||||
}
|
||||
}
|
||||
|
||||
public void loadCellMap(String file) {
|
||||
try {
|
||||
File mapFile = new File("src/main/resources/maps/" + file + "-cellmap.txt");
|
||||
Scanner scanner = new Scanner(mapFile);
|
||||
public void loadCellMap(String[] cellInfo) {
|
||||
if (cellMap == null)
|
||||
cellMap = new HashMap<String, Integer>();
|
||||
while (scanner.hasNextLine()) {
|
||||
String data = scanner.nextLine();
|
||||
String[] cellInfo = data.split(" ");
|
||||
if (cellInfo[0].equals("DOOR")) {
|
||||
Rectangle[] rec = new Rectangle[12];
|
||||
int CELL_SIZE = WindowOfFreeMove.CELL_SIZE;
|
||||
int count = 0;
|
||||
for (int i = 0; i < rec.length / 4; i++) {
|
||||
for (int j = 0; j < rec.length / 3; j++) {
|
||||
rec[count] = new Rectangle(CELL_SIZE * i, CELL_SIZE * j, CELL_SIZE, CELL_SIZE);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
imageDoor = new ImageDoor(cellInfo[1], rec);
|
||||
|
||||
if (cellInfo[1].equals("DOOR")) {
|
||||
Rectangle[] rec = new Rectangle[12];
|
||||
int CELL_SIZE = WindowOfFreeMove.CELL_SIZE;
|
||||
int count = 0;
|
||||
for (int i = 0; i < rec.length / 4; i++) {
|
||||
for (int j = 0; j < rec.length / 3; j++) {
|
||||
rec[count] = new Rectangle(CELL_SIZE * i, CELL_SIZE * j, CELL_SIZE, CELL_SIZE);
|
||||
count++;
|
||||
}
|
||||
else
|
||||
cellMap.put(cellInfo[0], Integer.parseInt(cellInfo[1]));
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
imageDoor = new ImageDoor(cellInfo[2], rec);
|
||||
}
|
||||
else
|
||||
cellMap.put(cellInfo[1], Integer.parseInt(cellInfo[2]));
|
||||
}
|
||||
|
||||
public void imageItem(String[] itemInfo) {
|
||||
|
||||
@ -56,8 +56,8 @@ public class Map {
|
||||
|
||||
public static Map loadMapFromFile(String name, WindowOfFreeMove window) {
|
||||
try {
|
||||
File dialogFile = new File("src/main/resources/maps/" + name + ".txt");
|
||||
scanner = new Scanner(dialogFile);
|
||||
File file = new File("src/main/resources/maps/" + name + ".txt");
|
||||
scanner = new Scanner(file);
|
||||
String firstLine = scanner.nextLine();
|
||||
String[] size = firstLine.split(" ");
|
||||
TypeOfCell[][] mapArray = new TypeOfCell[Integer.parseInt(size[0])][Integer.parseInt(size[1])];
|
||||
@ -65,6 +65,7 @@ public class Map {
|
||||
map.setName(name);
|
||||
map.npcs = new LinkedList<>();
|
||||
map.getImageCell().readMapFile(name);
|
||||
map.getSoundManager().loadSoundMap(name);
|
||||
map.canvasSize[0] = Integer.parseInt(size[0]);
|
||||
map.canvasSize[1] = Integer.parseInt(size[1]);
|
||||
int y = 0;
|
||||
@ -90,13 +91,13 @@ public class Map {
|
||||
String[] block = line[x].split(",");
|
||||
if (block[0].equals("BLOCK"))
|
||||
if (block.length == 2) {
|
||||
map.getBlocks().add(new Block(x, y, map.getImageCell(), block[1], true));
|
||||
map.getBlocks().add(new Block(x, y, map, block[1], true));
|
||||
}
|
||||
else {
|
||||
map.getBlocks().add(new Block(x, y, map.getImageCell(), true));
|
||||
map.getBlocks().add(new Block(x, y, map, true));
|
||||
}
|
||||
else {
|
||||
map.getBlocks().add(new Block(x, y, map.getImageCell(), false));
|
||||
map.getBlocks().add(new Block(x, y, map, false));
|
||||
}
|
||||
} else if (line[x].equals("EMPTY")) {
|
||||
cellType = TypeOfCell.EMPTY;
|
||||
@ -104,27 +105,27 @@ public class Map {
|
||||
} else if (line[x].contains("INTER") || line[x].contains("inter")) {
|
||||
String[] event = line[x].split(",");
|
||||
if (line[x].contains("INTER"))
|
||||
map.addInteractionEvent(new InteractionCell(x, y, event[1], new Dialog(window.getDialogBar()), map.getImageCell(), window, true));
|
||||
map.addInteractionEvent(new InteractionCell(x, y, event[1], new Dialog(window.getDialogBar()), map, window, true));
|
||||
else
|
||||
map.addInteractionEvent(new InteractionCell(x, y, event[1], new Dialog(window.getDialogBar()), map.getImageCell(), window, false));
|
||||
map.addInteractionEvent(new InteractionCell(x, y, event[1], new Dialog(window.getDialogBar()), map, window, false));
|
||||
} else if (line[x].contains("TRIGGER")) {
|
||||
String[] trigger = line[x].split(",");
|
||||
map.addInteractionEvent(new TriggerCell(x, y, trigger[1], new Dialog(window.getDialogBar()), map.getImageCell(), window));
|
||||
map.addInteractionEvent(new TriggerCell(x, y, trigger[1], new Dialog(window.getDialogBar()), map, window));
|
||||
} else if (line[x].equals("SPAWN")) {
|
||||
map.setIdExit(0);
|
||||
map.setSpawnPoint(x, y);
|
||||
} else if (line[x].contains("DOOR") && !line[x].contains("DOORTO")) {
|
||||
String[] door = line[x].split(",");
|
||||
if (door.length == 2)
|
||||
map.addInteractionEvent(new DoorCell(x, y, Boolean.parseBoolean(door[1]), map.getImageCell(), window));
|
||||
map.addInteractionEvent(new DoorCell(x, y, Boolean.parseBoolean(door[1]), map, window));
|
||||
else
|
||||
map.addInteractionEvent(new DoorCell(x, y, Boolean.parseBoolean(door[1]), door[2], new Dialog(window.getDialogBar()), map.getImageCell(), window));
|
||||
map.addInteractionEvent(new DoorCell(x, y, Boolean.parseBoolean(door[1]), door[2], new Dialog(window.getDialogBar()), map, window));
|
||||
} else if (line[x].contains("CHEST")) {
|
||||
String[] chest = line[x].split(",");
|
||||
if (chest.length == 3)
|
||||
map.addInteractionEvent(new ChestCell(x, y, chest[1], new Dialog(window.getDialogBar()), map.getImageCell(), window, Boolean.parseBoolean(chest[2])));
|
||||
map.addInteractionEvent(new ChestCell(x, y, chest[1], new Dialog(window.getDialogBar()), map, window, Boolean.parseBoolean(chest[2])));
|
||||
else
|
||||
map.addInteractionEvent(new ChestCell(x, y, chest[1], new Dialog(window.getDialogBar()), map.getImageCell(), window));
|
||||
map.addInteractionEvent(new ChestCell(x, y, chest[1], new Dialog(window.getDialogBar()), map, window));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -151,11 +152,11 @@ public class Map {
|
||||
else if (line[x].contains("DOORTO")) {
|
||||
String[] doorTo = line[x].split(",");
|
||||
if (doorTo[1].equals("locked")) {
|
||||
map.addInteractionEvent(new DoorCell(x, y, Boolean.parseBoolean(doorTo[2]), doorTo[3], new Dialog(window.getDialogBar()), map.getImageCell(), window));
|
||||
map.addInteractionEvent(new DoorCell(x, y, Boolean.parseBoolean(doorTo[2]), doorTo[3], new Dialog(window.getDialogBar()), map, window));
|
||||
map.addMoveToEvent(new EventMoveToCell(Integer.parseInt(doorTo[4]), Integer.parseInt(doorTo[5]), x, y, findMapByName(doorTo[6], window), window, false));
|
||||
}
|
||||
else {
|
||||
map.addInteractionEvent(new DoorCell(x, y, Boolean.parseBoolean(doorTo[1]), map.getImageCell(), window));
|
||||
map.addInteractionEvent(new DoorCell(x, y, Boolean.parseBoolean(doorTo[1]), map, window));
|
||||
map.addMoveToEvent(new EventMoveToCell(Integer.parseInt(doorTo[2]), Integer.parseInt(doorTo[3]), x, y, findMapByName(doorTo[4], window), window, false));
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ public class MapManager {
|
||||
for (int i = 0; i < actualMap.getMapArray().length; i++) {
|
||||
for (int j = 0; j < actualMap.getMapArray()[0].length; j++) {
|
||||
if (actualMap.getMapArray()[i][j] == TypeOfCell.BLOCK && !actualMap.isBusyCell(i, j)) {
|
||||
actualMap.getBlocks().add(new Block(i, j, actualMap.getImageCell(), true));
|
||||
actualMap.getBlocks().add(new Block(i, j, actualMap, true));
|
||||
}
|
||||
|
||||
if (actualMap.getMapArray()[i][j] == TypeOfCell.SPAWNPOINT && actualMap.getIdExit() == 0) {
|
||||
|
||||
@ -2,17 +2,44 @@ package ruscz.game.gameOfProd.Sounds;
|
||||
|
||||
import javax.sound.sampled.*;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class SoundManager {
|
||||
private FloatControl gainControl;
|
||||
private Clip clip;
|
||||
private int delay;
|
||||
private HashMap<String, String> soundMap;
|
||||
|
||||
public SoundManager() {
|
||||
this.delay = 0;
|
||||
}
|
||||
|
||||
public void loadSoundMap(String file) {
|
||||
try {
|
||||
File mapFile = new File("src/main/resources/maps/" + file + "-tileset.txt");
|
||||
Scanner scanner = new Scanner(mapFile);
|
||||
soundMap = new HashMap<>();
|
||||
while (scanner.hasNextLine()) {
|
||||
String[] data = scanner.nextLine().split(" ");
|
||||
if (data[0].equals("<soundmap>")) {
|
||||
if (data[1].equals("DOOR")) {
|
||||
soundMap.put("doorOpen", data[2]);
|
||||
soundMap.put("doorClose", data[3]);
|
||||
soundMap.put("doorLocked", data[4]);
|
||||
}
|
||||
else if (data[1].contains("WALK")) {
|
||||
soundMap.put("walk", data[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void playSound(String name, float volume){
|
||||
AudioInputStream audioIn;
|
||||
try {
|
||||
@ -46,8 +73,17 @@ public class SoundManager {
|
||||
}
|
||||
this.delay = 0;
|
||||
}
|
||||
else if (this.delay == delay-1) {
|
||||
if (clip != null) {
|
||||
clip.stop();
|
||||
clip.flush();
|
||||
}
|
||||
this.delay++;
|
||||
}
|
||||
else {
|
||||
this.delay++;
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<String, String> getSoundMap() { return soundMap; }
|
||||
}
|
||||
|
||||
11
src/main/resources/dialogs/cutscenes/cutscene-error.txt
Normal file
11
src/main/resources/dialogs/cutscenes/cutscene-error.txt
Normal file
@ -0,0 +1,11 @@
|
||||
<1> <personmove> false
|
||||
<1> <foreground> error
|
||||
<3> <moveto> openspace 4
|
||||
<3> <text> Shit..
|
||||
<5> <foreground> null
|
||||
<5> <text> null
|
||||
<6> <text> I-have-to-take-a-break.-It's-lunch-time-anyway.
|
||||
<10> <text> null
|
||||
<10> <personmove> true
|
||||
<11> <music>
|
||||
<11> <end>
|
||||
2
src/main/resources/dialogs/horn.txt
Normal file
2
src/main/resources/dialogs/horn.txt
Normal file
@ -0,0 +1,2 @@
|
||||
<sound> horn.wav -15.0f
|
||||
<end>
|
||||
@ -1,5 +0,0 @@
|
||||
BLOCK 2
|
||||
MOVETO 1
|
||||
EVENT 3
|
||||
TRIGGER 4
|
||||
DOOR dark-door.png,32
|
||||
@ -2,6 +2,12 @@
|
||||
<tileset> Openspace1.png 512 512 32
|
||||
<tileset> Openspace2.png 512 512 32
|
||||
<tileset> D_Inside_House.png 512 512 32
|
||||
<cellmap> BLOCK 2
|
||||
<cellmap> MOVETO 1
|
||||
<cellmap> EVENT 0
|
||||
<cellmap> TRIGGER 4
|
||||
<cellmap> DOOR dark-door.png,32
|
||||
<soundmap> DOOR qubodup-DoorOpen01-changed.wav qubodup-DoorClose02-changed.wav doorLocked.wav
|
||||
6 6 6 6 6 6 6 6 6
|
||||
6 6 6 6 6 6 6 6 6
|
||||
6 6 6 22 38 54 6 6 6
|
||||
|
||||
@ -1,6 +0,0 @@
|
||||
BLOCK 2
|
||||
MOVETO 1
|
||||
EVENT 3
|
||||
TRIGGER 4
|
||||
DOOR dark-door.png,32
|
||||
CHEST 390
|
||||
@ -2,6 +2,13 @@
|
||||
<tileset> Openspace1.png 512 512 32
|
||||
<tileset> Openspace2.png 512 512 32
|
||||
<tileset> D_Inside_House.png 512 512 32
|
||||
<cellmap> BLOCK 2
|
||||
<cellmap> MOVETO 1
|
||||
<cellmap> EVENT 3
|
||||
<cellmap> TRIGGER 4
|
||||
<cellmap> DOOR dark-door.png,32
|
||||
<cellmap> CHEST 390
|
||||
<soundmap> DOOR qubodup-DoorOpen01-changed.wav qubodup-DoorClose02-changed.wav doorLocked.wav
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
|
||||
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
|
||||
|
||||
@ -6,9 +6,9 @@ BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EM
|
||||
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY block BLOCK
|
||||
BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK EMPTY EMPTY EMPTY BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK
|
||||
BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK EMPTY moveto,1,2,openspace EMPTY EMPTY EMPTY EMPTY BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK
|
||||
BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK EMPTY moveto,1,2,openspace EMPTY EMPTY EMPTY EMPTY BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK
|
||||
BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK EMPTY moveto,2,2,openspace EMPTY EMPTY EMPTY EMPTY BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK
|
||||
BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK EMPTY EMPTY EMPTY BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK
|
||||
BLOCK CHEST,trashcan,true EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
|
||||
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY block
|
||||
BLOCK BLOCK,d EMPTY BLOCK,d BLOCK,d BLOCK,d BLOCK,d EMPTY BLOCK,d BLOCK,d BLOCK,d BLOCK,d EMPTY BLOCK,d BLOCK,d BLOCK,d BLOCK,d EMPTY BLOCK,d BLOCK
|
||||
BLOCK BLOCK DOOR,true,locked BLOCK BLOCK BLOCK BLOCK DOOR,true,locked BLOCK BLOCK BLOCK BLOCK DOOR,true,locked BLOCK BLOCK BLOCK BLOCK DOORTO,locked,true,white-key-card,2,1,treasure BLOCK BLOCK
|
||||
BLOCK BLOCK DOOR,true,locked BLOCK BLOCK BLOCK BLOCK DOOR,true,locked BLOCK BLOCK BLOCK BLOCK DOOR,true,locked BLOCK BLOCK BLOCK BLOCK DOORTO,locked,true,white-key-card,3,1,treasure BLOCK BLOCK
|
||||
@ -1,5 +0,0 @@
|
||||
BLOCK 2
|
||||
MOVETO 1
|
||||
EVENT 0
|
||||
TRIGGER 4
|
||||
DOOR dark-door.png,32
|
||||
@ -3,6 +3,12 @@
|
||||
<tileset> Openspace2.png 512 512 32
|
||||
<tileset> D_Inside_House.png 512 512 32
|
||||
<items> TransparentIcons.png 512 640 32
|
||||
<cellmap> BLOCK 2
|
||||
<cellmap> MOVETO 1
|
||||
<cellmap> EVENT 0
|
||||
<cellmap> TRIGGER 4
|
||||
<cellmap> DOOR dark-door.png,32
|
||||
<soundmap> DOOR qubodup-DoorOpen01-changed.wav qubodup-DoorClose02-changed.wav doorLocked.wav
|
||||
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
|
||||
6 117 117 117 117 117 117 117 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
|
||||
6 117 117 117 117 117 117 117 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
|
||||
|
||||
@ -15,7 +15,7 @@ BLOCK EMPTY block block inter,minecraft block block EMPTY BLOCK,u EMPTY EMPTY EM
|
||||
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY DOOR,false EMPTY EMPTY EMPTY EMPTY EMPTY block block EMPTY block block block
|
||||
BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY block
|
||||
BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK EMPTY moveto,1,2,office EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
|
||||
BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK EMPTY moveto,7,2,m1 EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY SPAWN block EMPTY block EMPTY BLOCK
|
||||
BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK EMPTY moveto,2,2,office EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY SPAWN block EMPTY block EMPTY BLOCK
|
||||
BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY block block EMPTY block block block
|
||||
BLOCK block EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY block
|
||||
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY block
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
BLOCK 0
|
||||
MOVETO 0
|
||||
EVENT 0
|
||||
TRIGGER 0
|
||||
DOOR dark-door.png,32
|
||||
@ -1,4 +1,9 @@
|
||||
<tileset> CertificateOfShame.png 650 500 50
|
||||
<cellmap> BLOCK 0
|
||||
<cellmap> MOVETO 0
|
||||
<cellmap> EVENT 0
|
||||
<cellmap> TRIGGER 0
|
||||
<cellmap> DOOR dark-door.png,32
|
||||
0 10 20 30 40 50 60 70 80 90 100 110 120
|
||||
1 11 21 31 41 51 61 71 81 91 101 111 121
|
||||
2 12 22 32 42 52 62 72 82 92 102 112 122
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
13 10
|
||||
block block block block block block moveto,2,3,office block block block block block block
|
||||
block EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY block
|
||||
block block block block block block moveto,3,3,office block block block block block block
|
||||
block EMPTY EMPTY EMPTY EMPTY EMPTY TRIGGER,horn EMPTY EMPTY EMPTY EMPTY EMPTY block
|
||||
block EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY block
|
||||
block EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY block
|
||||
block EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY block
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
BLOCK 120
|
||||
MOVETO 277
|
||||
EVENT 334
|
||||
TRIGGER 147
|
||||
@ -1,6 +1,10 @@
|
||||
<tileset> A2_Ground.png 512 384 32 192
|
||||
<tileset> D_OutDoor.png 512 512 32 256
|
||||
<tileset> tutorialtiles.png 288 96 32 448
|
||||
<cellmap> BLOCK 120
|
||||
<cellmap> MOVETO 277
|
||||
<cellmap> EVENT 334
|
||||
<cellmap> TRIGGER 147
|
||||
1 1 1 1 1 1 1 1 1 1 1 1 1
|
||||
1 1 1 1 1 1 1 1 1 1 1 1 1
|
||||
1 1 1 1 1 1 1 1 1 1 1 1 1
|
||||
|
||||
@ -5,7 +5,7 @@ BLOCK EMPTY EMPTY EMPTY EMPTY SPAWN EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
|
||||
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
|
||||
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
|
||||
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
|
||||
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY TRIGGER,error BLOCK
|
||||
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY TRIGGER,cutscene-error BLOCK
|
||||
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
|
||||
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
|
||||
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
|
||||
|
||||
@ -1,8 +1,3 @@
|
||||
m1
|
||||
m2
|
||||
m3
|
||||
m4
|
||||
m6
|
||||
tutorial
|
||||
openspace
|
||||
office
|
||||
|
||||
@ -1,48 +1,3 @@
|
||||
<map>
|
||||
<mapName>m1</mapName>
|
||||
<events>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>m2</mapName>
|
||||
<events>
|
||||
<trigger>
|
||||
<x>7</x>
|
||||
<y>2</y>
|
||||
<active>true</active>
|
||||
</trigger>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>m3</mapName>
|
||||
<events>
|
||||
<trigger>
|
||||
<x>2</x>
|
||||
<y>5</y>
|
||||
<active>true</active>
|
||||
</trigger>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>m4</mapName>
|
||||
<events>
|
||||
<trigger>
|
||||
<x>3</x>
|
||||
<y>3</y>
|
||||
<active>true</active>
|
||||
</trigger>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>m6</mapName>
|
||||
<events>
|
||||
<trigger>
|
||||
<x>11</x>
|
||||
<y>11</y>
|
||||
<active>true</active>
|
||||
</trigger>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>tutorial</mapName>
|
||||
<events>
|
||||
@ -59,12 +14,12 @@
|
||||
<trigger>
|
||||
<x>7</x>
|
||||
<y>4</y>
|
||||
<active>false</active>
|
||||
<active>true</active>
|
||||
</trigger>
|
||||
<chest>
|
||||
<x>15</x>
|
||||
<y>7</y>
|
||||
<active>true</active>
|
||||
<active>false</active>
|
||||
</chest>
|
||||
</events>
|
||||
</map>
|
||||
@ -74,7 +29,7 @@
|
||||
<chest>
|
||||
<x>1</x>
|
||||
<y>9</y>
|
||||
<active>true</active>
|
||||
<active>false</active>
|
||||
</chest>
|
||||
</events>
|
||||
</map>
|
||||
@ -84,12 +39,17 @@
|
||||
<trigger>
|
||||
<x>4</x>
|
||||
<y>18</y>
|
||||
<active>false</active>
|
||||
<active>true</active>
|
||||
</trigger>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>treasure</mapName>
|
||||
<events>
|
||||
<trigger>
|
||||
<x>6</x>
|
||||
<y>1</y>
|
||||
<active>false</active>
|
||||
</trigger>
|
||||
</events>
|
||||
</map>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<location>
|
||||
<map>openspace</map>
|
||||
<x>8</x>
|
||||
<y>15</y>
|
||||
<direction>3</direction>
|
||||
<map>office</map>
|
||||
<x>17</x>
|
||||
<y>11</y>
|
||||
<direction>2</direction>
|
||||
</location>
|
||||
BIN
src/main/resources/sounds/horn.wav
Normal file
BIN
src/main/resources/sounds/horn.wav
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user