Battle fix
This commit is contained in:
parent
a4c49e1439
commit
414a6602ed
@ -132,10 +132,10 @@ public class WindowOfBattle extends JPanel {
|
||||
});
|
||||
}
|
||||
|
||||
public void startBattle(){
|
||||
public void startBattle() {
|
||||
Hero hero = new Hero(100, 1, "Mark", 1, 100, 1);
|
||||
Enemy enemy1 = new Enemy(10, 1, "123", 1, 1);
|
||||
Enemy enemy2 = new Enemy(10, 1, "test", 1, 2);
|
||||
Enemy enemy2 = new Enemy(10, 1, "test", 1, 2);
|
||||
|
||||
LinkedList<Hero> a = new LinkedList<>();
|
||||
a.add(hero);
|
||||
@ -147,16 +147,14 @@ public class WindowOfBattle extends JPanel {
|
||||
battle = new Battle(a, b, this);
|
||||
|
||||
isReadyToPaint = true;
|
||||
Thread repainting = new Thread(() -> {
|
||||
Timer t = new Timer(10, actionEvent -> {
|
||||
canvas.repaint();
|
||||
if (situationText.isVisible()){
|
||||
situationText.repaint();
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
Timer t = new Timer(10, actionEvent -> {
|
||||
repaint();
|
||||
canvas.repaint();
|
||||
if (situationText.isVisible()) {
|
||||
situationText.repaint();
|
||||
}
|
||||
});
|
||||
repainting.start();
|
||||
t.start();
|
||||
|
||||
battle.startBattle();
|
||||
}
|
||||
@ -168,13 +166,13 @@ public class WindowOfBattle extends JPanel {
|
||||
public void writeToOutput(String s) {
|
||||
System.out.println(s);
|
||||
Font f = new Font(Font.SERIF, Font.BOLD, 20);
|
||||
if (situationText.getComponents().length != 0)
|
||||
situationText.remove(0);
|
||||
JLabel text = new JLabel();
|
||||
text.setText(s);
|
||||
text.setFont(f);
|
||||
situationText.add(text);
|
||||
situationText.getComponents()[0].repaint();
|
||||
if (situationText.getComponents().length == 0) {
|
||||
JLabel text = new JLabel();
|
||||
situationText.add(text);
|
||||
}
|
||||
JLabel jLabel = (JLabel) situationText.getComponents()[0];
|
||||
jLabel.setText(s);
|
||||
jLabel.setFont(f);
|
||||
repaint();
|
||||
}
|
||||
|
||||
@ -182,11 +180,11 @@ public class WindowOfBattle extends JPanel {
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
super.paint(g);
|
||||
if (isReadyToPaint){
|
||||
for (Enemy battlePerson: battle.getEnemies()){
|
||||
battlePerson.paint(g, CELL_SIZE * 2, CELL_SIZE *3 * battlePerson.getId());
|
||||
if (isReadyToPaint) {
|
||||
for (Enemy battlePerson : battle.getEnemies()) {
|
||||
battlePerson.paint(g, CELL_SIZE * 2, CELL_SIZE * 3 * battlePerson.getId());
|
||||
}
|
||||
for (BattlePerson battlePerson: battle.getHeroes()){
|
||||
for (BattlePerson battlePerson : battle.getHeroes()) {
|
||||
battlePerson.paint(g, CELL_SIZE * 12, CELL_SIZE * 4);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,65 @@
|
||||
<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>15</x>
|
||||
<y>7</y>
|
||||
<active>false</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>false</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>
|
||||
@ -0,0 +1,6 @@
|
||||
<item>
|
||||
<name>white-key-card</name>
|
||||
<multiplicity>1</multiplicity>
|
||||
<image>19</image>
|
||||
<action>key</action>
|
||||
</item>
|
||||
@ -0,0 +1,6 @@
|
||||
<location>
|
||||
<map>office</map>
|
||||
<x>8</x>
|
||||
<y>6</y>
|
||||
<direction>3</direction>
|
||||
</location>
|
||||
@ -0,0 +1 @@
|
||||
TODO: Village
|
||||
Loading…
x
Reference in New Issue
Block a user