diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/ChestCell.java b/src/main/java/ruscz/game/gameOfProd/Cells/ChestCell.java new file mode 100644 index 0000000..646a7d4 --- /dev/null +++ b/src/main/java/ruscz/game/gameOfProd/Cells/ChestCell.java @@ -0,0 +1,138 @@ +package ruscz.game.gameOfProd.Cells; + +import ruscz.game.gameOfProd.Dialog.Dialog; +import ruscz.game.gameOfProd.Image.ImageCell; +import ruscz.game.gameOfProd.Inventory.InventoryManager; +import ruscz.game.gameOfProd.Inventory.Item; +import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; + +import java.awt.*; +import java.io.File; +import java.io.FileNotFoundException; +import java.util.LinkedList; +import java.util.Scanner; + +public class ChestCell extends InteractionCell { + private LinkedList chestInventory; + private boolean showItem; + private boolean isActive; + + public ChestCell(int x, int y, String inventory, Dialog dialog, ImageCell imageCell, WindowOfFreeMove window, boolean paint) { + super(x, y, null, dialog, imageCell, window, paint); + this.showItem = false; + this.chestInventory = new LinkedList<>(); + this.isActive = true; + fillChest(inventory); + } + + public ChestCell(int x, int y, String inventory, Dialog dialog, ImageCell imageCell, WindowOfFreeMove window) { + super(x, y, null, dialog, imageCell, window, false); + this.showItem = true; + this.chestInventory = new LinkedList<>(); + this.isActive = true; + fillChest(inventory); + } + + private void fillChest(String inventory) { + try { + File inventoryInfo = new File("src/main/resources/chests/" + inventory + ".txt"); + Scanner scanner = new Scanner(inventoryInfo); + while (scanner.hasNextLine()) { + String[] itemData = scanner.nextLine().split(" "); + if(itemData[0].equals("")) this.message = itemData[1]; + else { + if (itemData.length == 4) { + Item item = new Item(itemData[0], Integer.parseInt(itemData[1]), Integer.parseInt(itemData[2]), itemData[3]); + chestInventory.add(item); + } else { + Item item = new Item(itemData[0], Integer.parseInt(itemData[1]), itemData[2]); + chestInventory.add(item); + } + } + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } + + private void putItemToInventory() { + if (chestInventory.size() == 0) { + endEvent(); + isActive = false; + return; + } + Item item = chestInventory.getFirst(); + InventoryManager.addItem(item); + chestInventory.remove(item); + String data = item.getName() + " was added to your inventory."; + dialog.hideText(); + dialog.setText(data); + dialog.showText(); + if (chestInventory.size() == 0 && message == null) { + showItem = false; + } + } + + @Override + public void startEvent() { + if (message != null) + super.startEvent(); + else readNextLine(); + } + + @Override + public void readNextLine() { + if (message != null) { + if (scanner.hasNextLine() && !dialog.getTimerIsRunning()) { + String data = scanner.nextLine(); + if (data.equals("")) { + isActive = false; + endEvent(); + } + else if (data.equals("")) { + putItemToInventory(); + } + else { + if (data.contains("
")) + data = "" + data + ""; + dialog.hideText(); + dialog.setText(data); + dialog.showText(); + } + } + else { + dialog.skipShowText(); + } + } + else { + putItemToInventory(); + } + } + + @Override + public void paint(Graphics2D g) { + if (showItem) + g.drawImage(super.getImageCell().getImagesOfItems().get(chestInventory.getFirst().getImage()), getX() * getSize(), + getY() * getSize(), getSize() / 2, getSize() / 2, null); + else if (paint) { + g.drawImage(super.getImageCell().getImagesOfTiles().get(super.getImageCell().getImageFromCellMap("CHEST")), getX() * getSize(), + getY() * getSize(), getSize(), getSize(), null); + } + } + + public boolean isActive() { + return isActive; + } + + public void setActive(boolean active) { + isActive = active; + } + + public boolean getPaint() { + return paint; + } + + public boolean getShowItem() { + return showItem; + } +} diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java b/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java index 5605bf4..514f68a 100644 --- a/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java @@ -15,10 +15,10 @@ import java.util.Scanner; public class InteractionCell extends Cell { protected String message; protected ruscz.game.gameOfProd.Dialog.Dialog dialog; - private Scanner scanner; + protected Scanner scanner; private ImageCell imageCell; private WindowOfFreeMove window; - private boolean paint; + protected boolean paint; public InteractionCell(int x, int y, String message, Dialog dialog, ImageCell imageCell, WindowOfFreeMove window, boolean paint) { super(x, y, WindowOfFreeMove.CELL_SIZE, Color.ORANGE); @@ -93,11 +93,11 @@ public class InteractionCell extends Cell { else if (data.contains("")) { String[] dialogInfo = data.split(" "); Item item; - if (dialogInfo.length == 4) { - item = new Item(dialogInfo[1], Integer.parseInt(dialogInfo[2]), dialogInfo[3]); + if (dialogInfo.length == 5) { + item = new Item(dialogInfo[1], Integer.parseInt(dialogInfo[2]), Integer.parseInt(dialogInfo[3]), dialogInfo[4]); } else { - item = new Item(dialogInfo[1], dialogInfo[2]); + item = new Item(dialogInfo[1], Integer.parseInt(dialogInfo[2]), dialogInfo[3]); } InventoryManager.addItem(item); String name = dialogInfo[1].replace("-", " "); diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/Person.java b/src/main/java/ruscz/game/gameOfProd/Cells/Person.java index 4f83faa..0e3aabb 100644 --- a/src/main/java/ruscz/game/gameOfProd/Cells/Person.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/Person.java @@ -110,19 +110,19 @@ public class Person extends Cell { else { door.readNextLine(); } - } else if (isItemInFront(x, y, directionSight)) { + } else if (isChestInFront(x, y, directionSight)) { if (!isInEvent) { isInEvent = true; - map.findItemByXY(x, y, directionSight).startEvent(); + map.findChestByXY(x, y, directionSight).startEvent(); } else { - map.findItemByXY(x, y, directionSight).endEvent(); + map.findChestByXY(x, y, directionSight).readNextLine(); } } break; } if (directionMove != WindowOfFreeMove.KEY_EVENT) { - if (directionMove != 0 && !map.isBusyCell(x, y, true) && !map.isInteractionCell(x, y) && !map.isClosedDoor(x, y) && !map.isItem(x, y)) { + if (directionMove != 0 && !map.isBusyCell(x, y, true) && !map.isInteractionCell(x, y) && !map.isClosedDoor(x, y) && !map.isChest(x, y)) { directionMoveLast = directionMove; isMoving = true; } else if (directionMove != 0 && map.isBusyCell(x, y, true)) { @@ -131,7 +131,7 @@ public class Person extends Cell { directionMoveLast = 0; } else if (directionMove != 0 && map.isClosedDoor(x, y)) { directionMoveLast = 0; - } else if (directionMove != 0 && map.isItem(x, y)) { + } else if (directionMove != 0 && map.isChest(x, y)) { directionMoveLast = 0; } if (map.isCellMoveTo(x, y) && !map.isClosedDoor(x, y)) { @@ -141,7 +141,7 @@ public class Person extends Cell { map.findEventByXY(x, y).moveToMap(); } } else { - if (!map.isInteractionCell(x, y) && !map.isBusyCell(x, y, true) && !map.isClosedDoor(x, y) && !map.isItem(x, y)) { + if (!map.isInteractionCell(x, y) && !map.isBusyCell(x, y, true) && !map.isClosedDoor(x, y) && !map.isChest(x, y)) { set(x, y); } } @@ -171,9 +171,9 @@ public class Person extends Cell { return map.isDoor(coords[0], coords[1]); } - private boolean isItemInFront(int x, int y, int directionSight) { + private boolean isChestInFront(int x, int y, int directionSight) { int[] coords = map.directionSightSwitch(x, y, directionSight); - return map.isActiveItem(coords[0], coords[1]); + return map.isActiveChest(coords[0], coords[1]); } public void stopPerson(){ @@ -287,4 +287,8 @@ public class Person extends Cell { public static void setInEvent(boolean isInEvent) { Person.isInEvent = isInEvent; } + + public int getDirectionSight() { + return directionSight; + } } diff --git a/src/main/java/ruscz/game/gameOfProd/Inventory/Item.java b/src/main/java/ruscz/game/gameOfProd/Inventory/Item.java index 3e75fe4..9587935 100644 --- a/src/main/java/ruscz/game/gameOfProd/Inventory/Item.java +++ b/src/main/java/ruscz/game/gameOfProd/Inventory/Item.java @@ -1,70 +1,29 @@ package ruscz.game.gameOfProd.Inventory; -import ruscz.game.gameOfProd.Cells.InteractionCell; -import ruscz.game.gameOfProd.Cells.Person; -import ruscz.game.gameOfProd.Dialog.Dialog; -import ruscz.game.gameOfProd.Image.ImageCell; -import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; - -import java.awt.*; - -public class Item extends InteractionCell { +public class Item { private ItemAction itemAction; private String name; private int multiplicity; private int image; - private boolean isActive; - public Item(int x, int y, String name, Dialog dialog, ImageCell imageCell, WindowOfFreeMove window, int multiplicity, int image, String itemAction) { - super(x, y, null, dialog, imageCell, window, true); - message = parseNameToMessage(name); + public Item(String name, int multiplicity, int image, String itemAction) { + this.name = parseName(name); this.image = image; this.multiplicity = multiplicity; setItemActionByName(itemAction); - this.isActive = true; } - public Item(int x, int y, String name, Dialog dialog, ImageCell imageCell, WindowOfFreeMove window, int image, String itemAction) { - super(x, y, null, dialog, imageCell, window, true); - message = parseNameToMessage(name); + public Item(String name, int image, String itemAction) { + this.name = parseName(name); this.image = image; this.multiplicity = 1; setItemActionByName(itemAction); - this.isActive = true; } - public Item(String name, String itemAction) { - super(-1, -1, null, null, null, null, true); - message = parseNameToMessage(name); - this.multiplicity = 1; - setItemActionByName(itemAction); - this.isActive = false; - } - - public Item(String name, int multiplicity, String itemAction) { - super(-1, -1, null, null, null, null, true); - message = parseNameToMessage(name); - this.multiplicity = multiplicity; - setItemActionByName(itemAction); - this.isActive = false; - } - - @Override - public void startEvent() { - WindowOfFreeMove.setCanPersonMove(false); - this.dialog.hideText(); - this.dialog.setText(message); - this.dialog.showText(); - InventoryManager.addItem(this); - } - - @Override - public void endEvent() { - this.isActive = false; - this.dialog.hideText(); - this.dialog.setImageDialog(null); - Person.setInEvent(false); - WindowOfFreeMove.setCanPersonMove(true); + private String parseName(String name) { + name = name.replace("-", " "); + name = name.substring(0, 1).toUpperCase() + name.substring(1); + return name; } private void setItemActionByName(String action) { @@ -87,32 +46,13 @@ public class Item extends InteractionCell { } } - private String parseNameToMessage(String name) { - name = name.replace("-", " "); - this.name = name.substring(0,1).toUpperCase() + name.substring(1); - String message = this.name + " was added to your inventory."; - return message; - } - public String getName() { return name; } public int getImage() { return image; } public int getMultiplicity() { return multiplicity; } - public void hideItem() { - isActive = false; - } - - public boolean isActive() { - return isActive; - } - - @Override - public void paint(Graphics2D g) { - if (isActive) { - g.drawImage(super.getImageCell().getImagesOfItems().get(image), getX() * getSize(), - getY() * getSize(), getSize() / 2, getSize() / 2, null); - } + public ItemAction getItemAction() { + return itemAction; } } diff --git a/src/main/java/ruscz/game/gameOfProd/Map/Map.java b/src/main/java/ruscz/game/gameOfProd/Map/Map.java index 8d599b1..9a8c3a9 100644 --- a/src/main/java/ruscz/game/gameOfProd/Map/Map.java +++ b/src/main/java/ruscz/game/gameOfProd/Map/Map.java @@ -21,7 +21,7 @@ public class Map { private LinkedList interactionCells; private LinkedList triggerCells; private LinkedList doorCells; - private LinkedList items; + private LinkedList chestCells; private LinkedList npcs; private int idExit; private ImageCell imageCell; @@ -30,14 +30,14 @@ public class Map { private static Scanner scanner; public Map(TypeOfCell[][] mapArray) { - idExit = 0; + idExit = -1; moveToCells = new LinkedList<>(); interactionCells = new LinkedList<>(); triggerCells = new LinkedList<>(); doorCells = new LinkedList<>(); block = new LinkedList<>(); imageCell = new ImageCell(); - items = new LinkedList<>(); + chestCells = new LinkedList<>(); npcs = new LinkedList<>(); this.mapArray = mapArray; person = new Person(this); @@ -111,18 +111,19 @@ public class Map { map.addInteractionEvent(new TriggerCell(x, y, trigger[1], new Dialog(window.getDialogBar()), map.getImageCell(), window)); } else if (line[x].equals("SPAWN")) { map.setSpawnPoint(x, y); + map.idExit = 0; } else if (line[x].contains("DOOR") && !line[x].contains("DOORTO")) { String[] door = line[x].split(","); if (door.length == 2) map.addInteractionEvent(new DoorCell(x, y, Boolean.parseBoolean(door[1]), map.getImageCell(), window)); else map.addInteractionEvent(new DoorCell(x, y, Boolean.parseBoolean(door[1]), door[2], new Dialog(window.getDialogBar()), map.getImageCell(), window)); - } else if (line[x].contains("ITEM")) { - String[] item = line[x].split(","); - if (item.length == 5) - map.addInteractionEvent(new Item(x, y, item[1], new Dialog(window.getDialogBar()), map.getImageCell(), window, Integer.parseInt(item[2]), Integer.parseInt(item[3]), item[4])); + } else if (line[x].contains("CHEST")) { + String[] chest = line[x].split(","); + if (chest.length == 3) + map.addInteractionEvent(new ChestCell(x, y, chest[1], new Dialog(window.getDialogBar()), map.getImageCell(), window, Boolean.parseBoolean(chest[2]))); else - map.addInteractionEvent(new Item(x, y, item[1], new Dialog(window.getDialogBar()), map.getImageCell(), window, Integer.parseInt(item[2]), item[3])); + map.addInteractionEvent(new ChestCell(x, y, chest[1], new Dialog(window.getDialogBar()), map.getImageCell(), window)); } } } @@ -186,9 +187,9 @@ public class Map { doorCells.add(doorCell); } - public void addInteractionEvent(Item item) { - mapArray[item.getX()][item.getY()] = TypeOfCell.EVENT; - items.add(item); + public void addInteractionEvent(ChestCell chestCell) { + mapArray[chestCell.getX()][chestCell.getY()] = TypeOfCell.EVENT; + chestCells.add(chestCell); } public void setNpcs(Npc npc){ @@ -231,7 +232,7 @@ public class Map { public LinkedList getDoorCells() { return doorCells; } - public LinkedList getItems() { return items; } + public LinkedList getChestCells() { return chestCells; } public void setIdExit(int id) { this.idExit = id; @@ -304,16 +305,16 @@ public class Map { return false; } - public boolean isActiveItem(int x, int y) { - for (Item item : items) - if (x == item.getX() && y == item.getY() && item.getClass().getName().equals("ruscz.game.gameOfProd.Inventory.Item") && item.isActive()) + public boolean isActiveChest(int x, int y) { + for (ChestCell cell : chestCells) + if (x == cell.getX() && y == cell.getY() && cell.getClass().getName().equals("ruscz.game.gameOfProd.Cells.ChestCell") && cell.isActive()) return true; return false; } - public boolean isItem(int x, int y) { - for (Item item : items) - if (x == item.getX() && y == item.getY() && item.getClass().getName().equals("ruscz.game.gameOfProd.Inventory.Item")) + public boolean isChest(int x, int y) { + for (ChestCell cell : chestCells) + if (x == cell.getX() && y == cell.getY() && cell.getClass().getName().equals("ruscz.game.gameOfProd.Cells.ChestCell")) return true; return false; } @@ -369,11 +370,18 @@ public class Map { return null; } - public Item findItemByXY(int x, int y, int directionSight) { + public ChestCell findChestByXY(int x, int y, int directionSight) { int[] coords = directionSightSwitch(x, y, directionSight); - for (Item item : items) - if (coords[0] == item.getX() && coords[1] == item.getY()) - return item; + for (ChestCell cell : chestCells) + if (coords[0] == cell.getX() && coords[1] == cell.getY()) + return cell; + return null; + } + + public ChestCell findChestByXY(int x, int y) { + for (ChestCell cell : chestCells) + if (x == cell.getX() && y == cell.getY()) + return cell; return null; } diff --git a/src/main/java/ruscz/game/gameOfProd/Save/LoadManager.java b/src/main/java/ruscz/game/gameOfProd/Save/LoadManager.java index 9010374..8705484 100644 --- a/src/main/java/ruscz/game/gameOfProd/Save/LoadManager.java +++ b/src/main/java/ruscz/game/gameOfProd/Save/LoadManager.java @@ -1,6 +1,9 @@ package ruscz.game.gameOfProd.Save; +import ruscz.game.gameOfProd.Cells.ChestCell; import ruscz.game.gameOfProd.Cells.TriggerCell; +import ruscz.game.gameOfProd.Inventory.InventoryManager; +import ruscz.game.gameOfProd.Inventory.Item; import ruscz.game.gameOfProd.Map.Map; import ruscz.game.gameOfProd.Map.MapManager; import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; @@ -30,8 +33,8 @@ public class LoadManager { loadNewGame(); loadPerson(); loadEvents(); - loadVillage(); loadInventory(); + loadVillage(); } public void clearSave() { @@ -93,6 +96,8 @@ public class LoadManager { case "": window.setMapManager(Map.findMapByName(getValue(scanner.nextLine()), window)); mapManager.getActualMap().getPerson().set(Integer.parseInt(getValue(scanner.nextLine())), Integer.parseInt(getValue(scanner.nextLine()))); + mapManager.getActualMap().getPerson().setDirectionSight(Integer.parseInt(getValue(scanner.nextLine()))); + mapManager.getActualMap().setIdExit(100); break; } } @@ -109,15 +114,17 @@ public class LoadManager { Map map = null; while (scanner.hasNextLine()) { - if (scanner.nextLine().equals("")) { + String data = scanner.nextLine(); + if (data.equals("")) { map = Map.findMapByName(getValue(scanner.nextLine()), window); } - else if (scanner.nextLine().contains("")) { + else if (data.contains("")) { TriggerCell triggerCell = map.findTriggerByXY(Integer.parseInt(getValue(scanner.nextLine())), Integer.parseInt(getValue(scanner.nextLine()))); triggerCell.setActive(Boolean.parseBoolean(getValue(scanner.nextLine()))); } - else { - scanner.nextLine(); + else if (data.contains("")) { + ChestCell chestCell = map.findChestByXY(Integer.parseInt(getValue(scanner.nextLine())), Integer.parseInt(getValue(scanner.nextLine()))); + chestCell.setActive(Boolean.parseBoolean(getValue(scanner.nextLine()))); } } scanner.close(); @@ -126,6 +133,27 @@ public class LoadManager { } } + private void loadInventory() { + try { + File inventoryFile = new File("src/main/resources/save/savedGame/inventory.txt"); + Scanner scanner = new Scanner(inventoryFile); + + while (scanner.hasNextLine()) { + String data = scanner.nextLine(); + switch (data) { + case "": + Item item = new Item(getValue(scanner.nextLine()), Integer.parseInt(getValue(scanner.nextLine())), Integer.parseInt(getValue(scanner.nextLine())), getValue(scanner.nextLine())); + InventoryManager.addItem(item); + break; + } + } + scanner.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + + } + private void loadVillage() { try { File villageFile = new File("src/main/resources/save/savedGame/village.txt"); @@ -137,17 +165,6 @@ public class LoadManager { //TODO: loadVillage } - private void loadInventory() { - try { - File inventoryFile = new File("src/main/resources/save/savedGame/inventory.txt"); - Scanner scanner = new Scanner(inventoryFile); - scanner.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - //TODO: loadInventory - } - private String getValue(String line) { return line.substring(line.indexOf(">") + 1, line.lastIndexOf("<")); } diff --git a/src/main/java/ruscz/game/gameOfProd/Save/SaveManager.java b/src/main/java/ruscz/game/gameOfProd/Save/SaveManager.java index 136f3d0..a3e4970 100644 --- a/src/main/java/ruscz/game/gameOfProd/Save/SaveManager.java +++ b/src/main/java/ruscz/game/gameOfProd/Save/SaveManager.java @@ -1,7 +1,10 @@ package ruscz.game.gameOfProd.Save; +import ruscz.game.gameOfProd.Cells.ChestCell; import ruscz.game.gameOfProd.Cells.Person; import ruscz.game.gameOfProd.Cells.TriggerCell; +import ruscz.game.gameOfProd.Inventory.InventoryManager; +import ruscz.game.gameOfProd.Inventory.Item; import ruscz.game.gameOfProd.Map.Map; import ruscz.game.gameOfProd.Map.MapManager; @@ -19,8 +22,8 @@ public class SaveManager { public void saveGame() { savePerson(); saveEvents(); - saveVillage(); saveInventory(); + saveVillage(); } private void savePerson() { @@ -32,6 +35,7 @@ public class SaveManager { " " + mapManager.getActualMap().getName() + "" + System.lineSeparator() + " " + person.getX() + "" + System.lineSeparator() + " " + person.getY() + "" + System.lineSeparator() + + " " + person.getDirectionSight() + "" + System.lineSeparator() + ""; writer.write(location); writer.close(); @@ -52,11 +56,20 @@ public class SaveManager { " " + System.lineSeparator(); for (TriggerCell triggerCell : map.getTriggerCells()) { String event = - " " + System.lineSeparator() + + " " + System.lineSeparator() + " " + triggerCell.getX() + "" + System.lineSeparator() + " " + triggerCell.getY() + "" + System.lineSeparator() + " " + triggerCell.getActive() + "" + System.lineSeparator() + - " " + System.lineSeparator(); + " " + System.lineSeparator(); + mapInfo += event; + } + for (ChestCell chestCell : map.getChestCells()) { + String event = + " " + System.lineSeparator() + + " " + chestCell.getX() + "" + System.lineSeparator() + + " " + chestCell.getY() + "" + System.lineSeparator() + + " " + chestCell.isActive() + "" + System.lineSeparator() + + " " + System.lineSeparator(); mapInfo += event; } mapInfo += @@ -71,6 +84,25 @@ public class SaveManager { } } + private void saveInventory() { + try { + FileWriter writer = new FileWriter("src/main/resources/save/savedGame/inventory.txt"); + String inventory = ""; + for (Item item : InventoryManager.getInventory()) { + inventory += "" + System.lineSeparator() + + " " + item.getName().toLowerCase().replace(" ", "-") + "" + System.lineSeparator() + + " " + item.getMultiplicity() + "" + System.lineSeparator() + + " " + item.getImage() + "" + System.lineSeparator() + + " " + item.getItemAction().toString().toLowerCase() + "" + System.lineSeparator() + + "" + System.lineSeparator(); + } + writer.write(inventory); + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + private void saveVillage() { try { FileWriter writer = new FileWriter("src/main/resources/save/savedGame/village.txt"); @@ -81,15 +113,4 @@ public class SaveManager { e.printStackTrace(); } } - - private void saveInventory() { - try { - FileWriter writer = new FileWriter("src/main/resources/save/savedGame/inventory.txt"); - String inventory = "TODO: Inventory"; - writer.write(inventory); - writer.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } } diff --git a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java index 3eb2683..a3f95f0 100644 --- a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java +++ b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java @@ -170,7 +170,7 @@ public class WindowOfFreeMove extends JLayeredPane { boss.setNpcs(npc2); musicManager = new MusicManager("Town1.wav"); -// musicManager.playMusic(); + musicManager.playMusic(); Timer timer = new Timer(10, actionEvent -> { mapManager.getActualMap().getPerson().move(); @@ -203,6 +203,9 @@ public class WindowOfFreeMove extends JLayeredPane { for (Cell cell : mapManager.getActualMap().getInteractionEventCells()) { if (cell.getY() == i) cell.paint(g2D); } + for (ChestCell cell : mapManager.getActualMap().getChestCells()) { + if (cell.getY() == i && cell.getPaint()) cell.paint(g2D); + } if (mapManager.getActualMap().getPerson().getY() == (i-1) && mapManager.getActualMap().getPerson().getDirectionMoveLast() == KEY_UP) mapManager.getActualMap().getPerson().paint(g2D); for (Block cell : mapManager.getActualMap().getBlocks()) { if (cell.getY() == i && cell.isPartial()) cell.paint(g2D); @@ -216,8 +219,8 @@ public class WindowOfFreeMove extends JLayeredPane { for (int j = 0; j < mapManager.getActualMap().getCanvasSize()[1]; j++) { mapManager.getActualMap().getImageCell().paintForeground(g2D, j, i); } - for (Item item : mapManager.getActualMap().getItems()) { - if (item.getY() == i) item.paint(g2D); + for (ChestCell cell : mapManager.getActualMap().getChestCells()) { + if (cell.getY() == i && cell.getShowItem()) cell.paint(g2D); } } } diff --git a/src/main/resources/chests/confroom.txt b/src/main/resources/chests/confroom.txt new file mode 100644 index 0000000..96cc682 --- /dev/null +++ b/src/main/resources/chests/confroom.txt @@ -0,0 +1 @@ +white-key-card 19 key \ No newline at end of file diff --git a/src/main/resources/chests/trashcan.txt b/src/main/resources/chests/trashcan.txt new file mode 100644 index 0000000..7a9351b --- /dev/null +++ b/src/main/resources/chests/trashcan.txt @@ -0,0 +1,2 @@ +blue-key-card 39 key + trash \ No newline at end of file diff --git a/src/main/resources/dialogs/trash.txt b/src/main/resources/dialogs/trash.txt index 998a666..bdd0270 100644 --- a/src/main/resources/dialogs/trash.txt +++ b/src/main/resources/dialogs/trash.txt @@ -1,4 +1,3 @@ Just like the trash you are.. -You found a Blue key card. - blue-key-card key + \ No newline at end of file diff --git a/src/main/resources/maps/office-cellmap.txt b/src/main/resources/maps/office-cellmap.txt index 2bf3640..631a4e7 100644 --- a/src/main/resources/maps/office-cellmap.txt +++ b/src/main/resources/maps/office-cellmap.txt @@ -2,4 +2,5 @@ BLOCK 2 MOVETO 1 EVENT 3 TRIGGER 4 -DOOR dark-door.png,32 \ No newline at end of file +DOOR dark-door.png,32 +CHEST 390 \ No newline at end of file diff --git a/src/main/resources/maps/office-objectset.txt b/src/main/resources/maps/office-objectset.txt index b5f40f7..038cb82 100644 --- a/src/main/resources/maps/office-objectset.txt +++ b/src/main/resources/maps/office-objectset.txt @@ -7,6 +7,6 @@ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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/office.txt b/src/main/resources/maps/office.txt index b004aa5..9027df0 100644 --- a/src/main/resources/maps/office.txt +++ b/src/main/resources/maps/office.txt @@ -8,7 +8,7 @@ BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK EMPTY EMPTY EMPTY BLOCK BL BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK EMPTY moveto,1,2,openspace EMPTY EMPTY EMPTY EMPTY BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK EMPTY moveto,1,2,openspace EMPTY EMPTY EMPTY EMPTY BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK EMPTY EMPTY EMPTY BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK -BLOCK inter,trash 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 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,2,1,treasure BLOCK BLOCK \ No newline at end of file diff --git a/src/main/resources/maps/openspace.txt b/src/main/resources/maps/openspace.txt index 94fc0db..04ea5ad 100644 --- a/src/main/resources/maps/openspace.txt +++ b/src/main/resources/maps/openspace.txt @@ -6,7 +6,7 @@ BLOCK block EMPTY EMPTY EMPTY EMPTY EMPTY block BLOCK,u EMPTY EMPTY EMPTY BLOCK BLOCK block EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY DOOR,false EMPTY EMPTY EMPTY BLOCK EMPTY block block block block EMPTY block BLOCK BLOCK,d EMPTY BLOCK,d BLOCK,d BLOCK,d EMPTY BLOCK,d BLOCK EMPTY EMPTY EMPTY BLOCK EMPTY block block block block EMPTY block BLOCK BLOCK DOOR,true,locked,false BLOCK BLOCK BLOCK DOOR,true BLOCK BLOCK EMPTY EMPTY EMPTY BLOCK EMPTY block block block block EMPTY block -BLOCK block EMPTY block BLOCK block EMPTY block BLOCK EMPTY EMPTY EMPTY BLOCK EMPTY block ITEM,white-key-card,19,key block block EMPTY block +BLOCK block EMPTY block BLOCK block EMPTY block BLOCK EMPTY EMPTY EMPTY BLOCK EMPTY block CHEST,confroom block block EMPTY block BLOCK block EMPTY block BLOCK block EMPTY block BLOCK EMPTY EMPTY EMPTY BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK BLOCK block EMPTY block BLOCK block EMPTY block BLOCK EMPTY EMPTY EMPTY BLOCK BLOCK,d BLOCK,d BLOCK,d EMPTY BLOCK,d BLOCK,d BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK EMPTY EMPTY EMPTY BLOCK BLOCK BLOCK BLOCK DOOR,true,blue-key-card BLOCK BLOCK BLOCK diff --git a/src/main/resources/maps/treasure-cellmap.txt b/src/main/resources/maps/treasure-cellmap.txt new file mode 100644 index 0000000..d8e7ba0 --- /dev/null +++ b/src/main/resources/maps/treasure-cellmap.txt @@ -0,0 +1,5 @@ +BLOCK 0 +MOVETO 0 +EVENT 0 +TRIGGER 0 +DOOR dark-door.png,32 \ No newline at end of file diff --git a/src/main/resources/maps/treasure-objectset.txt b/src/main/resources/maps/treasure-objectset.txt new file mode 100644 index 0000000..defab2f --- /dev/null +++ b/src/main/resources/maps/treasure-objectset.txt @@ -0,0 +1,10 @@ +0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 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/treasure-tileset.txt b/src/main/resources/maps/treasure-tileset.txt index d9ee8a1..fc40a91 100644 --- a/src/main/resources/maps/treasure-tileset.txt +++ b/src/main/resources/maps/treasure-tileset.txt @@ -5,7 +5,7 @@ 3 13 23 33 43 53 63 73 83 93 103 113 123 4 14 24 34 44 54 64 74 84 94 104 114 124 5 15 25 35 45 55 65 75 85 95 105 115 125 -6 13 26 36 46 56 66 76 86 96 106 116 126 +6 16 26 36 46 56 66 76 86 96 106 116 126 7 17 27 37 47 57 67 77 87 97 107 117 127 8 18 28 38 48 58 68 78 88 98 108 118 128 9 19 29 39 49 59 69 79 89 99 109 119 129 \ 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 48e77b7..e69de29 100644 --- a/src/main/resources/save/savedGame/events.txt +++ b/src/main/resources/save/savedGame/events.txt @@ -1,75 +0,0 @@ - - m1 - - - - - m2 - - - 7 - 2 - true - - - - - m3 - - - 2 - 5 - true - - - - - m4 - - - 3 - 3 - true - - - - - m5 - - - - - m6 - - - 11 - 11 - true - - - - - openspace - - - - - office - - - - - boss - - - 4 - 18 - true - - - - - treasure - - - diff --git a/src/main/resources/save/savedGame/inventory.txt b/src/main/resources/save/savedGame/inventory.txt index 7082420..e69de29 100644 --- a/src/main/resources/save/savedGame/inventory.txt +++ b/src/main/resources/save/savedGame/inventory.txt @@ -1 +0,0 @@ -TODO: Inventory \ No newline at end of file diff --git a/src/main/resources/save/savedGame/person.txt b/src/main/resources/save/savedGame/person.txt index 1cfca66..e69de29 100644 --- a/src/main/resources/save/savedGame/person.txt +++ b/src/main/resources/save/savedGame/person.txt @@ -1,5 +0,0 @@ - - office - 17 - 11 - \ No newline at end of file diff --git a/src/main/resources/save/savedGame/village.txt b/src/main/resources/save/savedGame/village.txt index 1b4bc7b..e69de29 100644 --- a/src/main/resources/save/savedGame/village.txt +++ b/src/main/resources/save/savedGame/village.txt @@ -1 +0,0 @@ -TODO: Village \ No newline at end of file