diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java b/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java index d95c139..e7842af 100644 --- a/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java @@ -313,6 +313,41 @@ public class InteractionCell extends Cell { window.getMusicManager().fadeOut(10); } } + else if (data[1].equals("")) { + window.getMapManager().getActualMap().getSoundManager().playSound(data[2], Float.parseFloat(data[3])); + } + else if (data[1].equals("")) { + 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("")) { + 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("")) window.getMapManager().getActualMap().getNpcs().clear(); else if (data[1].equals("")) window.loadNextChapter(); else if (data[1].equals("")) { diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/Npc.java b/src/main/java/ruscz/game/gameOfProd/Cells/Npc.java index 630b152..2bb0491 100644 --- a/src/main/java/ruscz/game/gameOfProd/Cells/Npc.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/Npc.java @@ -4,14 +4,15 @@ import ruscz.game.gameOfProd.Map.Map; import ruscz.game.gameOfProd.Map.MapManager; import ruscz.game.gameOfProd.Scripts.Direction; import ruscz.game.gameOfProd.Scripts.PathFinder; -import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; import javax.imageio.ImageIO; +import javax.swing.*; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.util.LinkedList; import java.util.Scanner; public class Npc extends Person { @@ -25,6 +26,8 @@ public class Npc extends Person { private int widthCoef; private int heightCoef; private String imageNpc; + private String battle; + private Timer timer; public Npc(int x, int y, String name, Map map, MapManager mapManager) { super(x, y, map); @@ -33,6 +36,14 @@ public class Npc extends Person { 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) { super(x, y, map); this.mapManager = mapManager; @@ -40,44 +51,67 @@ public class Npc extends Person { public void move(int endX, int endY) { PathFinder pathFinder = new PathFinder(getMap()); - for (Direction direction: pathFinder.getWayWithCollision(getX(), getY(), endX, endY)){ - WindowOfFreeMove.sleep(500); - switch (direction){ - case UP: - moveUp(); - break; - case DOWN: - moveDown(); - break; - case LEFT: - moveLeft(); - break; - case RIGHT: - moveRight(); - break; + LinkedList directions = pathFinder.getWayWithCollision(getX(), getY(), endX, endY); + if (endX == mapManager.getActualMap().getPerson().getX() && endY == mapManager.getActualMap().getPerson().getY()) { + directions.removeLast(); + } + final int[] i = {0}; + timer = new Timer(500, actionEvent -> { + if (i[0] == directions.size()) stopTimer(endX, endY); + else { + switch (directions.get(i[0])) { + case UP: + moveUp(); + break; + case DOWN: + moveDown(); + break; + case LEFT: + moveLeft(); + break; + case RIGHT: + moveRight(); + break; + } + if (name.equals("monster")) { + getMap().getSoundManager().playSound("monstersound.wav", 0.0f); + } } 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() { int y = getY() - 1; set(getX(), y); + direction = 3; } private void moveDown() { int y = getY() + 1; set(getX(), y); + direction = 1; } private void moveLeft() { int x = getX() - 1; set(x, getY()); + direction = 2; } private void moveRight() { int x = getX() + 1; set(x, getY()); + direction = 0; } private void loadNpc() { @@ -98,6 +132,7 @@ public class Npc extends Person { widthCoef = Integer.parseInt(imageInfo[5]); heightCoef = Integer.parseInt(imageInfo[6]); imageNpc = scanner.nextLine(); + if (scanner.hasNextLine()) battle = scanner.nextLine(); } @Override diff --git a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java index 8cf028c..aed67be 100644 --- a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java +++ b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java @@ -7,7 +7,10 @@ import ruscz.game.gameOfProd.Game; import javax.swing.*; import java.awt.*; import java.awt.event.*; +import java.io.File; +import java.io.FileNotFoundException; import java.util.LinkedList; +import java.util.Scanner; public class WindowOfBattle extends JPanel { @@ -96,22 +99,33 @@ public class WindowOfBattle extends JPanel { }); } - public void startBattle() { + public void startBattle(String name) { //saveManager.saveGame(); - //TODO Enemies from Files - Hero hero = new Hero(100, 100, "Mark", 1, 100, 1); - Enemy enemy1 = new Enemy(10, 1, "123", 1, 1); - Enemy enemy2 = new Enemy(10, 1, "test", 1, 2); + LinkedList heroes = new LinkedList<>(); + LinkedList enemies = new LinkedList<>(); - LinkedList a = new LinkedList<>(); - a.add(hero); + try { + 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 = 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 = 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 b = new LinkedList<>(); - b.add(enemy1); - b.add(enemy2); - - battle = new Battle(a, b, this); + battle = new Battle(heroes, enemies, this); isReadyToPaint = true; Timer t = new Timer(10, actionEvent -> { diff --git a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java index 7153f0d..4570a79 100644 --- a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java +++ b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java @@ -2,6 +2,7 @@ package ruscz.game.gameOfProd.Windows; import ruscz.game.gameOfProd.Cells.*; import ruscz.game.gameOfProd.Dialog.DialogBar; +import ruscz.game.gameOfProd.Game; import ruscz.game.gameOfProd.Map.Map; import ruscz.game.gameOfProd.Map.MapManager; import ruscz.game.gameOfProd.Sounds.MusicManager; @@ -45,7 +46,7 @@ public class WindowOfFreeMove extends JLayeredPane { private static String CHAPTER = "0"; - private JFrame game; + private Game game; private Canvas canvas; private DialogBar dialogBar; private MapManager mapManager; @@ -104,11 +105,11 @@ public class WindowOfFreeMove extends JLayeredPane { public MusicManager getMusicManager() { return musicManager; } - public JFrame getGame() { + public Game getGame() { return game; } - public WindowOfFreeMove(JFrame game) { + public WindowOfFreeMove(Game game) { this.game = game; isReadyToPaint = false; canPersonMove = true; @@ -218,6 +219,13 @@ public class WindowOfFreeMove extends JLayeredPane { 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 { @Override public void paint(Graphics g) { diff --git a/src/main/resources/battles/storageroombattle.txt b/src/main/resources/battles/storageroombattle.txt new file mode 100644 index 0000000..3e9aea5 --- /dev/null +++ b/src/main/resources/battles/storageroombattle.txt @@ -0,0 +1,2 @@ + 100 10 Mark 1 10 1 + 100 10 Karen 10 1 \ No newline at end of file diff --git a/src/main/resources/characters/monster.png b/src/main/resources/characters/monster.png new file mode 100644 index 0000000..8a3ec02 Binary files /dev/null and b/src/main/resources/characters/monster.png differ diff --git a/src/main/resources/characters/monster.txt b/src/main/resources/characters/monster.txt new file mode 100644 index 0000000..acce660 --- /dev/null +++ b/src/main/resources/characters/monster.txt @@ -0,0 +1,4 @@ +7 7 storageroom +34 86 1 0 0 3 3 +monster.png +storageroombattle \ No newline at end of file diff --git a/src/main/resources/dialogs/boobs.txt b/src/main/resources/dialogs/boobs.txt index c1e8118..78f5aea 100644 --- a/src/main/resources/dialogs/boobs.txt +++ b/src/main/resources/dialogs/boobs.txt @@ -1,6 +1,4 @@ What did one boob say to the other? You are my breastfriend *badumm tits* -ěščřžzýáíé -Главное чтобы я шарила в том, что вы творите \ No newline at end of file diff --git a/src/main/resources/dialogs/cutscenes/cutscene-fight.txt b/src/main/resources/dialogs/cutscenes/cutscene-fight.txt new file mode 100644 index 0000000..667dd0f --- /dev/null +++ b/src/main/resources/dialogs/cutscenes/cutscene-fight.txt @@ -0,0 +1,17 @@ +<1> false +<1> end +<1> 6 1 true +<1> qubodup-DoorClose02-changed.wav -8.0f +<1> color 0 0 0 100 +<2> null +<4> color 0 0 0 100 +<5> null +<6> color 0 0 0 200 +<7> add monster +<8> image main-face.png +<8> Oh-no.-I-really-don't-like-this.
I-want-to-get-out-now! +<11> null +<11> true +<17> false +<17> movetoplayer monster +<18> \ No newline at end of file diff --git a/src/main/resources/maps/0/office-tileset.txt b/src/main/resources/maps/0/office-tileset.txt index cd52491..2a0bea7 100644 --- a/src/main/resources/maps/0/office-tileset.txt +++ b/src/main/resources/maps/0/office-tileset.txt @@ -9,20 +9,20 @@ DOOR dark-door.png,32 CHEST 390 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 -6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 -6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 -6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 -6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 -6 6 6 6 6 6 6 6 6 6 6 6 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 6 6 6 6 -6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 -6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 -6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 -6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 -6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 -6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 -6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 -6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 -6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 \ No newline at end of file +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 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 6 6 6 6 +6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 +6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 +6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 +6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 +6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 +6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 +6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 +6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 \ No newline at end of file diff --git a/src/main/resources/maps/0/office.txt b/src/main/resources/maps/0/office.txt index 6ca0377..8aefd08 100644 --- a/src/main/resources/maps/0/office.txt +++ b/src/main/resources/maps/0/office.txt @@ -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 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 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 \ No newline at end of file +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 \ No newline at end of file diff --git a/src/main/resources/maps/0/storageroom-objectset.txt b/src/main/resources/maps/0/storageroom-objectset.txt new file mode 100644 index 0000000..17be624 --- /dev/null +++ b/src/main/resources/maps/0/storageroom-objectset.txt @@ -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 \ No newline at end of file diff --git a/src/main/resources/maps/0/storageroom-tileset.txt b/src/main/resources/maps/0/storageroom-tileset.txt new file mode 100644 index 0000000..e3d1d2a --- /dev/null +++ b/src/main/resources/maps/0/storageroom-tileset.txt @@ -0,0 +1,24 @@ + A5_Tiles.png + Openspace1.png + Openspace2.png + D_Inside_House.png + BLOCK 2 + MOVETO 1 + EVENT 0 + TRIGGER 4 + CHEST 254 + DOOR dark-door.png,32 + 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 \ No newline at end of file diff --git a/src/main/resources/maps/0/storageroom.txt b/src/main/resources/maps/0/storageroom.txt new file mode 100644 index 0000000..9c04747 --- /dev/null +++ b/src/main/resources/maps/0/storageroom.txt @@ -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 \ No newline at end of file diff --git a/src/main/resources/save/newGame/maps.txt b/src/main/resources/save/newGame/maps.txt index 91d0103..9ed572a 100644 --- a/src/main/resources/save/newGame/maps.txt +++ b/src/main/resources/save/newGame/maps.txt @@ -3,6 +3,6 @@ <0> office <0> boss <0> treasure -<1> glade +<0> storageroom <999> m1 <999> m6 \ No newline at end of file diff --git a/src/main/resources/save/savedGame/events.txt b/src/main/resources/save/savedGame/events.txt index f537083..02fad9d 100644 --- a/src/main/resources/save/savedGame/events.txt +++ b/src/main/resources/save/savedGame/events.txt @@ -14,12 +14,12 @@ 6 4 - false + true 14 16 - true + false 1 @@ -54,7 +54,7 @@ 4 18 - false + true @@ -68,3 +68,13 @@ + + storageroom + + + 6 + 2 + true + + + diff --git a/src/main/resources/save/savedGame/person.txt b/src/main/resources/save/savedGame/person.txt index f083d14..ec0fcae 100644 --- a/src/main/resources/save/savedGame/person.txt +++ b/src/main/resources/save/savedGame/person.txt @@ -1,6 +1,6 @@ - openspace - 8 - 15 - 3 + storageroom + 6 + 2 + 0 \ No newline at end of file diff --git a/src/main/resources/sounds/monstersound.wav b/src/main/resources/sounds/monstersound.wav new file mode 100644 index 0000000..67996df Binary files /dev/null and b/src/main/resources/sounds/monstersound.wav differ diff --git a/src/main/resources/tilesets/trees.png b/src/main/resources/tilesets/trees.png deleted file mode 100644 index 94c5462..0000000 Binary files a/src/main/resources/tilesets/trees.png and /dev/null differ diff --git a/src/test/java/ruscz/game/gameOfProd/Map/MapTest.java b/src/test/java/ruscz/game/gameOfProd/Map/MapTest.java index 65e81f9..0da61d5 100644 --- a/src/test/java/ruscz/game/gameOfProd/Map/MapTest.java +++ b/src/test/java/ruscz/game/gameOfProd/Map/MapTest.java @@ -8,9 +8,9 @@ import org.junit.jupiter.params.provider.MethodSource; import ruscz.game.gameOfProd.Cells.*; import ruscz.game.gameOfProd.Dialog.Dialog; import ruscz.game.gameOfProd.Dialog.DialogBar; +import ruscz.game.gameOfProd.Game; import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; -import javax.swing.*; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; @@ -24,13 +24,16 @@ public class MapTest { @Test public void loadMapFromFile_parseMapFileToMapArray_mapArrayParsedCorrectly() { //Arrange - Map testMap, testMap2; + Map testMap; + Game game; TypeOfCell[][] mapArray; WindowOfFreeMove window; //Act + game = new Game(); + game.setVisible(false); mapArray = parseMap("m6"); - window = new WindowOfFreeMove(new JFrame()); + window = new WindowOfFreeMove(game); window.setCHAPTER("999"); testMap = Map.loadMapFromFile("m6", window); @@ -43,7 +46,9 @@ public class MapTest { } public static Stream 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()); Map map = new Map(new TypeOfCell[1][1]); map.setName("test"); @@ -63,13 +68,16 @@ public class MapTest { @MethodSource("argumentsStream") public void loadMapFromFile_parseStringToCorrectObject_MapObjectParsedCorrectly(Cell cell, String cellText) { //Arrange + Game game; Map testMap; WindowOfFreeMove window; //Act + game = new Game(); + game.setVisible(false); testMap = new Map(new TypeOfCell[1][1]); String[] size = {"1", "1"}; - window= new WindowOfFreeMove(new JFrame()); + window= new WindowOfFreeMove(game); Map.loadMap(testMap, cellText, size, 0, window); //Assert diff --git a/src/test/java/ruscz/game/gameOfProd/Scripts/PathFinderTest.java b/src/test/java/ruscz/game/gameOfProd/Scripts/PathFinderTest.java index bb23761..2b2b8b5 100644 --- a/src/test/java/ruscz/game/gameOfProd/Scripts/PathFinderTest.java +++ b/src/test/java/ruscz/game/gameOfProd/Scripts/PathFinderTest.java @@ -5,10 +5,10 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import ruscz.game.gameOfProd.Cells.Npc; +import ruscz.game.gameOfProd.Game; import ruscz.game.gameOfProd.Map.Map; import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; -import javax.swing.*; import java.util.stream.Stream; public class PathFinderTest { @@ -51,12 +51,15 @@ public class PathFinderTest { @MethodSource("argumentsStream") public void getWayWithCollision_usingMap6ForTestOfPathFinding_rightPositionOfNpc(int startX, int startY, int endX, int endY, boolean isPossible) { //Arrange + Game game; WindowOfFreeMove freeMove; Map testMap; Npc testNpc; //Act - freeMove = new WindowOfFreeMove(new JFrame()); + game = new Game(); + game.setVisible(false); + freeMove = new WindowOfFreeMove(game); freeMove.setVisible(false); WindowOfFreeMove.setCHAPTER("999"); freeMove.start(true);