diff --git a/src/main/java/ruscz/game/gameOfProd/Map/Map.java b/src/main/java/ruscz/game/gameOfProd/Map/Map.java index 103c2d0..8a4f215 100644 --- a/src/main/java/ruscz/game/gameOfProd/Map/Map.java +++ b/src/main/java/ruscz/game/gameOfProd/Map/Map.java @@ -313,6 +313,13 @@ public class Map { return false; } + public boolean isTriggerCell(int x, int y) { + for (TriggerCell cell : triggerCells) + if (x == cell.getX() && y == cell.getY() && cell.getClass().getName().equals("ruscz.game.gameOfProd.Cells.TriggerCell")) + return true; + return false; + } + public boolean isDoor(int x, int y) { for (DoorCell cell : doorCells) if (x == cell.getX() && y == cell.getY() && cell.getClass().getName().equals("ruscz.game.gameOfProd.Cells.DoorCell")) { diff --git a/src/main/java/ruscz/game/gameOfProd/Map/MapManager.java b/src/main/java/ruscz/game/gameOfProd/Map/MapManager.java index c2f310d..dcddd5f 100644 --- a/src/main/java/ruscz/game/gameOfProd/Map/MapManager.java +++ b/src/main/java/ruscz/game/gameOfProd/Map/MapManager.java @@ -51,6 +51,10 @@ public class MapManager { public LoadManager getLoadManager() { return loadManager; } + public SaveManager getSaveManager() { + return saveManager; + } + public void createMap() { for (int i = 0; i < actualMap.getMapArray().length; i++) { for (int j = 0; j < actualMap.getMapArray()[0].length; j++) { diff --git a/src/main/java/ruscz/game/gameOfProd/Scripts/PathFinder.java b/src/main/java/ruscz/game/gameOfProd/Scripts/PathFinder.java index 8d68928..13f6327 100644 --- a/src/main/java/ruscz/game/gameOfProd/Scripts/PathFinder.java +++ b/src/main/java/ruscz/game/gameOfProd/Scripts/PathFinder.java @@ -54,7 +54,7 @@ public class PathFinder { for (int i = 0; i < map.getMapArray().length; i++) { for (int j = 0; j < map.getMapArray()[0].length; j++) { - if (map.getMapArray()[i][j] == TypeOfCell.BLOCK || map.getMapArray()[i][j] == TypeOfCell.EVENT) { + if (map.getMapArray()[i][j] == TypeOfCell.BLOCK || (map.getMapArray()[i][j] == TypeOfCell.EVENT && !map.isTriggerCell(i, j))) { aStar.setBlock(i, j); } } diff --git a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java index d738263..060e9d8 100644 --- a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java +++ b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java @@ -1,15 +1,19 @@ package ruscz.game.gameOfProd.Windows; -import ruscz.game.gameOfProd.Battle.*; +import ruscz.game.gameOfProd.Battle.Battle; +import ruscz.game.gameOfProd.Battle.BattlePerson; +import ruscz.game.gameOfProd.Battle.Enemy; +import ruscz.game.gameOfProd.Battle.Hero; import ruscz.game.gameOfProd.BattleUI.*; import ruscz.game.gameOfProd.Game; -import ruscz.game.gameOfProd.Save.LoadManager; import ruscz.game.gameOfProd.Save.SaveManager; import ruscz.game.gameOfProd.Sounds.MusicManager; import javax.swing.*; import java.awt.*; -import java.awt.event.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.WindowEvent; import java.io.File; import java.io.FileNotFoundException; import java.util.LinkedList; @@ -105,7 +109,7 @@ public class WindowOfBattle extends JPanel { } public void startBattle(String name) { - SaveManager saveManager = new SaveManager(game.getFreeMove().getMapManager()); + SaveManager saveManager = game.getFreeMove().getMapManager().getSaveManager(); saveManager.saveGame(); LinkedList heroes = new LinkedList<>(); @@ -134,7 +138,7 @@ public class WindowOfBattle extends JPanel { e.printStackTrace(); } - MusicManager musicManager = new MusicManager("Fight_Music.wav", 0.0f); + MusicManager musicManager = new MusicManager("Fight_Music.wav", -15.0f); battle = new Battle(heroes, enemies, this); isReadyToPaint = true; @@ -151,9 +155,6 @@ public class WindowOfBattle extends JPanel { musicManager.playMusic(); musicManager.setVolumeToMaxVolume(); } - - LoadManager loadManager = new LoadManager(game.getFreeMove().getMapManager()); - loadManager.loadSavedGame(); } public Canvas getCanvas() { diff --git a/src/main/resources/save/savedGame/events.txt b/src/main/resources/save/savedGame/events.txt index e69de29..b09722c 100644 --- a/src/main/resources/save/savedGame/events.txt +++ b/src/main/resources/save/savedGame/events.txt @@ -0,0 +1,80 @@ + + tutorial + + + 11 + 6 + false + + + + + openspace + + + 6 + 4 + true + + + 14 + 16 + false + + + 1 + 2 + true + + + 15 + 7 + true + + + + + office + + + 4 + 2 + false + + + 1 + 9 + true + + + + + boss + + + 4 + 18 + true + + + + + treasure + + + 6 + 1 + true + + + + + storageroom + + + 6 + 2 + false + + + diff --git a/src/main/resources/save/savedGame/person.txt b/src/main/resources/save/savedGame/person.txt index e69de29..ec0fcae 100644 --- a/src/main/resources/save/savedGame/person.txt +++ b/src/main/resources/save/savedGame/person.txt @@ -0,0 +1,6 @@ + + storageroom + 6 + 2 + 0 + \ No newline at end of file