Description
This commit is contained in:
parent
6c7f9cdef2
commit
c3c5c0d33e
BIN
Game_of_Prod.zip
Normal file
BIN
Game_of_Prod.zip
Normal file
Binary file not shown.
@ -158,4 +158,8 @@ public abstract class BattlePerson {
|
|||||||
public int getStrength() {
|
public int getStrength() {
|
||||||
return strength;
|
return strength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMaxHealth() {
|
||||||
|
return maxHealth;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,74 @@
|
|||||||
package ruscz.game.gameOfProd.BattleUI;
|
package ruscz.game.gameOfProd.BattleUI;
|
||||||
|
|
||||||
|
import ruscz.game.gameOfProd.Battle.BattlePerson;
|
||||||
import ruscz.game.gameOfProd.Windows.WindowOfBattle;
|
import ruscz.game.gameOfProd.Windows.WindowOfBattle;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import static ruscz.game.gameOfProd.Windows.WindowOfBattle.*;
|
import static ruscz.game.gameOfProd.Windows.WindowOfBattle.*;
|
||||||
|
|
||||||
public class EnemyDescription extends JPanel {
|
public class EnemyDescription extends JPanel {
|
||||||
|
|
||||||
|
private final WindowOfBattle windowOfBattle;
|
||||||
|
|
||||||
public EnemyDescription(WindowOfBattle window) {
|
public EnemyDescription(WindowOfBattle window) {
|
||||||
|
windowOfBattle = window;
|
||||||
|
|
||||||
setSize(CELL_SIZE * CANVAS_WIDTH * 2 / 3, CELL_SIZE * CANVAS_HEIGHT / 4);
|
setSize(CELL_SIZE * CANVAS_WIDTH * 2 / 3, CELL_SIZE * CANVAS_HEIGHT / 4);
|
||||||
setLocation(0, CELL_SIZE * CANVAS_HEIGHT * 3 / 4);
|
setLocation(0, CELL_SIZE * CANVAS_HEIGHT * 3 / 4);
|
||||||
setBackground(Color.cyan);
|
setBackground(Color.cyan);
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
|
|
||||||
|
updateDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateDescription() {
|
||||||
|
Timer timer = new Timer(1000, e -> {
|
||||||
|
if (isVisible()){
|
||||||
|
deletePreviousDescription();
|
||||||
|
addNewDescription();
|
||||||
|
revalidate();
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
timer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addNewDescription() {
|
||||||
|
if (getComponentCount() != 0) return;
|
||||||
|
if (windowOfBattle.getBattle() == null) return;
|
||||||
|
|
||||||
|
LinkedList<BattlePerson> he = new LinkedList<>(windowOfBattle.getBattle().getHeroes());
|
||||||
|
he.addAll(windowOfBattle.getBattle().getEnemies());
|
||||||
|
|
||||||
|
setLayout(new GridLayout (he.size() + 1, 3));
|
||||||
|
|
||||||
|
for (BattlePerson person: he){
|
||||||
|
JPanel jPanel = new JPanel();
|
||||||
|
JLabel name = new JLabel(person.getName());
|
||||||
|
JLabel level = new JLabel("Level: " + person.getLevel());
|
||||||
|
JLabel health = new JLabel("Health: " + person.getHealth() + "/" + person.getMaxHealth());
|
||||||
|
jPanel.add(name);
|
||||||
|
jPanel.add(level);
|
||||||
|
jPanel.add(health);
|
||||||
|
|
||||||
|
add(jPanel);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println(Arrays.toString(getComponents()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deletePreviousDescription() {
|
||||||
|
if (getComponentCount() == 0) return;
|
||||||
|
for (Component c: getComponents())
|
||||||
|
remove(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
<trigger>
|
<trigger>
|
||||||
<x>6</x>
|
<x>6</x>
|
||||||
<y>4</y>
|
<y>4</y>
|
||||||
<active>false</active>
|
<active>true</active>
|
||||||
</trigger>
|
</trigger>
|
||||||
<trigger>
|
<trigger>
|
||||||
<x>14</x>
|
<x>14</x>
|
||||||
@ -24,7 +24,7 @@
|
|||||||
<chest>
|
<chest>
|
||||||
<x>1</x>
|
<x>1</x>
|
||||||
<y>2</y>
|
<y>2</y>
|
||||||
<active>false</active>
|
<active>true</active>
|
||||||
</chest>
|
</chest>
|
||||||
<chest>
|
<chest>
|
||||||
<x>15</x>
|
<x>15</x>
|
||||||
|
|||||||
@ -1,6 +0,0 @@
|
|||||||
<item>
|
|
||||||
<name>cup-o'-coffee</name>
|
|
||||||
<multiplicity>1</multiplicity>
|
|
||||||
<image>295</image>
|
|
||||||
<action>heal</action>
|
|
||||||
</item>
|
|
||||||
Loading…
x
Reference in New Issue
Block a user