diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/DoorCell.java b/src/main/java/ruscz/game/gameOfProd/Cells/DoorCell.java index 8fcb2b5..676ba89 100644 --- a/src/main/java/ruscz/game/gameOfProd/Cells/DoorCell.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/DoorCell.java @@ -2,7 +2,7 @@ package ruscz.game.gameOfProd.Cells; import ruscz.game.gameOfProd.Dialog.Dialog; import ruscz.game.gameOfProd.Image.ImageCell; -import ruscz.game.gameOfProd.Image.ImageDoor; +import ruscz.game.gameOfProd.Inventory.Item; import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; import java.awt.*; @@ -10,14 +10,12 @@ import java.awt.*; public class DoorCell extends InteractionCell { private boolean isOpen; private boolean isLocked; - private boolean requiresKey; private boolean directionVert; - public DoorCell(int x, int y, boolean directionVert, String message, Dialog dialog, ImageCell imageCell, WindowOfFreeMove window, boolean requiresKey) { + public DoorCell(int x, int y, boolean directionVert, String message, Dialog dialog, ImageCell imageCell, WindowOfFreeMove window) { super(x, y, message, dialog, imageCell, window, true); this.isOpen = false; this.isLocked = true; - this.requiresKey = requiresKey; this.directionVert = directionVert; } @@ -36,6 +34,12 @@ public class DoorCell extends InteractionCell { (getY() - 1) * getSize(), getSize() * 2, getSize() * 2, null); } + @Override + public void useItem(Item item) { + isLocked = false; + super.useItem(item); + } + public boolean isOpen() { return isOpen; } @@ -51,12 +55,4 @@ public class DoorCell extends InteractionCell { public void setLocked(boolean locked) { isLocked = locked; } - - public boolean isRequiresKey() { - return requiresKey; - } - - public void setRequiresKey(boolean requiresKey) { - this.requiresKey = requiresKey; - } } diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java b/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java index 26959b1..5605bf4 100644 --- a/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java @@ -3,6 +3,8 @@ package ruscz.game.gameOfProd.Cells; import ruscz.game.gameOfProd.Dialog.Dialog; import ruscz.game.gameOfProd.Image.ImageCell; import ruscz.game.gameOfProd.Image.ImageDialog; +import ruscz.game.gameOfProd.Inventory.InventoryManager; +import ruscz.game.gameOfProd.Inventory.Item; import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; import java.awt.*; @@ -88,6 +90,41 @@ public class InteractionCell extends Cell { break; } } + 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]); + } + else { + item = new Item(dialogInfo[1], dialogInfo[2]); + } + InventoryManager.addItem(item); + String name = dialogInfo[1].replace("-", " "); + name = name.substring(0,1).toUpperCase() + name.substring(1); + data = name + " was added to your inventory."; + dialog.hideText(); + dialog.setText(data); + dialog.showText(); + } + else if (data.contains("")) { + String[] dialogInfo = data.split(" "); + String name = dialogInfo[1].replace("-", " "); + name = name.substring(0,1).toUpperCase() + name.substring(1); + if(InventoryManager.isInInventory(InventoryManager.findItemByName(name))) { + useItem(InventoryManager.findItemByName(name)); + data = "You used " + name + "."; + dialog.hideText(); + dialog.setText(data); + dialog.showText(); + } + else { + data = "You need " + name + " to proceed."; + dialog.hideText(); + dialog.setText(data); + dialog.showText(); + } + } else { if (data.contains("
")) data = "" + data + ""; @@ -116,6 +153,10 @@ public class InteractionCell extends Cell { } } + public void useItem(Item item) { + InventoryManager.removeItem(item); + } + @Override public void paint(Graphics2D g) { super.paint(g); diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/Person.java b/src/main/java/ruscz/game/gameOfProd/Cells/Person.java index c1ee847..4f83faa 100644 --- a/src/main/java/ruscz/game/gameOfProd/Cells/Person.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/Person.java @@ -97,7 +97,7 @@ public class Person extends Cell { } else if (isDoorInFront(x,y,directionSight)) { DoorCell door = map.findDoorByXY(x, y, directionSight); - if (!door.isLocked()) { + if (!door.isLocked() && !isInEvent) { if (door.isOpen()) door.setOpen(false); else diff --git a/src/main/java/ruscz/game/gameOfProd/Inventory/Item.java b/src/main/java/ruscz/game/gameOfProd/Inventory/Item.java index 48ccb48..3e75fe4 100644 --- a/src/main/java/ruscz/game/gameOfProd/Inventory/Item.java +++ b/src/main/java/ruscz/game/gameOfProd/Inventory/Item.java @@ -33,6 +33,22 @@ public class Item extends InteractionCell { 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); diff --git a/src/main/java/ruscz/game/gameOfProd/Map/Map.java b/src/main/java/ruscz/game/gameOfProd/Map/Map.java index c70f339..8d599b1 100644 --- a/src/main/java/ruscz/game/gameOfProd/Map/Map.java +++ b/src/main/java/ruscz/game/gameOfProd/Map/Map.java @@ -116,7 +116,7 @@ public class Map { 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, Boolean.parseBoolean(door[3]))); + 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) @@ -149,8 +149,8 @@ public class Map { else if (line[x].contains("DOORTO")) { String[] doorTo = line[x].split(","); if (doorTo[1].equals("locked")) { - map.addInteractionEvent(new DoorCell(x, y, Boolean.parseBoolean(doorTo[2]), doorTo[3], new Dialog(window.getDialogBar()), map.getImageCell(), window, Boolean.parseBoolean(doorTo[4]))); - map.addMoveToEvent(new EventMoveToCell(Integer.parseInt(doorTo[5]), Integer.parseInt(doorTo[6]), x, y, findMapByName(doorTo[7], window), window, false)); + map.addInteractionEvent(new DoorCell(x, y, Boolean.parseBoolean(doorTo[2]), doorTo[3], new Dialog(window.getDialogBar()), map.getImageCell(), window)); + map.addMoveToEvent(new EventMoveToCell(Integer.parseInt(doorTo[4]), Integer.parseInt(doorTo[5]), x, y, findMapByName(doorTo[6], window), window, false)); } else { map.addInteractionEvent(new DoorCell(x, y, Boolean.parseBoolean(doorTo[1]), map.getImageCell(), window)); diff --git a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java index fc8bdc0..3eb2683 100644 --- a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java +++ b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java @@ -114,7 +114,6 @@ public class WindowOfFreeMove extends JLayeredPane { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KEY_ESCAPE){ - System.out.println("escape"); game.dispatchEvent(new WindowEvent(game, WindowEvent.WINDOW_CLOSING)); return; } diff --git a/src/main/resources/CertificateOfShame.png b/src/main/resources/CertificateOfShame.png new file mode 100644 index 0000000..130cf30 Binary files /dev/null and b/src/main/resources/CertificateOfShame.png differ diff --git a/src/main/resources/dialogs/blue-key-card.txt b/src/main/resources/dialogs/blue-key-card.txt new file mode 100644 index 0000000..0d37878 --- /dev/null +++ b/src/main/resources/dialogs/blue-key-card.txt @@ -0,0 +1,2 @@ + blue-key-card + \ No newline at end of file diff --git a/src/main/resources/dialogs/trash.txt b/src/main/resources/dialogs/trash.txt new file mode 100644 index 0000000..998a666 --- /dev/null +++ b/src/main/resources/dialogs/trash.txt @@ -0,0 +1,4 @@ +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/dialogs/white-key-card.txt b/src/main/resources/dialogs/white-key-card.txt new file mode 100644 index 0000000..e9baa62 --- /dev/null +++ b/src/main/resources/dialogs/white-key-card.txt @@ -0,0 +1,2 @@ + white-key-card + \ 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 b3389d1..b5f40f7 100644 --- a/src/main/resources/maps/office-objectset.txt +++ b/src/main/resources/maps/office-objectset.txt @@ -6,7 +6,7 @@ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 -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 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 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 b007b39..b004aa5 100644 --- a/src/main/resources/maps/office.txt +++ b/src/main/resources/maps/office.txt @@ -1,6 +1,6 @@ 20 13 BLOCK,d BLOCK,d BLOCK,d BLOCK,d EMPTY BLOCK,d BLOCK,d BLOCK,d BLOCK,d BLOCK,d BLOCK,d BLOCK,d BLOCK,d BLOCK,d BLOCK,d BLOCK,d BLOCK,d BLOCK,d BLOCK,d BLOCK,d -BLOCK BLOCK BLOCK BLOCK DOORTO,true,0,3,boss BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK DOOR,true,locked,false BLOCK BLOCK BLOCK BLOCK DOOR,true,locked,false BLOCK BLOCK +BLOCK BLOCK BLOCK BLOCK DOORTO,true,0,3,boss BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK DOOR,true,locked BLOCK BLOCK BLOCK BLOCK DOOR,true,locked BLOCK 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 EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY block BLOCK @@ -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 block EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK +BLOCK inter,trash 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,false BLOCK BLOCK BLOCK BLOCK DOOR,true,locked,false BLOCK BLOCK BLOCK BLOCK DOOR,true,locked,false BLOCK BLOCK BLOCK BLOCK DOOR,true,locked,false BLOCK BLOCK \ No newline at end of file +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 a2e6859..94fc0db 100644 --- a/src/main/resources/maps/openspace.txt +++ b/src/main/resources/maps/openspace.txt @@ -9,7 +9,7 @@ BLOCK BLOCK DOOR,true,locked,false BLOCK BLOCK BLOCK DOOR,true BLOCK BLOCK EMPTY 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 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 BLOCK BLOCK 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 BLOCK EMPTY block block EMPTY inter,minecraft inter,minecraft EMPTY BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY BLOCK BLOCK EMPTY block block EMPTY inter,minecraft inter,minecraft EMPTY BLOCK,u EMPTY EMPTY EMPTY EMPTY EMPTY block EMPTY EMPTY EMPTY block block BLOCK EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY DOOR,false EMPTY EMPTY EMPTY EMPTY EMPTY block block EMPTY block block block diff --git a/src/main/resources/maps/treasure-tileset.txt b/src/main/resources/maps/treasure-tileset.txt new file mode 100644 index 0000000..d9ee8a1 --- /dev/null +++ b/src/main/resources/maps/treasure-tileset.txt @@ -0,0 +1,11 @@ + CertificateOfShame.png 650 500 50 +0 10 20 30 40 50 60 70 80 90 100 110 120 +1 11 21 31 41 51 61 71 81 91 101 111 121 +2 12 22 32 42 52 62 72 82 92 102 112 122 +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 +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/maps/treasure.txt b/src/main/resources/maps/treasure.txt new file mode 100644 index 0000000..026dc7f --- /dev/null +++ b/src/main/resources/maps/treasure.txt @@ -0,0 +1,11 @@ +13 10 +block block block block block block moveto,2,3,office block block block block block 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 b4a3eb2..fd103b4 100644 --- a/src/main/resources/save/newGame/maps.txt +++ b/src/main/resources/save/newGame/maps.txt @@ -6,4 +6,5 @@ m5 m6 openspace office -boss \ No newline at end of file +boss +treasure \ No newline at end of file diff --git a/src/main/resources/save/savedGame/events-DESKTOP-TL25DTN.txt b/src/main/resources/save/savedGame/events-DESKTOP-TL25DTN.txt new file mode 100644 index 0000000..48e77b7 --- /dev/null +++ b/src/main/resources/save/savedGame/events-DESKTOP-TL25DTN.txt @@ -0,0 +1,75 @@ + + 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/events.txt b/src/main/resources/save/savedGame/events.txt index 245388a..48e77b7 100644 --- a/src/main/resources/save/savedGame/events.txt +++ b/src/main/resources/save/savedGame/events.txt @@ -68,3 +68,8 @@ + + treasure + + + diff --git a/src/main/resources/save/savedGame/inventory-DESKTOP-TL25DTN.txt b/src/main/resources/save/savedGame/inventory-DESKTOP-TL25DTN.txt new file mode 100644 index 0000000..7082420 --- /dev/null +++ b/src/main/resources/save/savedGame/inventory-DESKTOP-TL25DTN.txt @@ -0,0 +1 @@ +TODO: Inventory \ No newline at end of file diff --git a/src/main/resources/save/savedGame/person-DESKTOP-TL25DTN-2.txt b/src/main/resources/save/savedGame/person-DESKTOP-TL25DTN-2.txt new file mode 100644 index 0000000..ee5b150 --- /dev/null +++ b/src/main/resources/save/savedGame/person-DESKTOP-TL25DTN-2.txt @@ -0,0 +1,5 @@ + + m1 + 1 + 7 + \ No newline at end of file diff --git a/src/main/resources/save/savedGame/person-DESKTOP-TL25DTN-3.txt b/src/main/resources/save/savedGame/person-DESKTOP-TL25DTN-3.txt new file mode 100644 index 0000000..ee5b150 --- /dev/null +++ b/src/main/resources/save/savedGame/person-DESKTOP-TL25DTN-3.txt @@ -0,0 +1,5 @@ + + m1 + 1 + 7 + \ No newline at end of file diff --git a/src/main/resources/save/savedGame/person-DESKTOP-TL25DTN.txt b/src/main/resources/save/savedGame/person-DESKTOP-TL25DTN.txt new file mode 100644 index 0000000..ee5b150 --- /dev/null +++ b/src/main/resources/save/savedGame/person-DESKTOP-TL25DTN.txt @@ -0,0 +1,5 @@ + + m1 + 1 + 7 + \ 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 3e8a7a4..1cfca66 100644 --- a/src/main/resources/save/savedGame/person.txt +++ b/src/main/resources/save/savedGame/person.txt @@ -1,5 +1,5 @@ - openspace - 8 - 16 + office + 17 + 11 \ No newline at end of file diff --git a/src/main/resources/save/savedGame/village-DESKTOP-TL25DTN.txt b/src/main/resources/save/savedGame/village-DESKTOP-TL25DTN.txt new file mode 100644 index 0000000..1b4bc7b --- /dev/null +++ b/src/main/resources/save/savedGame/village-DESKTOP-TL25DTN.txt @@ -0,0 +1 @@ +TODO: Village \ No newline at end of file