added storage room, fight cutscene & battle start

This commit is contained in:
musilto9 2020-06-03 02:24:38 +02:00
parent c134d5e1d9
commit e117e03ecf
21 changed files with 251 additions and 66 deletions

View File

@ -313,6 +313,41 @@ public class InteractionCell extends Cell {
window.getMusicManager().fadeOut(10); window.getMusicManager().fadeOut(10);
} }
} }
else if (data[1].equals("<sound>")) {
window.getMapManager().getActualMap().getSoundManager().playSound(data[2], Float.parseFloat(data[3]));
}
else if (data[1].equals("<doorlock>")) {
DoorCell door = window.getMapManager().getActualMap().findDoorByXY(Integer.parseInt(data[2]), Integer.parseInt(data[3]));
if (Boolean.parseBoolean(data[4])) {
door.message = "locked";
door.dialog = new Dialog(window.getDialogBar());
door.setOpen(false);
door.setLocked(true);
}
else {
door.setLocked(false);
door.message = null;
door.dialog = null;
}
}
else if (data[1].equals("<npc>")) {
if (data[2].equals("add")) {
File npcFile = new File("src/main/resources/characters/" + data[3] + ".txt");
Scanner sc = new Scanner(npcFile);
String[] position = sc.nextLine().split(" ");
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")) {
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());
}
else {
npc.move(Integer.parseInt(data[4]), Integer.parseInt(data[5]));
}
}
}
else if (data[1].equals("<removenpcs>")) window.getMapManager().getActualMap().getNpcs().clear(); else if (data[1].equals("<removenpcs>")) window.getMapManager().getActualMap().getNpcs().clear();
else if (data[1].equals("<loadnextchapter>")) window.loadNextChapter(); else if (data[1].equals("<loadnextchapter>")) window.loadNextChapter();
else if (data[1].equals("<closegame>")) { else if (data[1].equals("<closegame>")) {

View File

@ -4,14 +4,15 @@ import ruscz.game.gameOfProd.Map.Map;
import ruscz.game.gameOfProd.Map.MapManager; import ruscz.game.gameOfProd.Map.MapManager;
import ruscz.game.gameOfProd.Scripts.Direction; import ruscz.game.gameOfProd.Scripts.Direction;
import ruscz.game.gameOfProd.Scripts.PathFinder; import ruscz.game.gameOfProd.Scripts.PathFinder;
import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.LinkedList;
import java.util.Scanner; import java.util.Scanner;
public class Npc extends Person { public class Npc extends Person {
@ -25,6 +26,8 @@ public class Npc extends Person {
private int widthCoef; private int widthCoef;
private int heightCoef; private int heightCoef;
private String imageNpc; private String imageNpc;
private String battle;
private Timer timer;
public Npc(int x, int y, String name, Map map, MapManager mapManager) { public Npc(int x, int y, String name, Map map, MapManager mapManager) {
super(x, y, map); super(x, y, map);
@ -33,6 +36,14 @@ public class Npc extends Person {
loadNpc(); loadNpc();
} }
public Npc(int x, int y, String name, String battle, Map map, MapManager mapManager) {
super(x, y, map);
this.name = name;
this.battle = battle;
this.mapManager = mapManager;
loadNpc();
}
public Npc(int x, int y, Map map, MapManager mapManager) { public Npc(int x, int y, Map map, MapManager mapManager) {
super(x, y, map); super(x, y, map);
this.mapManager = mapManager; this.mapManager = mapManager;
@ -40,44 +51,67 @@ public class Npc extends Person {
public void move(int endX, int endY) { public void move(int endX, int endY) {
PathFinder pathFinder = new PathFinder(getMap()); PathFinder pathFinder = new PathFinder(getMap());
for (Direction direction: pathFinder.getWayWithCollision(getX(), getY(), endX, endY)){ LinkedList<Direction> directions = pathFinder.getWayWithCollision(getX(), getY(), endX, endY);
WindowOfFreeMove.sleep(500); if (endX == mapManager.getActualMap().getPerson().getX() && endY == mapManager.getActualMap().getPerson().getY()) {
switch (direction){ directions.removeLast();
case UP: }
moveUp(); final int[] i = {0};
break; timer = new Timer(500, actionEvent -> {
case DOWN: if (i[0] == directions.size()) stopTimer(endX, endY);
moveDown(); else {
break; switch (directions.get(i[0])) {
case LEFT: case UP:
moveLeft(); moveUp();
break; break;
case RIGHT: case DOWN:
moveRight(); moveDown();
break; break;
case LEFT:
moveLeft();
break;
case RIGHT:
moveRight();
break;
}
if (name.equals("monster")) {
getMap().getSoundManager().playSound("monstersound.wav", 0.0f);
}
} }
mapManager.repaintCanvas(); mapManager.repaintCanvas();
i[0]++;
});
timer.start();
}
private void stopTimer(int endX, int endY) {
timer.stop();
if (battle != null && endX == mapManager.getActualMap().getPerson().getX() && endY == mapManager.getActualMap().getPerson().getY()) {
mapManager.getWindow().startBattle(battle);
} }
} }
private void moveUp() { private void moveUp() {
int y = getY() - 1; int y = getY() - 1;
set(getX(), y); set(getX(), y);
direction = 3;
} }
private void moveDown() { private void moveDown() {
int y = getY() + 1; int y = getY() + 1;
set(getX(), y); set(getX(), y);
direction = 1;
} }
private void moveLeft() { private void moveLeft() {
int x = getX() - 1; int x = getX() - 1;
set(x, getY()); set(x, getY());
direction = 2;
} }
private void moveRight() { private void moveRight() {
int x = getX() + 1; int x = getX() + 1;
set(x, getY()); set(x, getY());
direction = 0;
} }
private void loadNpc() { private void loadNpc() {
@ -98,6 +132,7 @@ public class Npc extends Person {
widthCoef = Integer.parseInt(imageInfo[5]); widthCoef = Integer.parseInt(imageInfo[5]);
heightCoef = Integer.parseInt(imageInfo[6]); heightCoef = Integer.parseInt(imageInfo[6]);
imageNpc = scanner.nextLine(); imageNpc = scanner.nextLine();
if (scanner.hasNextLine()) battle = scanner.nextLine();
} }
@Override @Override

View File

@ -7,7 +7,10 @@ import ruscz.game.gameOfProd.Game;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Scanner;
public class WindowOfBattle extends JPanel { public class WindowOfBattle extends JPanel {
@ -96,22 +99,33 @@ public class WindowOfBattle extends JPanel {
}); });
} }
public void startBattle() { public void startBattle(String name) {
//saveManager.saveGame(); //saveManager.saveGame();
//TODO Enemies from Files LinkedList<Hero> heroes = new LinkedList<>();
Hero hero = new Hero(100, 100, "Mark", 1, 100, 1); LinkedList<Enemy> enemies = new LinkedList<>();
Enemy enemy1 = new Enemy(10, 1, "123", 1, 1);
Enemy enemy2 = new Enemy(10, 1, "test", 1, 2);
LinkedList<Hero> a = new LinkedList<>(); try {
a.add(hero); File battleFile = new File("src/main/resources/battles/" + name + ".txt");
Scanner scanner = new Scanner(battleFile);
while(scanner.hasNextLine()) {
String[] data = scanner.nextLine().split(" ");
if (data[0].equals("<hero>")) {
Hero hero = new Hero(Integer.parseInt(data[1]), Integer.parseInt(data[2]), data[3],
Integer.parseInt(data[4]), Integer.parseInt(data[5]), Integer.parseInt(data[6]));
heroes.add(hero);
}
else if (data[0].equals("<enemy>")) {
Enemy enemy = new Enemy(Integer.parseInt(data[1]), Integer.parseInt(data[2]), data[3],
Integer.parseInt(data[4]), Integer.parseInt(data[5]));
enemies.add(enemy);
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
LinkedList<Enemy> b = new LinkedList<>(); battle = new Battle(heroes, enemies, this);
b.add(enemy1);
b.add(enemy2);
battle = new Battle(a, b, this);
isReadyToPaint = true; isReadyToPaint = true;
Timer t = new Timer(10, actionEvent -> { Timer t = new Timer(10, actionEvent -> {

View File

@ -2,6 +2,7 @@ package ruscz.game.gameOfProd.Windows;
import ruscz.game.gameOfProd.Cells.*; import ruscz.game.gameOfProd.Cells.*;
import ruscz.game.gameOfProd.Dialog.DialogBar; import ruscz.game.gameOfProd.Dialog.DialogBar;
import ruscz.game.gameOfProd.Game;
import ruscz.game.gameOfProd.Map.Map; import ruscz.game.gameOfProd.Map.Map;
import ruscz.game.gameOfProd.Map.MapManager; import ruscz.game.gameOfProd.Map.MapManager;
import ruscz.game.gameOfProd.Sounds.MusicManager; import ruscz.game.gameOfProd.Sounds.MusicManager;
@ -45,7 +46,7 @@ public class WindowOfFreeMove extends JLayeredPane {
private static String CHAPTER = "0"; private static String CHAPTER = "0";
private JFrame game; private Game game;
private Canvas canvas; private Canvas canvas;
private DialogBar dialogBar; private DialogBar dialogBar;
private MapManager mapManager; private MapManager mapManager;
@ -104,11 +105,11 @@ public class WindowOfFreeMove extends JLayeredPane {
public MusicManager getMusicManager() { return musicManager; } public MusicManager getMusicManager() { return musicManager; }
public JFrame getGame() { public Game getGame() {
return game; return game;
} }
public WindowOfFreeMove(JFrame game) { public WindowOfFreeMove(Game game) {
this.game = game; this.game = game;
isReadyToPaint = false; isReadyToPaint = false;
canPersonMove = true; canPersonMove = true;
@ -218,6 +219,13 @@ public class WindowOfFreeMove extends JLayeredPane {
isReadyToPaint = true; isReadyToPaint = true;
} }
public void startBattle(String name) {
setVisible(false);
WindowOfBattle battle = game.getBattle();
mapManager.getWindow().getGame().add(battle);
battle.startBattle(name);
}
public class Canvas extends JPanel { public class Canvas extends JPanel {
@Override @Override
public void paint(Graphics g) { public void paint(Graphics g) {

View File

@ -0,0 +1,2 @@
<hero> 100 10 Mark 1 10 1
<enemy> 100 10 Karen 10 1

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,4 @@
7 7 storageroom
34 86 1 0 0 3 3
monster.png
storageroombattle

View File

@ -1,6 +1,4 @@
What did one boob say to the other? What did one boob say to the other?
You are my breastfriend You are my breastfriend
*badumm tits* *badumm tits*
ěščřžzýáíé
Главное чтобы я шарила в том, что вы творите
<end> <end>

View File

@ -0,0 +1,17 @@
<1> <personmove> false
<1> <music> end
<1> <doorlock> 6 1 true
<1> <sound> qubodup-DoorClose02-changed.wav -8.0f
<1> <foreground> color 0 0 0 100
<2> <foreground> null
<4> <foreground> color 0 0 0 100
<5> <foreground> null
<6> <foreground> color 0 0 0 200
<7> <npc> add monster
<8> <text> image main-face.png
<8> <text> Oh-no.-I-really-don't-like-this.<br/>I-want-to-get-out-now!
<11> <text> null
<11> <personmove> true
<17> <personmove> false
<17> <npc> movetoplayer monster
<18> <end>

View File

@ -9,20 +9,20 @@
<cellmap> DOOR dark-door.png,32 <cellmap> DOOR dark-door.png,32
<cellmap> CHEST 390 <cellmap> CHEST 390
<soundmap> DOOR qubodup-DoorOpen01-changed.wav qubodup-DoorClose02-changed.wav doorLocked.wav <soundmap> DOOR qubodup-DoorOpen01-changed.wav qubodup-DoorClose02-changed.wav doorLocked.wav
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 86 86 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 86 86 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 86 86 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 86 86 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6

View File

@ -11,4 +11,4 @@ BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK EMPTY EMPTY EMPTY BLOCK BL
BLOCK CHEST,trashcan,true EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK BLOCK CHEST,trashcan,true EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY block BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY block
BLOCK BLOCK,d EMPTY BLOCK,d BLOCK,d BLOCK,d BLOCK,d EMPTY BLOCK,d BLOCK,d BLOCK,d BLOCK,d EMPTY BLOCK,d BLOCK,d BLOCK,d BLOCK,d EMPTY BLOCK,d BLOCK BLOCK BLOCK,d EMPTY BLOCK,d BLOCK,d BLOCK,d BLOCK,d EMPTY BLOCK,d BLOCK,d BLOCK,d BLOCK,d EMPTY BLOCK,d BLOCK,d BLOCK,d BLOCK,d EMPTY BLOCK,d BLOCK
BLOCK BLOCK DOOR,true,locked BLOCK BLOCK BLOCK BLOCK DOOR,true,locked BLOCK BLOCK BLOCK BLOCK DOOR,true,locked BLOCK BLOCK BLOCK BLOCK DOORTO,locked,true,white-key-card,3,1,treasure BLOCK BLOCK BLOCK BLOCK DOORTO,true,4,1,storageroom BLOCK BLOCK BLOCK BLOCK DOOR,true,locked BLOCK BLOCK BLOCK BLOCK DOOR,true,locked BLOCK BLOCK BLOCK BLOCK DOORTO,locked,true,white-key-card,3,1,treasure BLOCK BLOCK

View File

@ -0,0 +1,13 @@
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0

View File

@ -0,0 +1,24 @@
<tileset> A5_Tiles.png
<tileset> Openspace1.png
<tileset> Openspace2.png
<tileset> D_Inside_House.png
<cellmap> BLOCK 2
<cellmap> MOVETO 1
<cellmap> EVENT 0
<cellmap> TRIGGER 4
<cellmap> CHEST 254
<cellmap> DOOR dark-door.png,32
<soundmap> DOOR qubodup-DoorOpen01-changed.wav qubodup-DoorClose02-changed.wav doorLocked.wav
0 0 0 0 0 0 0 0 0 0 0 0 0
6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6

View File

@ -0,0 +1,14 @@
13 13
BLOCK,d BLOCK,d BLOCK,d BLOCK,d BLOCK,d BLOCK,d EMPTY BLOCK,d BLOCK,d BLOCK,d BLOCK,d BLOCK,d BLOCK,d
BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK DOORTO,true,4,3,office BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY TRIGGER,cutscene-fight EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK
BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK

View File

@ -3,6 +3,6 @@
<0> office <0> office
<0> boss <0> boss
<0> treasure <0> treasure
<1> glade <0> storageroom
<999> m1 <999> m1
<999> m6 <999> m6

View File

@ -14,12 +14,12 @@
<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>
<y>16</y> <y>16</y>
<active>true</active> <active>false</active>
</trigger> </trigger>
<chest> <chest>
<x>1</x> <x>1</x>
@ -54,7 +54,7 @@
<trigger> <trigger>
<x>4</x> <x>4</x>
<y>18</y> <y>18</y>
<active>false</active> <active>true</active>
</trigger> </trigger>
</events> </events>
</map> </map>
@ -68,3 +68,13 @@
</trigger> </trigger>
</events> </events>
</map> </map>
<map>
<mapName>storageroom</mapName>
<events>
<trigger>
<x>6</x>
<y>2</y>
<active>true</active>
</trigger>
</events>
</map>

View File

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

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

View File

@ -8,9 +8,9 @@ import org.junit.jupiter.params.provider.MethodSource;
import ruscz.game.gameOfProd.Cells.*; import ruscz.game.gameOfProd.Cells.*;
import ruscz.game.gameOfProd.Dialog.Dialog; import ruscz.game.gameOfProd.Dialog.Dialog;
import ruscz.game.gameOfProd.Dialog.DialogBar; import ruscz.game.gameOfProd.Dialog.DialogBar;
import ruscz.game.gameOfProd.Game;
import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
import javax.swing.*;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.Scanner; import java.util.Scanner;
@ -24,13 +24,16 @@ public class MapTest {
@Test @Test
public void loadMapFromFile_parseMapFileToMapArray_mapArrayParsedCorrectly() { public void loadMapFromFile_parseMapFileToMapArray_mapArrayParsedCorrectly() {
//Arrange //Arrange
Map testMap, testMap2; Map testMap;
Game game;
TypeOfCell[][] mapArray; TypeOfCell[][] mapArray;
WindowOfFreeMove window; WindowOfFreeMove window;
//Act //Act
game = new Game();
game.setVisible(false);
mapArray = parseMap("m6"); mapArray = parseMap("m6");
window = new WindowOfFreeMove(new JFrame()); window = new WindowOfFreeMove(game);
window.setCHAPTER("999"); window.setCHAPTER("999");
testMap = Map.loadMapFromFile("m6", window); testMap = Map.loadMapFromFile("m6", window);
@ -43,7 +46,9 @@ public class MapTest {
} }
public static Stream<Arguments> argumentsStream() { public static Stream<Arguments> argumentsStream() {
WindowOfFreeMove window = new WindowOfFreeMove(new JFrame()); Game game = new Game();
game.setVisible(false);
WindowOfFreeMove window = new WindowOfFreeMove(game);
Dialog dialog = new Dialog(new DialogBar()); Dialog dialog = new Dialog(new DialogBar());
Map map = new Map(new TypeOfCell[1][1]); Map map = new Map(new TypeOfCell[1][1]);
map.setName("test"); map.setName("test");
@ -63,13 +68,16 @@ public class MapTest {
@MethodSource("argumentsStream") @MethodSource("argumentsStream")
public void loadMapFromFile_parseStringToCorrectObject_MapObjectParsedCorrectly(Cell cell, String cellText) { public void loadMapFromFile_parseStringToCorrectObject_MapObjectParsedCorrectly(Cell cell, String cellText) {
//Arrange //Arrange
Game game;
Map testMap; Map testMap;
WindowOfFreeMove window; WindowOfFreeMove window;
//Act //Act
game = new Game();
game.setVisible(false);
testMap = new Map(new TypeOfCell[1][1]); testMap = new Map(new TypeOfCell[1][1]);
String[] size = {"1", "1"}; String[] size = {"1", "1"};
window= new WindowOfFreeMove(new JFrame()); window= new WindowOfFreeMove(game);
Map.loadMap(testMap, cellText, size, 0, window); Map.loadMap(testMap, cellText, size, 0, window);
//Assert //Assert

View File

@ -5,10 +5,10 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.MethodSource;
import ruscz.game.gameOfProd.Cells.Npc; import ruscz.game.gameOfProd.Cells.Npc;
import ruscz.game.gameOfProd.Game;
import ruscz.game.gameOfProd.Map.Map; import ruscz.game.gameOfProd.Map.Map;
import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
import javax.swing.*;
import java.util.stream.Stream; import java.util.stream.Stream;
public class PathFinderTest { public class PathFinderTest {
@ -51,12 +51,15 @@ public class PathFinderTest {
@MethodSource("argumentsStream") @MethodSource("argumentsStream")
public void getWayWithCollision_usingMap6ForTestOfPathFinding_rightPositionOfNpc(int startX, int startY, int endX, int endY, boolean isPossible) { public void getWayWithCollision_usingMap6ForTestOfPathFinding_rightPositionOfNpc(int startX, int startY, int endX, int endY, boolean isPossible) {
//Arrange //Arrange
Game game;
WindowOfFreeMove freeMove; WindowOfFreeMove freeMove;
Map testMap; Map testMap;
Npc testNpc; Npc testNpc;
//Act //Act
freeMove = new WindowOfFreeMove(new JFrame()); game = new Game();
game.setVisible(false);
freeMove = new WindowOfFreeMove(game);
freeMove.setVisible(false); freeMove.setVisible(false);
WindowOfFreeMove.setCHAPTER("999"); WindowOfFreeMove.setCHAPTER("999");
freeMove.start(true); freeMove.start(true);