diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/Person.java b/src/main/java/ruscz/game/gameOfProd/Cells/Person.java index 8de62ee..53b55fc 100644 --- a/src/main/java/ruscz/game/gameOfProd/Cells/Person.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/Person.java @@ -7,6 +7,9 @@ import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; import java.awt.*; public class Person extends Cell { + + private final int WALKING_SPEED = 3; + private Map map; private ImagePerson imagePerson; private int directionMove; @@ -189,7 +192,7 @@ public class Person extends Cell { @Override public void paint(Graphics2D g) { super.paint(g); - if (distanceOfAnimation == 0) { + if (distanceOfAnimation <= WALKING_SPEED - 1) { isMoving = false; } if (isMoving) { @@ -208,7 +211,7 @@ public class Person extends Cell { break; } if (distanceOfAnimation > 0 && isMoving) { - distanceOfAnimation -= 2; + distanceOfAnimation -= WALKING_SPEED; } else { isMoving = false; diff --git a/src/main/java/ruscz/game/gameOfProd/Dialog/Dialog.java b/src/main/java/ruscz/game/gameOfProd/Dialog/Dialog.java index eefdc03..c632bcc 100644 --- a/src/main/java/ruscz/game/gameOfProd/Dialog/Dialog.java +++ b/src/main/java/ruscz/game/gameOfProd/Dialog/Dialog.java @@ -46,7 +46,7 @@ public class Dialog { text.setBounds(cellSize, cellSize / 2, size.width, size.height); dialogBar.unsetImageDialog(); } - + dialogBar.repaint(); return text; } @@ -59,6 +59,7 @@ public class Dialog { if (dialogBar.getComponentCount() != 0) dialogBar.remove(0); dialogBar.add(textToShow); + dialogBar.repaint(); charNumber++; if (charNumber == textLength) { timer.stop(); @@ -70,7 +71,8 @@ public class Dialog { if (text.contains("")) charNumber = 6; dialogBar.setVisible(true); - timer = new Timer(30, e -> { + dialogBar.repaint(); + timer = new Timer(40, e -> { if (voiceover) soundManager.playSound(voice + ".wav", -20.0f); showByChar(); @@ -84,6 +86,7 @@ public class Dialog { if (text.contains("")) charNumber = 6; dialogBar.setVisible(true); + dialogBar.repaint(); while (charNumber <= text.length()) { if (voiceover) soundManager.playSound(voice + ".wav", -20.0f); diff --git a/src/main/java/ruscz/game/gameOfProd/Inventory/InventoryManager.java b/src/main/java/ruscz/game/gameOfProd/Inventory/InventoryManager.java index 29a8519..acf340d 100644 --- a/src/main/java/ruscz/game/gameOfProd/Inventory/InventoryManager.java +++ b/src/main/java/ruscz/game/gameOfProd/Inventory/InventoryManager.java @@ -2,9 +2,16 @@ package ruscz.game.gameOfProd.Inventory; import java.util.LinkedList; +/** + * Class for working with Inventory (fully static) + */ public class InventoryManager { - private static LinkedList inventory = new LinkedList(); + private static LinkedList inventory = new LinkedList<>(); + /** + * Increase multiplicity of items, if exists in Inventory, or add to List + * @param item Item to add to inventory + */ public static void addItem(Item item) { for(Item item1: inventory){ if(item1.equals(item)) { @@ -15,10 +22,18 @@ public class InventoryManager { inventory.add(item); } + /** + * Deletes all items from Inventory + */ public static void flushInventory() { inventory = new LinkedList<>(); } + /** + * Checks, if item in Inventory + * @param item Item to check + * @return true if is in List, false if not + */ public static boolean isInInventory(Item item) { for (Item inventoryItem : inventory) { if (inventoryItem.equals(item)) return true; @@ -26,9 +41,16 @@ public class InventoryManager { return false; } + /** + * Removes count of Item, if it possible + * @param item Item to remove + * @param count Count of this Item + * @return true if successful, false if not + */ public static boolean removeItem(Item item, int count) { if (isInInventory(item)) { Item itemIn = findItemByName(item.getName()); + if (itemIn == null) return false; if (itemIn.getMultiplicity() > count) itemIn.setMultiplicity(itemIn.getMultiplicity() - count); else if (itemIn.getMultiplicity() == count) @@ -41,6 +63,11 @@ public class InventoryManager { public static LinkedList getInventory() { return inventory; } + /** + * Return Item, if exists in List with this Name + * @param name Name of Item + * @return Item if exists, null if not + */ public static Item findItemByName(String name) { for (Item item : inventory) { if (item.getName().equals(name)) return item; diff --git a/src/main/java/ruscz/game/gameOfProd/Inventory/Item.java b/src/main/java/ruscz/game/gameOfProd/Inventory/Item.java index 3739435..408b50b 100644 --- a/src/main/java/ruscz/game/gameOfProd/Inventory/Item.java +++ b/src/main/java/ruscz/game/gameOfProd/Inventory/Item.java @@ -5,13 +5,15 @@ import ruscz.game.gameOfProd.Image.ImageCell; import javax.swing.*; import java.util.Objects; +/** + * Class, describing Item in Game + */ public class Item { private ItemAction itemAction; private final String name; private int multiplicity; private final int image; - public Item(String name, int multiplicity, int image, String itemAction) { this.name = parseName(name); this.image = image; @@ -26,12 +28,21 @@ public class Item { setItemActionByName(itemAction); } + /** + * Removes all "-" in text + * @param name Name of Item + * @return Name with whitespaces + */ private String parseName(String name) { name = name.replace("-", " "); name = name.substring(0, 1).toUpperCase() + name.substring(1); return name; } + /** + * Choose enumeration by String you provide + * @param action Name of action + */ private void setItemActionByName(String action) { switch (action) { case "heal": diff --git a/src/main/java/ruscz/game/gameOfProd/Inventory/ItemAction.java b/src/main/java/ruscz/game/gameOfProd/Inventory/ItemAction.java index 78a9b03..273db1d 100644 --- a/src/main/java/ruscz/game/gameOfProd/Inventory/ItemAction.java +++ b/src/main/java/ruscz/game/gameOfProd/Inventory/ItemAction.java @@ -1,5 +1,8 @@ package ruscz.game.gameOfProd.Inventory; +/** + * Enumerations for Item, describing what action provide + */ public enum ItemAction { HEAL, MANA, DEFENCE, STRENGTH, KEY; } diff --git a/src/main/java/ruscz/game/gameOfProd/Inventory/ItemPanel.java b/src/main/java/ruscz/game/gameOfProd/Inventory/ItemPanel.java index 496289e..e01b6e5 100644 --- a/src/main/java/ruscz/game/gameOfProd/Inventory/ItemPanel.java +++ b/src/main/java/ruscz/game/gameOfProd/Inventory/ItemPanel.java @@ -5,9 +5,12 @@ import ruscz.game.gameOfProd.Image.ImageCell; import javax.swing.*; import java.awt.*; +/** + * Graphic representation of Item for Battle + */ public class ItemPanel extends JPanel { - ImageCell imageCell; - int item; + private final ImageCell imageCell; + private final int item; public ItemPanel(ImageCell imageCell, int item){ this.imageCell = imageCell; diff --git a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java index 0af6f19..7a13d51 100644 --- a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java +++ b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java @@ -22,7 +22,7 @@ import java.util.LinkedList; * It also holds references to all major classes */ public class WindowOfFreeMove extends JLayeredPane { - public static final int CELL_SIZE = 70; + public static final int CELL_SIZE = 69; public static int CANVAS_WIDTH = 50; public static int CANVAS_HEIGHT = 50; public static final int WINDOW_WIDTH = 13; @@ -211,8 +211,7 @@ public class WindowOfFreeMove extends JLayeredPane { mapManager.getActualMap().getPerson().move(); camera.moveCamera(); canvas.repaint(); - foreground.repaint(); - dialogBar.repaint(); + if (foreground.isVisible()) foreground.repaint(); }); timer.start(); } diff --git a/src/main/resources/maps/custom/name-objectset.txt b/src/main/resources/maps/custom/name-objectset.txt new file mode 100644 index 0000000..0a61ccd --- /dev/null +++ b/src/main/resources/maps/custom/name-objectset.txt @@ -0,0 +1,12 @@ +0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 +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/custom/name-tileset.txt b/src/main/resources/maps/custom/name-tileset.txt new file mode 100644 index 0000000..211b13d --- /dev/null +++ b/src/main/resources/maps/custom/name-tileset.txt @@ -0,0 +1,21 @@ + A2_Ground.png + A5_Tiles.png + CHEST 0 + TRIGGER 0 + BLOCK 0 + MOVETO 0 + EVENT 0 + DOOR/DOORTO 0 + DOOR qubodup-DoorOpen01-changed.wav qubodup-DoorClose02-changed.wav doorLocked.wav +194 194 194 194 194 194 194 194 194 194 194 194 +194 194 194 194 194 194 194 194 194 194 194 194 +194 194 194 194 194 194 194 194 194 194 194 194 +194 194 194 194 194 194 194 194 194 194 194 194 +194 194 194 194 194 194 194 194 194 194 194 194 +194 194 194 194 194 194 194 194 194 194 194 194 +194 194 194 194 194 194 194 194 194 194 194 194 +194 194 194 194 194 194 194 194 194 194 194 194 +194 194 194 194 194 194 194 194 194 194 194 194 +194 194 194 194 194 194 194 194 194 194 194 194 +194 194 194 194 194 194 194 194 194 194 194 194 +194 194 194 194 194 194 194 194 194 194 194 194 \ No newline at end of file diff --git a/src/main/resources/maps/custom/name.txt b/src/main/resources/maps/custom/name.txt new file mode 100644 index 0000000..012cb49 --- /dev/null +++ b/src/main/resources/maps/custom/name.txt @@ -0,0 +1,13 @@ +12 12 +EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY +EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY +EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY +EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY +EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY +EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY +EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY +EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY +EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY +EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY +EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY +EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY EMPTY \ 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 ecd9763..e19efff 100644 --- a/src/main/resources/save/savedGame/events.txt +++ b/src/main/resources/save/savedGame/events.txt @@ -14,7 +14,7 @@ 6 4 - true + false 14 @@ -24,7 +24,7 @@ 1 2 - true + false 15 @@ -35,7 +35,7 @@ 8 4 false - false + true 2 @@ -110,7 +110,7 @@ 2 12 false - false + true 17 @@ -152,13 +152,13 @@ 6 2 - true + false 6 1 false - false + true diff --git a/src/main/resources/save/savedGame/inventory.txt b/src/main/resources/save/savedGame/inventory.txt index e69de29..02de760 100644 --- a/src/main/resources/save/savedGame/inventory.txt +++ b/src/main/resources/save/savedGame/inventory.txt @@ -0,0 +1,6 @@ + + cup-o'-coffee + 1 + 295 + heal + diff --git a/src/main/resources/save/savedGame/person.txt b/src/main/resources/save/savedGame/person.txt index da4d904..f083d14 100644 --- a/src/main/resources/save/savedGame/person.txt +++ b/src/main/resources/save/savedGame/person.txt @@ -1,6 +1,6 @@ openspace 8 - 16 + 15 3 \ No newline at end of file