Some adds to Battle and Cutscene

This commit is contained in:
iryupnik 2020-06-04 12:15:23 +02:00
parent e117e03ecf
commit 1d152e2773
9 changed files with 31 additions and 91 deletions

View File

@ -6,9 +6,9 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
public class MusicManager { public class MusicManager {
private String musicName; private final String musicName;
private float volume; private float volume;
private float maxVolume; private final float maxVolume;
private FloatControl gainControl; private FloatControl gainControl;
private Timer timerIn; private Timer timerIn;
private Timer timerOut; private Timer timerOut;
@ -46,6 +46,14 @@ public class MusicManager {
volume = -40.0f; volume = -40.0f;
} }
public void setVolumeToMaxVolume(){
gainControl.setValue(maxVolume);
}
public void setVolumeToNormalVolume(){
gainControl.setValue(-40.0f);
}
public void fadeIn(int delay) { public void fadeIn(int delay) {
timerIn = new Timer(delay, actionEvent -> { timerIn = new Timer(delay, actionEvent -> {
if (volume < maxVolume) { if (volume < maxVolume) {

View File

@ -3,6 +3,9 @@ package ruscz.game.gameOfProd.Windows;
import ruscz.game.gameOfProd.Battle.*; import ruscz.game.gameOfProd.Battle.*;
import ruscz.game.gameOfProd.BattleUI.*; import ruscz.game.gameOfProd.BattleUI.*;
import ruscz.game.gameOfProd.Game; 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 javax.swing.*;
import java.awt.*; import java.awt.*;
@ -56,6 +59,8 @@ public class WindowOfBattle extends JPanel {
private Game game; private Game game;
private Battle battle; private Battle battle;
private MusicManager musicManager;
public Battle getBattle() { public Battle getBattle() {
return battle; return battle;
} }
@ -100,7 +105,8 @@ public class WindowOfBattle extends JPanel {
} }
public void startBattle(String name) { public void startBattle(String name) {
//saveManager.saveGame(); SaveManager saveManager = new SaveManager(game.getFreeMove().getMapManager());
saveManager.saveGame();
LinkedList<Hero> heroes = new LinkedList<>(); LinkedList<Hero> heroes = new LinkedList<>();
LinkedList<Enemy> enemies = new LinkedList<>(); LinkedList<Enemy> enemies = new LinkedList<>();
@ -120,11 +126,15 @@ public class WindowOfBattle extends JPanel {
Integer.parseInt(data[4]), Integer.parseInt(data[5])); Integer.parseInt(data[4]), Integer.parseInt(data[5]));
enemies.add(enemy); enemies.add(enemy);
} }
else if (data[0].equals("<music>")) {
musicManager = new MusicManager(data[1], Float.parseFloat(data[2]));
}
} }
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
MusicManager musicManager = new MusicManager("Fight_Music.wav", 0.0f);
battle = new Battle(heroes, enemies, this); battle = new Battle(heroes, enemies, this);
isReadyToPaint = true; isReadyToPaint = true;
@ -137,7 +147,13 @@ public class WindowOfBattle extends JPanel {
battle.startBattle(); battle.startBattle();
//loadManager.loadSavedGame(); if (musicManager != null){
musicManager.playMusic();
musicManager.setVolumeToMaxVolume();
}
LoadManager loadManager = new LoadManager(game.getFreeMove().getMapManager());
loadManager.loadSavedGame();
} }
public Canvas getCanvas() { public Canvas getCanvas() {

View File

@ -1,2 +1,3 @@
<hero> 100 10 Mark 1 10 1 <hero> 100 10 Mark 1 10 1
<enemy> 100 10 Karen 10 1 <enemy> 100 10 Karen 10 1
<music> Fight_Music.wav -10.0f

View File

@ -6,6 +6,7 @@
<2> <foreground> null <2> <foreground> null
<4> <foreground> color 0 0 0 100 <4> <foreground> color 0 0 0 100
<5> <foreground> null <5> <foreground> null
<6> <sound> glass-flood-light-bulb-smash.wav 0.0f
<6> <foreground> color 0 0 0 200 <6> <foreground> color 0 0 0 200
<7> <npc> add monster <7> <npc> add monster
<8> <text> image main-face.png <8> <text> image main-face.png

Binary file not shown.

View File

@ -1,80 +0,0 @@
<map>
<mapName>tutorial</mapName>
<events>
<trigger>
<x>11</x>
<y>6</y>
<active>false</active>
</trigger>
</events>
</map>
<map>
<mapName>openspace</mapName>
<events>
<trigger>
<x>6</x>
<y>4</y>
<active>true</active>
</trigger>
<trigger>
<x>14</x>
<y>16</y>
<active>false</active>
</trigger>
<chest>
<x>1</x>
<y>2</y>
<active>true</active>
</chest>
<chest>
<x>15</x>
<y>7</y>
<active>true</active>
</chest>
</events>
</map>
<map>
<mapName>office</mapName>
<events>
<trigger>
<x>4</x>
<y>2</y>
<active>false</active>
</trigger>
<chest>
<x>1</x>
<y>9</y>
<active>true</active>
</chest>
</events>
</map>
<map>
<mapName>boss</mapName>
<events>
<trigger>
<x>4</x>
<y>18</y>
<active>true</active>
</trigger>
</events>
</map>
<map>
<mapName>treasure</mapName>
<events>
<trigger>
<x>6</x>
<y>1</y>
<active>true</active>
</trigger>
</events>
</map>
<map>
<mapName>storageroom</mapName>
<events>
<trigger>
<x>6</x>
<y>2</y>
<active>true</active>
</trigger>
</events>
</map>

View File

@ -1,6 +0,0 @@
<location>
<map>storageroom</map>
<x>6</x>
<y>2</y>
<direction>0</direction>
</location>

Binary file not shown.