diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java b/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java index b23ebdc..5eb6d3e 100644 --- a/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java @@ -256,6 +256,7 @@ public class InteractionCell extends Cell { window.getMusicManager().playMusic(); window.getMusicManager().fadeIn(10); } + else if (data[1].equals("")) window.loadNextChapter(); else if (data[1].equals("")) { timer.stop(); } diff --git a/src/main/java/ruscz/game/gameOfProd/Game.java b/src/main/java/ruscz/game/gameOfProd/Game.java index e155227..c40d6b5 100644 --- a/src/main/java/ruscz/game/gameOfProd/Game.java +++ b/src/main/java/ruscz/game/gameOfProd/Game.java @@ -40,18 +40,18 @@ public class Game extends JFrame { battle = new WindowOfBattle(this); //tohle spustí na začátku menu -// add(menu); + add(menu); //tohle spustí na začátku hru // add(freeMove); // freeMove.start(true); //tohle spustí na začátku bitvu - add(battle); - battle.startBattle(); +// add(battle); +// battle.startBattle(); //Tohle spustí na začátku tileset overview -// tilesetOverview = new TilesetOverview(); +// new TilesetOverview(); setDefaultCloseOperation(EXIT_ON_CLOSE); setUndecorated(true); diff --git a/src/main/java/ruscz/game/gameOfProd/Image/ImageCell.java b/src/main/java/ruscz/game/gameOfProd/Image/ImageCell.java index bae557d..d71e151 100644 --- a/src/main/java/ruscz/game/gameOfProd/Image/ImageCell.java +++ b/src/main/java/ruscz/game/gameOfProd/Image/ImageCell.java @@ -25,7 +25,7 @@ public class ImageCell { try { mapBackground = new int[WindowOfFreeMove.CANVAS_WIDTH][WindowOfFreeMove.CANVAS_HEIGHT]; mapForeground = new int[WindowOfFreeMove.CANVAS_WIDTH][WindowOfFreeMove.CANVAS_HEIGHT]; - File mapFile = new File("src/main/resources/maps/" + name + "-tileset.txt"); + File mapFile = new File("src/main/resources/maps/" + WindowOfFreeMove.CHAPTER + "/" + name + "-tileset.txt"); Scanner scanner = new Scanner(mapFile); int j = 0; while (scanner.hasNextLine()) { @@ -91,7 +91,7 @@ public class ImageCell { public void imageObjectset(String file) { try { - File objectFile = new File("src/main/resources/maps/" + file + "-objectset.txt"); + File objectFile = new File("src/main/resources/maps/" + WindowOfFreeMove.CHAPTER + "/" + file + "-objectset.txt"); Scanner scanner = new Scanner(objectFile); int j = 0; while (scanner.hasNextLine()) { diff --git a/src/main/java/ruscz/game/gameOfProd/Map/Map.java b/src/main/java/ruscz/game/gameOfProd/Map/Map.java index 296189a..fd3b373 100644 --- a/src/main/java/ruscz/game/gameOfProd/Map/Map.java +++ b/src/main/java/ruscz/game/gameOfProd/Map/Map.java @@ -29,6 +29,8 @@ public class Map { private static Scanner scanner; + private static String mapWithSpawn = ""; + public Map(TypeOfCell[][] mapArray) { idExit = -1; moveToCells = new LinkedList<>(); @@ -56,7 +58,7 @@ public class Map { public static Map loadMapFromFile(String name, WindowOfFreeMove window) { try { - File file = new File("src/main/resources/maps/" + name + ".txt"); + File file = new File("src/main/resources/maps/" + WindowOfFreeMove.CHAPTER + "/" + name + ".txt"); scanner = new Scanner(file); String firstLine = scanner.nextLine(); String[] size = firstLine.split(" "); @@ -117,6 +119,7 @@ public class Map { } else if (line[x].equals("SPAWN")) { map.setIdExit(0); map.setSpawnPoint(x, y); + mapWithSpawn = map.getName(); } else if (line[x].contains("DOOR") && !line[x].contains("DOORTO")) { String[] door = line[x].split(","); if (door.length == 2) @@ -136,7 +139,7 @@ public class Map { public void linkMaps(Map map, WindowOfFreeMove window) { try { - File dialogFile = new File("src/main/resources/maps/" + map.getName() + ".txt"); + File dialogFile = new File("src/main/resources/maps/" + WindowOfFreeMove.CHAPTER + "/" + map.getName() + ".txt"); scanner = new Scanner(dialogFile); String firstLine = scanner.nextLine(); String[] size = firstLine.split(" "); @@ -221,6 +224,8 @@ public class Map { return idExit; } + public static String getMapWithSpawn() { return mapWithSpawn; } + public LinkedList getBlocks() { return block; } @@ -239,9 +244,7 @@ public class Map { public LinkedList getChestCells() { return chestCells; } - public void setIdExit(int id) { - this.idExit = id; - } + public void setIdExit(int id) { this.idExit = id; } public void setSpawnPoint(int x, int y) { mapArray[x][y] = TypeOfCell.SPAWNPOINT; diff --git a/src/main/java/ruscz/game/gameOfProd/Save/LoadManager.java b/src/main/java/ruscz/game/gameOfProd/Save/LoadManager.java index 5618a9d..4df16e9 100644 --- a/src/main/java/ruscz/game/gameOfProd/Save/LoadManager.java +++ b/src/main/java/ruscz/game/gameOfProd/Save/LoadManager.java @@ -72,12 +72,14 @@ public class LoadManager { Scanner scanner = new Scanner(mapsFile); while (scanner.hasNextLine()) { - String mapName = scanner.nextLine(); - Map map = Map.loadMapFromFile(mapName, window); - if (mapName.equals("tutorial")) map.getPerson().setImagePerson("tutorialpers", rec); - else map.getPerson().setImagePerson("main", rec); - map.setName(mapName); - mapLinkedList.add(map); + String[] mapName = scanner.nextLine().split(" "); + if (mapName[0].equals("<" + WindowOfFreeMove.CHAPTER + ">")) { + Map map = Map.loadMapFromFile(mapName[1], window); + if (mapName[1].equals("tutorial")) map.getPerson().setImagePerson("tutorialpers", rec); + else map.getPerson().setImagePerson("main", rec); + map.setName(mapName[1]); + mapLinkedList.add(map); + } } scanner.close(); for (Map map : mapLinkedList) { @@ -93,12 +95,14 @@ public class LoadManager { File npcsFile = new File("src/main/resources/save/newGame/npcs.txt"); Scanner scanner = new Scanner(npcsFile); while (scanner.hasNextLine()) { - String name = scanner.nextLine(); - File npcFile = new File("src/main/resources/characters/" + name + ".txt"); - Scanner sc = new Scanner(npcFile); - String[] position = sc.nextLine().split(" "); - Npc npc = new Npc(Integer.parseInt(position[0]), Integer.parseInt(position[1]), name, Map.findMapByName(position[2], window), mapManager); - Map.findMapByName(position[2], window).setNpcs(npc); + String[] npcName = scanner.nextLine().split(" "); + if (npcName[0].equals("<" + WindowOfFreeMove.CHAPTER + ">")) { + File npcFile = new File("src/main/resources/characters/" + npcName[1] + ".txt"); + Scanner sc = new Scanner(npcFile); + String[] position = sc.nextLine().split(" "); + Npc npc = new Npc(Integer.parseInt(position[0]), Integer.parseInt(position[1]), npcName[1], Map.findMapByName(position[2], window), mapManager); + Map.findMapByName(position[2], window).setNpcs(npc); + } } } catch (FileNotFoundException e) { e.printStackTrace(); diff --git a/src/main/java/ruscz/game/gameOfProd/Sounds/SoundManager.java b/src/main/java/ruscz/game/gameOfProd/Sounds/SoundManager.java index 9288601..276bf36 100644 --- a/src/main/java/ruscz/game/gameOfProd/Sounds/SoundManager.java +++ b/src/main/java/ruscz/game/gameOfProd/Sounds/SoundManager.java @@ -1,5 +1,7 @@ package ruscz.game.gameOfProd.Sounds; +import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; + import javax.sound.sampled.*; import java.io.File; import java.io.FileNotFoundException; @@ -19,7 +21,7 @@ public class SoundManager { public void loadSoundMap(String file) { try { - File mapFile = new File("src/main/resources/maps/" + file + "-tileset.txt"); + File mapFile = new File("src/main/resources/maps/" + WindowOfFreeMove.CHAPTER + "/" + file + "-tileset.txt"); Scanner scanner = new Scanner(mapFile); soundMap = new HashMap<>(); while (scanner.hasNextLine()) { diff --git a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java index 542dca3..e5714f0 100644 --- a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java +++ b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java @@ -35,6 +35,8 @@ public class WindowOfFreeMove extends JLayeredPane { private static final int KEY_ESCAPE = 27; + public static int CHAPTER = 0; + private JFrame game; private Canvas canvas; private DialogBar dialogBar; @@ -164,8 +166,8 @@ public class WindowOfFreeMove extends JLayeredPane { if (newGame) { mapManager.getLoadManager().clearSave(); mapManager.getLoadManager().loadNewGame(); - Map openspace = Map.findMapByName("tutorial", this); - setMapManager(openspace); + Map firstMap = Map.findMapByName(Map.getMapWithSpawn(), this); + setMapManager(firstMap); } else { mapManager.getLoadManager().loadSavedGame(); @@ -187,6 +189,18 @@ public class WindowOfFreeMove extends JLayeredPane { timer.start(); } + public void loadNextChapter() { + CHAPTER++; + isReadyToPaint = false; + mapLinkedList = new LinkedList<>(); + mapManager = new MapManager(mapLinkedList, canvas, this); + mapManager.getLoadManager().loadNewGame(); + Map map = Map.findMapByName(Map.getMapWithSpawn(), this); + setMapManager(map); + mapManager.createMap(); + isReadyToPaint = true; + } + public class Canvas extends JPanel { @Override public void paint(Graphics g) { diff --git a/src/main/resources/dialogs/cutscenes/cutscene-work.txt b/src/main/resources/dialogs/cutscenes/cutscene-work.txt index 2b6ab62..620b8e3 100644 --- a/src/main/resources/dialogs/cutscenes/cutscene-work.txt +++ b/src/main/resources/dialogs/cutscenes/cutscene-work.txt @@ -1,3 +1,4 @@ <1> test <3> null +<3> <3> \ No newline at end of file diff --git a/src/main/resources/maps/boss-objectset.txt b/src/main/resources/maps/0/boss-objectset.txt similarity index 100% rename from src/main/resources/maps/boss-objectset.txt rename to src/main/resources/maps/0/boss-objectset.txt diff --git a/src/main/resources/maps/boss-tileset.txt b/src/main/resources/maps/0/boss-tileset.txt similarity index 100% rename from src/main/resources/maps/boss-tileset.txt rename to src/main/resources/maps/0/boss-tileset.txt diff --git a/src/main/resources/maps/boss.txt b/src/main/resources/maps/0/boss.txt similarity index 100% rename from src/main/resources/maps/boss.txt rename to src/main/resources/maps/0/boss.txt diff --git a/src/main/resources/maps/office-objectset.txt b/src/main/resources/maps/0/office-objectset.txt similarity index 100% rename from src/main/resources/maps/office-objectset.txt rename to src/main/resources/maps/0/office-objectset.txt diff --git a/src/main/resources/maps/office-tileset.txt b/src/main/resources/maps/0/office-tileset.txt similarity index 100% rename from src/main/resources/maps/office-tileset.txt rename to src/main/resources/maps/0/office-tileset.txt diff --git a/src/main/resources/maps/office.txt b/src/main/resources/maps/0/office.txt similarity index 100% rename from src/main/resources/maps/office.txt rename to src/main/resources/maps/0/office.txt diff --git a/src/main/resources/maps/openspace-objectset.txt b/src/main/resources/maps/0/openspace-objectset.txt similarity index 100% rename from src/main/resources/maps/openspace-objectset.txt rename to src/main/resources/maps/0/openspace-objectset.txt diff --git a/src/main/resources/maps/openspace-tileset.txt b/src/main/resources/maps/0/openspace-tileset.txt similarity index 100% rename from src/main/resources/maps/openspace-tileset.txt rename to src/main/resources/maps/0/openspace-tileset.txt diff --git a/src/main/resources/maps/openspace.txt b/src/main/resources/maps/0/openspace.txt similarity index 100% rename from src/main/resources/maps/openspace.txt rename to src/main/resources/maps/0/openspace.txt diff --git a/src/main/resources/maps/treasure-objectset.txt b/src/main/resources/maps/0/treasure-objectset.txt similarity index 100% rename from src/main/resources/maps/treasure-objectset.txt rename to src/main/resources/maps/0/treasure-objectset.txt diff --git a/src/main/resources/maps/treasure-tileset.txt b/src/main/resources/maps/0/treasure-tileset.txt similarity index 100% rename from src/main/resources/maps/treasure-tileset.txt rename to src/main/resources/maps/0/treasure-tileset.txt diff --git a/src/main/resources/maps/treasure.txt b/src/main/resources/maps/0/treasure.txt similarity index 100% rename from src/main/resources/maps/treasure.txt rename to src/main/resources/maps/0/treasure.txt diff --git a/src/main/resources/maps/tutorial-objectset.txt b/src/main/resources/maps/0/tutorial-objectset.txt similarity index 100% rename from src/main/resources/maps/tutorial-objectset.txt rename to src/main/resources/maps/0/tutorial-objectset.txt diff --git a/src/main/resources/maps/tutorial-tileset.txt b/src/main/resources/maps/0/tutorial-tileset.txt similarity index 100% rename from src/main/resources/maps/tutorial-tileset.txt rename to src/main/resources/maps/0/tutorial-tileset.txt diff --git a/src/main/resources/maps/tutorial.txt b/src/main/resources/maps/0/tutorial.txt similarity index 100% rename from src/main/resources/maps/tutorial.txt rename to src/main/resources/maps/0/tutorial.txt diff --git a/src/main/resources/maps/1/glade-objectset.txt b/src/main/resources/maps/1/glade-objectset.txt new file mode 100644 index 0000000..e9fbc8c --- /dev/null +++ b/src/main/resources/maps/1/glade-objectset.txt @@ -0,0 +1,13 @@ +0 0 0 0 0 0 0 0 0 0 0 0 0 +0 205 221 0 0 0 0 310 0 0 0 0 0 +0 206 222 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 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 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 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 293 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 \ No newline at end of file diff --git a/src/main/resources/maps/1/glade-tileset.txt b/src/main/resources/maps/1/glade-tileset.txt new file mode 100644 index 0000000..cebae29 --- /dev/null +++ b/src/main/resources/maps/1/glade-tileset.txt @@ -0,0 +1,19 @@ + A2_Ground.png 512 384 32 192 + D_OutDoor.png 512 512 32 256 + BLOCK 120 + MOVETO 277 + EVENT 334 + TRIGGER 147 +1 1 1 1 1 1 1 1 1 1 1 1 1 +1 1 27 1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 27 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 27 1 1 +1 1 1 1 1 1 1 1 1 1 1 1 1 +1 1 27 1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 27 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 1 1 1 +1 1 1 1 27 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 27 1 1 +1 1 1 1 1 1 1 1 1 1 1 1 1 diff --git a/src/main/resources/maps/1/glade.txt b/src/main/resources/maps/1/glade.txt new file mode 100644 index 0000000..64da428 --- /dev/null +++ b/src/main/resources/maps/1/glade.txt @@ -0,0 +1,14 @@ +13 13 +block block block block block block block block block block block block 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 EMPTY block +block EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY block +block EMPTY EMPTY EMPTY EMPTY EMPTY SPAWN 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 EMPTY block +block EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY block +block block block block block block block block block block block block block \ No newline at end of file diff --git a/src/main/resources/save/newGame/maps.txt b/src/main/resources/save/newGame/maps.txt index 56d740f..65664ad 100644 --- a/src/main/resources/save/newGame/maps.txt +++ b/src/main/resources/save/newGame/maps.txt @@ -1,5 +1,6 @@ -tutorial -openspace -office -boss -treasure \ No newline at end of file +<0> tutorial +<0> openspace +<0> office +<0> boss +<0> treasure +<1> glade \ No newline at end of file diff --git a/src/main/resources/save/newGame/npcs.txt b/src/main/resources/save/newGame/npcs.txt index e4bfa1b..fdfcafd 100644 --- a/src/main/resources/save/newGame/npcs.txt +++ b/src/main/resources/save/newGame/npcs.txt @@ -1,8 +1,8 @@ -boy1 -boy2 -boy3 -boy4 -boy5 -girl1 -girl2 -boss \ No newline at end of file +<0> boy1 +<0> boy2 +<0> boy3 +<0> boy4 +<0> boy5 +<0> girl1 +<0> girl2 +<0> boss \ No newline at end of file diff --git a/src/main/resources/tilesets/trees.png b/src/main/resources/tilesets/trees.png new file mode 100644 index 0000000..94c5462 Binary files /dev/null and b/src/main/resources/tilesets/trees.png differ