diff --git a/src/main/java/ruscz/game/gameOfProd/Sounds/MusicManager.java b/src/main/java/ruscz/game/gameOfProd/Sounds/MusicManager.java index 0bf2841..f04b3c6 100644 --- a/src/main/java/ruscz/game/gameOfProd/Sounds/MusicManager.java +++ b/src/main/java/ruscz/game/gameOfProd/Sounds/MusicManager.java @@ -6,9 +6,9 @@ import java.io.File; import java.io.IOException; public class MusicManager { - private String musicName; + private final String musicName; private float volume; - private float maxVolume; + private final float maxVolume; private FloatControl gainControl; private Timer timerIn; private Timer timerOut; @@ -46,6 +46,14 @@ public class MusicManager { volume = -40.0f; } + public void setVolumeToMaxVolume(){ + gainControl.setValue(maxVolume); + } + + public void setVolumeToNormalVolume(){ + gainControl.setValue(-40.0f); + } + public void fadeIn(int delay) { timerIn = new Timer(delay, actionEvent -> { if (volume < maxVolume) { diff --git a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java index aed67be..d738263 100644 --- a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java +++ b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java @@ -3,6 +3,9 @@ package ruscz.game.gameOfProd.Windows; import ruscz.game.gameOfProd.Battle.*; 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.*; @@ -56,6 +59,8 @@ public class WindowOfBattle extends JPanel { private Game game; private Battle battle; + private MusicManager musicManager; + public Battle getBattle() { return battle; } @@ -100,7 +105,8 @@ public class WindowOfBattle extends JPanel { } public void startBattle(String name) { - //saveManager.saveGame(); + SaveManager saveManager = new SaveManager(game.getFreeMove().getMapManager()); + saveManager.saveGame(); LinkedList heroes = new LinkedList<>(); LinkedList enemies = new LinkedList<>(); @@ -120,11 +126,15 @@ public class WindowOfBattle extends JPanel { Integer.parseInt(data[4]), Integer.parseInt(data[5])); enemies.add(enemy); } + else if (data[0].equals("")) { + musicManager = new MusicManager(data[1], Float.parseFloat(data[2])); + } } } catch (FileNotFoundException e) { e.printStackTrace(); } + MusicManager musicManager = new MusicManager("Fight_Music.wav", 0.0f); battle = new Battle(heroes, enemies, this); isReadyToPaint = true; @@ -137,7 +147,13 @@ public class WindowOfBattle extends JPanel { battle.startBattle(); - //loadManager.loadSavedGame(); + if (musicManager != null){ + musicManager.playMusic(); + musicManager.setVolumeToMaxVolume(); + } + + LoadManager loadManager = new LoadManager(game.getFreeMove().getMapManager()); + loadManager.loadSavedGame(); } public Canvas getCanvas() { diff --git a/src/main/resources/battles/storageroombattle.txt b/src/main/resources/battles/storageroombattle.txt index 3e9aea5..546413f 100644 --- a/src/main/resources/battles/storageroombattle.txt +++ b/src/main/resources/battles/storageroombattle.txt @@ -1,2 +1,3 @@ 100 10 Mark 1 10 1 - 100 10 Karen 10 1 \ No newline at end of file + 100 10 Karen 10 1 + Fight_Music.wav -10.0f \ No newline at end of file diff --git a/src/main/resources/dialogs/cutscenes/cutscene-fight.txt b/src/main/resources/dialogs/cutscenes/cutscene-fight.txt index 667dd0f..fa64fd9 100644 --- a/src/main/resources/dialogs/cutscenes/cutscene-fight.txt +++ b/src/main/resources/dialogs/cutscenes/cutscene-fight.txt @@ -6,6 +6,7 @@ <2> null <4> color 0 0 0 100 <5> null +<6> glass-flood-light-bulb-smash.wav 0.0f <6> color 0 0 0 200 <7> add monster <8> image main-face.png diff --git a/src/main/resources/music/Fight_Music.wav b/src/main/resources/music/Fight_Music.wav new file mode 100644 index 0000000..590955a Binary files /dev/null and b/src/main/resources/music/Fight_Music.wav differ diff --git a/src/main/resources/save/savedGame/events.txt b/src/main/resources/save/savedGame/events.txt index 02fad9d..e69de29 100644 --- a/src/main/resources/save/savedGame/events.txt +++ b/src/main/resources/save/savedGame/events.txt @@ -1,80 +0,0 @@ - - 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 - true - - - diff --git a/src/main/resources/save/savedGame/person.txt b/src/main/resources/save/savedGame/person.txt index ec0fcae..e69de29 100644 --- a/src/main/resources/save/savedGame/person.txt +++ b/src/main/resources/save/savedGame/person.txt @@ -1,6 +0,0 @@ - - storageroom - 6 - 2 - 0 - \ No newline at end of file diff --git a/src/main/resources/sounds/glass-flood-light-bulb-smash.wav b/src/main/resources/sounds/glass-flood-light-bulb-smash.wav new file mode 100644 index 0000000..46a3969 Binary files /dev/null and b/src/main/resources/sounds/glass-flood-light-bulb-smash.wav differ diff --git a/src/main/resources/sounds/lamp-break-drop.wav b/src/main/resources/sounds/lamp-break-drop.wav new file mode 100644 index 0000000..cfd000f Binary files /dev/null and b/src/main/resources/sounds/lamp-break-drop.wav differ