improved inventory
This commit is contained in:
parent
5256dc6c4f
commit
c642c196b8
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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("<additem>")) {
|
||||
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("<removeitem>")) {
|
||||
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("<br/>"))
|
||||
data = "<html>" + data + "</html>";
|
||||
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
BIN
src/main/resources/CertificateOfShame.png
Normal file
BIN
src/main/resources/CertificateOfShame.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 85 KiB |
2
src/main/resources/dialogs/blue-key-card.txt
Normal file
2
src/main/resources/dialogs/blue-key-card.txt
Normal file
@ -0,0 +1,2 @@
|
||||
<removeitem> blue-key-card
|
||||
<end>
|
||||
4
src/main/resources/dialogs/trash.txt
Normal file
4
src/main/resources/dialogs/trash.txt
Normal file
@ -0,0 +1,4 @@
|
||||
Just like the trash you are..
|
||||
You found a Blue key card.
|
||||
<additem> blue-key-card key
|
||||
<end>
|
||||
2
src/main/resources/dialogs/white-key-card.txt
Normal file
2
src/main/resources/dialogs/white-key-card.txt
Normal file
@ -0,0 +1,2 @@
|
||||
<removeitem> white-key-card
|
||||
<end>
|
||||
@ -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
|
||||
@ -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
|
||||
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
|
||||
@ -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
|
||||
|
||||
11
src/main/resources/maps/treasure-tileset.txt
Normal file
11
src/main/resources/maps/treasure-tileset.txt
Normal file
@ -0,0 +1,11 @@
|
||||
<tileset> 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
|
||||
11
src/main/resources/maps/treasure.txt
Normal file
11
src/main/resources/maps/treasure.txt
Normal file
@ -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
|
||||
@ -6,4 +6,5 @@ m5
|
||||
m6
|
||||
openspace
|
||||
office
|
||||
boss
|
||||
boss
|
||||
treasure
|
||||
75
src/main/resources/save/savedGame/events-DESKTOP-TL25DTN.txt
Normal file
75
src/main/resources/save/savedGame/events-DESKTOP-TL25DTN.txt
Normal file
@ -0,0 +1,75 @@
|
||||
<map>
|
||||
<mapName>m1</mapName>
|
||||
<events>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>m2</mapName>
|
||||
<events>
|
||||
<event>
|
||||
<x>7</x>
|
||||
<y>2</y>
|
||||
<active>true</active>
|
||||
</event>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>m3</mapName>
|
||||
<events>
|
||||
<event>
|
||||
<x>2</x>
|
||||
<y>5</y>
|
||||
<active>true</active>
|
||||
</event>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>m4</mapName>
|
||||
<events>
|
||||
<event>
|
||||
<x>3</x>
|
||||
<y>3</y>
|
||||
<active>true</active>
|
||||
</event>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>m5</mapName>
|
||||
<events>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>m6</mapName>
|
||||
<events>
|
||||
<event>
|
||||
<x>11</x>
|
||||
<y>11</y>
|
||||
<active>true</active>
|
||||
</event>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>openspace</mapName>
|
||||
<events>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>office</mapName>
|
||||
<events>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>boss</mapName>
|
||||
<events>
|
||||
<event>
|
||||
<x>4</x>
|
||||
<y>18</y>
|
||||
<active>true</active>
|
||||
</event>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>treasure</mapName>
|
||||
<events>
|
||||
</events>
|
||||
</map>
|
||||
@ -68,3 +68,8 @@
|
||||
</event>
|
||||
</events>
|
||||
</map>
|
||||
<map>
|
||||
<mapName>treasure</mapName>
|
||||
<events>
|
||||
</events>
|
||||
</map>
|
||||
|
||||
@ -0,0 +1 @@
|
||||
TODO: Inventory
|
||||
@ -0,0 +1,5 @@
|
||||
<location>
|
||||
<map>m1</map>
|
||||
<x>1</x>
|
||||
<y>7</y>
|
||||
</location>
|
||||
@ -0,0 +1,5 @@
|
||||
<location>
|
||||
<map>m1</map>
|
||||
<x>1</x>
|
||||
<y>7</y>
|
||||
</location>
|
||||
@ -0,0 +1,5 @@
|
||||
<location>
|
||||
<map>m1</map>
|
||||
<x>1</x>
|
||||
<y>7</y>
|
||||
</location>
|
||||
@ -1,5 +1,5 @@
|
||||
<location>
|
||||
<map>openspace</map>
|
||||
<x>8</x>
|
||||
<y>16</y>
|
||||
<map>office</map>
|
||||
<x>17</x>
|
||||
<y>11</y>
|
||||
</location>
|
||||
@ -0,0 +1 @@
|
||||
TODO: Village
|
||||
Loading…
x
Reference in New Issue
Block a user