Merge branch 'master' of gitlab.fel.cvut.cz:B192_B0B36PJV/iryupnik
This commit is contained in:
commit
3c91433a23
@ -2,6 +2,7 @@ package ruscz.game.gameOfProd.Battle;
|
||||
|
||||
import ruscz.game.gameOfProd.Cells.InteractionCell;
|
||||
import ruscz.game.gameOfProd.Dialog.Dialog;
|
||||
import ruscz.game.gameOfProd.Sounds.SoundManager;
|
||||
import ruscz.game.gameOfProd.Windows.WindowOfBattle;
|
||||
import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
|
||||
|
||||
@ -17,9 +18,7 @@ public class Battle {
|
||||
private final WindowOfBattle windowOfBattle;
|
||||
private Timer timer;
|
||||
|
||||
public void setTurnBelongTo(BattlePerson turnBelongTo) {
|
||||
this.turnBelongTo = turnBelongTo;
|
||||
}
|
||||
private final SoundManager soundManager;
|
||||
|
||||
private BattlePerson turnBelongTo;
|
||||
|
||||
@ -42,10 +41,6 @@ public class Battle {
|
||||
|
||||
private boolean timerStopped;
|
||||
|
||||
public BattlePerson getTurnBelongTo() {
|
||||
return turnBelongTo;
|
||||
}
|
||||
|
||||
public void setPlayerAttack(boolean playerAttack) {
|
||||
windowOfBattle.getMenuOfActions().setVisible(false);
|
||||
windowOfBattle.getEnemyDescription().setVisible(false);
|
||||
@ -56,6 +51,7 @@ public class Battle {
|
||||
this.heroes = heroes;
|
||||
this.enemies = enemies;
|
||||
this.windowOfBattle = window;
|
||||
soundManager = new SoundManager();
|
||||
}
|
||||
|
||||
public LinkedList<Enemy> getEnemies() {
|
||||
@ -81,7 +77,6 @@ public class Battle {
|
||||
windowOfBattle.repaint();
|
||||
turnOrder = new LinkedList<>();
|
||||
timer = new Timer(1000, actionEvent -> {
|
||||
for (Enemy e: enemies) System.out.println(e.health);
|
||||
if (checkHealthOfEnemies()) endBattle(true);
|
||||
if (checkHealthOfHeroes()) endBattle(false);
|
||||
if(playerAttack)
|
||||
@ -136,9 +131,9 @@ public class Battle {
|
||||
turnCount++;
|
||||
windowOfBattle.repaint();
|
||||
turnBelongTo.attack(e);
|
||||
if (windowOfBattle.getHitSound() != null) soundManager.playSound(windowOfBattle.getHitSound(), 6.0f);
|
||||
|
||||
windowOfBattle.writeToOutput(turnBelongTo.getName() + " deal " + turnBelongTo.getLevel() * turnBelongTo.getStrength() + " to " + e.getName());
|
||||
//TODO Animation of Attack
|
||||
windowOfBattle.writeToOutput(turnBelongTo.getName() + " deal " + turnBelongTo.getLevel() * turnBelongTo.getStrength() + " damage to " + e.getName()+"!");
|
||||
//TODO Animation of Death
|
||||
if (e.health <= 0) enemies.remove(e);
|
||||
|
||||
@ -156,26 +151,27 @@ public class Battle {
|
||||
LinkedList<BattlePerson> turns = new LinkedList<>(enemies);
|
||||
turns.addAll(heroes);
|
||||
|
||||
if (checkIfTurnOrderIsFull(turns))
|
||||
BattlePerson last = turnOrder.getLast();
|
||||
if (checkIfTurnOrderIsFull(turns)) {
|
||||
turnOrder = new LinkedList<>();
|
||||
}
|
||||
|
||||
Collections.shuffle(turns);
|
||||
turnBelongTo = turns.getFirst();
|
||||
|
||||
while (turnOrder.contains(turnBelongTo)){
|
||||
while (turnOrder.contains(turnBelongTo) || turnBelongTo.equals(last)){
|
||||
turns.remove(turnBelongTo);
|
||||
Collections.shuffle(turns);
|
||||
turnBelongTo = turns.getFirst();
|
||||
}
|
||||
|
||||
System.out.println(turnBelongTo.getClass().getName());
|
||||
}
|
||||
|
||||
private void attackByMonster(Hero e) {
|
||||
turnCount++;
|
||||
turnBelongTo.attack(e);
|
||||
if (windowOfBattle.getHitSound() != null) soundManager.playSound(windowOfBattle.getHitSound(), 6.0f);
|
||||
|
||||
windowOfBattle.writeToOutput(turnBelongTo.getName() + " deal " + turnBelongTo.getLevel() * turnBelongTo.getStrength() + " to " + e.getName());
|
||||
//TODO Animation of Attack
|
||||
windowOfBattle.writeToOutput(turnBelongTo.getName() + " deal " + turnBelongTo.getLevel() + " damage to " + e.getName()+"!");
|
||||
//TODO Animation of Death
|
||||
if (e.health <= 0) heroes.remove(e);
|
||||
|
||||
@ -200,8 +196,8 @@ public class Battle {
|
||||
return timer;
|
||||
}
|
||||
|
||||
public boolean isPlayerAttack() {
|
||||
return playerAttack;
|
||||
public void setTurnBelongTo(BattlePerson turnBelongTo) {
|
||||
this.turnBelongTo = turnBelongTo;
|
||||
}
|
||||
|
||||
private boolean checkIfTurnOrderIsFull(LinkedList<BattlePerson> allBattlePerson){
|
||||
|
||||
@ -48,18 +48,21 @@ public class EnemyDescription extends JPanel {
|
||||
setLayout(new GridLayout (he.size() + 1, 3));
|
||||
|
||||
for (BattlePerson person: he){
|
||||
Font f = new Font(Font.DIALOG, Font.BOLD, 20);
|
||||
|
||||
JPanel jPanel = new JPanel();
|
||||
JLabel name = new JLabel(person.getName());
|
||||
name.setFont(f);
|
||||
JLabel level = new JLabel("Level: " + person.getLevel());
|
||||
level.setFont(f);
|
||||
JLabel health = new JLabel("Health: " + person.getHealth() + "/" + person.getMaxHealth());
|
||||
health.setFont(f);
|
||||
jPanel.add(name);
|
||||
jPanel.add(level);
|
||||
jPanel.add(health);
|
||||
|
||||
add(jPanel);
|
||||
}
|
||||
|
||||
System.out.println(Arrays.toString(getComponents()));
|
||||
}
|
||||
|
||||
private void deletePreviousDescription() {
|
||||
|
||||
@ -54,15 +54,15 @@ public class WindowOfBattle extends JPanel {
|
||||
return itemsInventory;
|
||||
}
|
||||
|
||||
private Canvas canvas;
|
||||
private SituationText situationText;
|
||||
private EnemyDescription enemyDescription;
|
||||
private MenuOfActions menuOfActions;
|
||||
private ConsoleInput consoleInput;
|
||||
private CommandList commandList;
|
||||
private ItemsInventory itemsInventory;
|
||||
private final Canvas canvas;
|
||||
private final SituationText situationText;
|
||||
private final EnemyDescription enemyDescription;
|
||||
private final MenuOfActions menuOfActions;
|
||||
private final ConsoleInput consoleInput;
|
||||
private final CommandList commandList;
|
||||
private final ItemsInventory itemsInventory;
|
||||
|
||||
private Game game;
|
||||
private final Game game;
|
||||
private Battle battle;
|
||||
|
||||
private MusicManager musicManager;
|
||||
@ -71,6 +71,8 @@ public class WindowOfBattle extends JPanel {
|
||||
private String loseCutscene;
|
||||
private String name;
|
||||
|
||||
private String hitSound;
|
||||
|
||||
public Battle getBattle() {
|
||||
return battle;
|
||||
}
|
||||
@ -152,6 +154,9 @@ public class WindowOfBattle extends JPanel {
|
||||
else if (data[0].equals("<losecutscene>")) {
|
||||
loseCutscene = data[1];
|
||||
}
|
||||
else if (data[0].equals("<attacksound>")){
|
||||
hitSound = data[1];
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
@ -213,6 +218,10 @@ public class WindowOfBattle extends JPanel {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getHitSound() {
|
||||
return hitSound;
|
||||
}
|
||||
|
||||
class Canvas extends JPanel {
|
||||
private LinkedList<BufferedImage> images;
|
||||
private BufferedImage image;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<hero> 100 10 Mark 1 10 1 main-battle
|
||||
<enemy> 1 1 Karen 1 1 monster-battle hover
|
||||
<enemy> 120 10 Karen 10 1 monster-battle hover
|
||||
<music> Fight_Music.wav -10.0f
|
||||
<attacksound> hit.wav
|
||||
<image> battle1
|
||||
<image> battle2
|
||||
<image> flicker 500
|
||||
|
||||
BIN
src/main/resources/sounds/hit.wav
Normal file
BIN
src/main/resources/sounds/hit.wav
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user