test
This commit is contained in:
parent
6c7f9cdef2
commit
2328494c4f
@ -1,6 +1,9 @@
|
||||
package ruscz.game.gameOfProd.Battle;
|
||||
|
||||
import ruscz.game.gameOfProd.Cells.InteractionCell;
|
||||
import ruscz.game.gameOfProd.Dialog.Dialog;
|
||||
import ruscz.game.gameOfProd.Windows.WindowOfBattle;
|
||||
import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@ -96,11 +99,27 @@ public class Battle {
|
||||
}
|
||||
|
||||
private void endBattle(boolean b) {
|
||||
//TODO Return to Map
|
||||
timer.stop();
|
||||
timerStopped = true;
|
||||
if (b) windowOfBattle.writeToOutput("Win!");
|
||||
else windowOfBattle.writeToOutput("Lose!");
|
||||
windowOfBattle.setVisible(false);
|
||||
WindowOfFreeMove windowOfFreeMove = windowOfBattle.getGame().getFreeMove();
|
||||
windowOfBattle.getMenuOfActions().getAttack().removeActionListener(windowOfBattle.getMenuOfActions().getAttack().getActionListeners()[0]);
|
||||
windowOfBattle.getMenuOfActions().getConsole().removeActionListener(windowOfBattle.getMenuOfActions().getConsole().getActionListeners()[0]);
|
||||
windowOfBattle.getMenuOfActions().getEscape().removeActionListener(windowOfBattle.getMenuOfActions().getEscape().getActionListeners()[0]);
|
||||
windowOfBattle.getMenuOfActions().getInventory().removeActionListener(windowOfBattle.getMenuOfActions().getInventory().getActionListeners()[0]);
|
||||
InteractionCell ic;
|
||||
if (b) ic = new InteractionCell(-1, -1, windowOfBattle.getWinCutscene(),
|
||||
new Dialog(windowOfFreeMove.getDialogBar()), windowOfFreeMove.getMapManager().getActualMap(), windowOfFreeMove, true);
|
||||
else ic = new InteractionCell(-1, -1, windowOfBattle.getLoseCutscene(),
|
||||
new Dialog(windowOfFreeMove.getDialogBar()), windowOfFreeMove.getMapManager().getActualMap(), windowOfFreeMove, true);
|
||||
ic.startEvent();
|
||||
windowOfFreeMove.getForegroundPanel().setColorForeground(0, 0, 0, 255);
|
||||
windowOfFreeMove.setVisible(true);
|
||||
windowOfFreeMove.requestFocus();
|
||||
windowOfBattle.getGame().remove(windowOfBattle);
|
||||
windowOfBattle.getMusicManager().stopMusic();
|
||||
// SaveManager saveManager = game.getFreeMove().getMapManager().getSaveManager();
|
||||
// saveManager.saveGame();
|
||||
}
|
||||
|
||||
private void returnControlToPlayer(){
|
||||
|
||||
@ -338,7 +338,7 @@ public class InteractionCell extends Cell {
|
||||
Npc npc = new Npc(Integer.parseInt(position[0]), Integer.parseInt(position[1]), data[3], Map.findMapByName(position[2], window), window.getMapManager());
|
||||
Map.findMapByName(position[2], window).setNpcs(npc);
|
||||
}
|
||||
else if (data[2].contains("move")) {
|
||||
else if (data[2].contains("move") && !data[2].equals("remove")) {
|
||||
Npc npc = window.getMapManager().getActualMap().findNpcByName(data[3]);
|
||||
if (data[2].equals("movetoplayer")) {
|
||||
npc.move(window.getMapManager().getActualMap().getPerson().getX(), window.getMapManager().getActualMap().getPerson().getY());
|
||||
@ -347,6 +347,10 @@ public class InteractionCell extends Cell {
|
||||
npc.move(Integer.parseInt(data[4]), Integer.parseInt(data[5]));
|
||||
}
|
||||
}
|
||||
else if (data[2].equals("remove")) {
|
||||
Npc npc = window.getMapManager().getActualMap().findNpcByName(data[3]);
|
||||
window.getMapManager().getActualMap().getNpcs().remove(npc);
|
||||
}
|
||||
}
|
||||
else if (data[1].equals("<removenpcs>")) window.getMapManager().getActualMap().getNpcs().clear();
|
||||
else if (data[1].equals("<loadnextchapter>")) window.loadNextChapter();
|
||||
|
||||
@ -24,24 +24,23 @@ public class MusicManager {
|
||||
AudioInputStream audioIn;
|
||||
try {
|
||||
audioIn = AudioSystem.getAudioInputStream(new File("src/main/resources/music/" + musicName));
|
||||
clip = AudioSystem.getClip();
|
||||
if (clip != null) {
|
||||
clip.open(audioIn);
|
||||
}
|
||||
if (clip != null) {
|
||||
gainControl =
|
||||
(FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
|
||||
gainControl.setValue(volume);
|
||||
clip.loop(1000);
|
||||
clip.start();
|
||||
}
|
||||
clip = AudioSystem.getClip();
|
||||
if (clip != null) {
|
||||
clip.open(audioIn);
|
||||
}
|
||||
if (clip != null) {
|
||||
gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
|
||||
gainControl.setValue(volume);
|
||||
clip.loop(1000);
|
||||
clip.start();
|
||||
}
|
||||
} catch (LineUnavailableException | IOException | UnsupportedAudioFileException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void stopMusic() {
|
||||
timerOut.stop();
|
||||
if (timerOut != null) timerOut.stop();
|
||||
clip.stop();
|
||||
volume = -40.0f;
|
||||
}
|
||||
|
||||
@ -67,6 +67,10 @@ public class WindowOfBattle extends JPanel {
|
||||
|
||||
private MusicManager musicManager;
|
||||
|
||||
private String winCutscene;
|
||||
private String loseCutscene;
|
||||
private String name;
|
||||
|
||||
public Battle getBattle() {
|
||||
return battle;
|
||||
}
|
||||
@ -108,15 +112,16 @@ public class WindowOfBattle extends JPanel {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
setCursor(Cursor.getDefaultCursor());
|
||||
}
|
||||
|
||||
public void startBattle(String name) {
|
||||
// SaveManager saveManager = game.getFreeMove().getMapManager().getSaveManager();
|
||||
// saveManager.saveGame();
|
||||
|
||||
LinkedList<Hero> heroes = new LinkedList<>();
|
||||
LinkedList<Enemy> enemies = new LinkedList<>();
|
||||
|
||||
this.name = name;
|
||||
|
||||
try {
|
||||
File battleFile = new File("src/main/resources/battles/" + name + ".txt");
|
||||
Scanner scanner = new Scanner(battleFile);
|
||||
@ -141,12 +146,17 @@ public class WindowOfBattle extends JPanel {
|
||||
if (data[1].equals("flicker")) canvas.flicker(Integer.parseInt(data[2]));
|
||||
else canvas.addImage(data[1]);
|
||||
}
|
||||
else if (data[0].equals("<wincutscene>")) {
|
||||
winCutscene = data[1];
|
||||
}
|
||||
else if (data[0].equals("<losecutscene>")) {
|
||||
loseCutscene = data[1];
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
MusicManager musicManager = new MusicManager("Fight_Music.wav", -15.0f);
|
||||
battle = new Battle(heroes, enemies, this);
|
||||
|
||||
isReadyToPaint = true;
|
||||
@ -186,6 +196,23 @@ public class WindowOfBattle extends JPanel {
|
||||
return game;
|
||||
}
|
||||
|
||||
public MusicManager getMusicManager() {
|
||||
return musicManager;
|
||||
}
|
||||
|
||||
public String getWinCutscene() {
|
||||
return winCutscene;
|
||||
}
|
||||
|
||||
public String getLoseCutscene() {
|
||||
return loseCutscene;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
class Canvas extends JPanel {
|
||||
private LinkedList<BufferedImage> images;
|
||||
private BufferedImage image;
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
<hero> 100 10 Mark 1 10 1 main-battle
|
||||
<enemy> 100 10 Karen 10 1 monster-battle hover
|
||||
<enemy> 1 1 Karen 1 1 monster-battle hover
|
||||
<music> Fight_Music.wav -10.0f
|
||||
<image> battle1
|
||||
<image> battle2
|
||||
<image> flicker 500
|
||||
<wincutscene> cutscene-storageroombattle-win
|
||||
<losecutscene> cutscene-storageroombattle-lose
|
||||
@ -0,0 +1,10 @@
|
||||
<1> <npc> remove monster
|
||||
<1> <music> start
|
||||
<1> <doorlock> 6 1 false
|
||||
<1> <foreground> fade 255 0 1
|
||||
<3> <foreground> null
|
||||
<3> <text> image main-face.png
|
||||
<3> <text> Huh,-what-a-weird-encounter.
|
||||
<5> <text> null
|
||||
<5> <personmove> true
|
||||
<5> <end>
|
||||
@ -0,0 +1,10 @@
|
||||
<1> <npc> remove monster
|
||||
<1> <music> start
|
||||
<1> <doorlock> 6 1 false
|
||||
<1> <foreground> fade 255 0 1
|
||||
<3> <foreground> null
|
||||
<3> <text> image main-face.png
|
||||
<3> <text> Huh,-what-a-weird-encounter.
|
||||
<5> <text> null
|
||||
<5> <personmove> true
|
||||
<5> <end>
|
||||
@ -14,7 +14,7 @@
|
||||
<trigger>
|
||||
<x>6</x>
|
||||
<y>4</y>
|
||||
<active>false</active>
|
||||
<active>true</active>
|
||||
</trigger>
|
||||
<trigger>
|
||||
<x>14</x>
|
||||
@ -24,7 +24,7 @@
|
||||
<chest>
|
||||
<x>1</x>
|
||||
<y>2</y>
|
||||
<active>false</active>
|
||||
<active>true</active>
|
||||
</chest>
|
||||
<chest>
|
||||
<x>15</x>
|
||||
@ -74,7 +74,7 @@
|
||||
<trigger>
|
||||
<x>6</x>
|
||||
<y>2</y>
|
||||
<active>true</active>
|
||||
<active>false</active>
|
||||
</trigger>
|
||||
</events>
|
||||
</map>
|
||||
|
||||
@ -1,6 +0,0 @@
|
||||
<item>
|
||||
<name>cup-o'-coffee</name>
|
||||
<multiplicity>1</multiplicity>
|
||||
<image>295</image>
|
||||
<action>heal</action>
|
||||
</item>
|
||||
@ -1,6 +1,6 @@
|
||||
<location>
|
||||
<map>storageroom</map>
|
||||
<x>6</x>
|
||||
<y>2</y>
|
||||
<direction>0</direction>
|
||||
<map>office</map>
|
||||
<x>2</x>
|
||||
<y>11</y>
|
||||
<direction>2</direction>
|
||||
</location>
|
||||
Loading…
x
Reference in New Issue
Block a user