From 53f9333ce1c12e046d9c5366213803371dd3cfe2 Mon Sep 17 00:00:00 2001 From: musilto9 Date: Thu, 11 Jun 2020 12:33:41 +0200 Subject: [PATCH] improved javadoc and enimateMove --- .../ruscz/game/gameOfProd/Battle/Battle.java | 4 +- .../game/gameOfProd/Battle/BattlePerson.java | 21 +++ .../ruscz/game/gameOfProd/Battle/Enemy.java | 1 + .../ruscz/game/gameOfProd/Battle/Hero.java | 1 + .../ruscz/game/gameOfProd/Cells/Block.java | 6 + .../game/gameOfProd/Cells/ChestCell.java | 10 ++ .../ruscz/game/gameOfProd/Cells/DoorCell.java | 6 + .../gameOfProd/Cells/EventMoveToCell.java | 10 ++ .../gameOfProd/Cells/InteractionCell.java | 31 +++- .../java/ruscz/game/gameOfProd/Cells/Npc.java | 28 +++ .../ruscz/game/gameOfProd/Cells/Person.java | 36 ++++ .../game/gameOfProd/Cells/TriggerCell.java | 3 + .../game/gameOfProd/Cells/TypeOfCell.java | 3 + .../game/gameOfProd/Image/ImageCell.java | 12 +- .../game/gameOfProd/Image/ImageDoor.java | 2 +- .../game/gameOfProd/Image/ImagePerson.java | 4 +- .../gameOfProd/LevelEditor/CellSetConfig.java | 14 +- .../LevelEditor/DetailedCellInfo.java | 34 ++-- .../LevelEditor/EditorSaveManager.java | 2 +- .../gameOfProd/LevelEditor/InfoManager.java | 8 +- .../gameOfProd/LevelEditor/LevelEditor.java | 6 +- .../LevelEditor/MapLayersManager.java | 8 +- .../LevelEditor/TilesetOverview.java | 4 +- .../java/ruscz/game/gameOfProd/Map/Map.java | 20 +-- .../ruscz/game/gameOfProd/Map/MapManager.java | 4 +- .../game/gameOfProd/Save/LoadManager.java | 2 +- .../game/gameOfProd/Scripts/PathFinder.java | 2 +- .../game/gameOfProd/Scripts/TextParser.java | 8 +- .../game/gameOfProd/Sounds/MusicManager.java | 4 +- .../game/gameOfProd/Sounds/SoundManager.java | 6 +- .../gameOfProd/Windows/WindowOfBattle.java | 10 +- .../gameOfProd/Windows/WindowOfFreeMove.java | 15 +- src/main/resources/save/savedGame/events.txt | 163 +----------------- src/main/resources/save/savedGame/person.txt | 8 +- .../Windows/WindowOfFreeMoveTest.java | 17 +- 35 files changed, 257 insertions(+), 256 deletions(-) diff --git a/src/main/java/ruscz/game/gameOfProd/Battle/Battle.java b/src/main/java/ruscz/game/gameOfProd/Battle/Battle.java index f40b48f..a3096d3 100644 --- a/src/main/java/ruscz/game/gameOfProd/Battle/Battle.java +++ b/src/main/java/ruscz/game/gameOfProd/Battle/Battle.java @@ -60,7 +60,7 @@ public class Battle { } /** - * Checks, if all enemies dies + * Checks, if all enemies died * @return true if all dies */ public boolean checkHealthOfEnemies(){ @@ -68,7 +68,7 @@ public class Battle { } /** - * Checks, if all heroes dies + * Checks, if all heroes died * @return true if all dies */ public boolean checkHealthOfHeroes(){ diff --git a/src/main/java/ruscz/game/gameOfProd/Battle/BattlePerson.java b/src/main/java/ruscz/game/gameOfProd/Battle/BattlePerson.java index b603e06..8b8be6d 100644 --- a/src/main/java/ruscz/game/gameOfProd/Battle/BattlePerson.java +++ b/src/main/java/ruscz/game/gameOfProd/Battle/BattlePerson.java @@ -8,6 +8,9 @@ import java.awt.image.RescaleOp; import java.io.File; import java.io.IOException; +/** + * General class for all battle actors + */ public abstract class BattlePerson { protected int maxHealth; protected int health; @@ -34,6 +37,10 @@ public abstract class BattlePerson { strength = str; } + /** + * Parses image to be displayed + * @param name image file name + */ public void parseImage(String name) { try { image = ImageIO.read(new File("src/main/resources/characters/" + name.substring(0, name.indexOf("-battle")) + "/" + name + ".png")); @@ -47,6 +54,10 @@ public abstract class BattlePerson { effectCoords(effect); } + /** + * Starts timer that is effecting person's coordinates - creates movement effects + * @param effect effect name + */ private void effectCoords(String effect) { if (effect.equals("hover")) { final boolean[] isGoingUp = {true}; @@ -102,6 +113,9 @@ public abstract class BattlePerson { if (effectTimer!= null) effectTimer.stop(); } + /** + * Displays a flashing effect of getting hurt + */ private void getHurt() { BufferedImage originalImage = image; BufferedImage whiteImage = new BufferedImage(originalImage.getWidth(), originalImage.getHeight(), BufferedImage.TYPE_INT_ARGB); @@ -128,6 +142,9 @@ public abstract class BattlePerson { timer.start(); } + /** + * Displays a line effect of getting healed + */ protected void getHealed() { BufferedImage originalImage = image; BufferedImage whiteImage = new BufferedImage(originalImage.getWidth(), originalImage.getHeight(), BufferedImage.TYPE_INT_ARGB); @@ -150,6 +167,10 @@ public abstract class BattlePerson { timer.start(); } + /** + * Displays grid effect of dying and removes person from battle + * @param battle reference for Battle + */ public void getKilled(Battle battle) { BufferedImage originalImage = image; BufferedImage whiteImage = new BufferedImage(originalImage.getWidth(), originalImage.getHeight(), BufferedImage.TYPE_INT_ARGB); diff --git a/src/main/java/ruscz/game/gameOfProd/Battle/Enemy.java b/src/main/java/ruscz/game/gameOfProd/Battle/Enemy.java index 74b59b8..4ed4be6 100644 --- a/src/main/java/ruscz/game/gameOfProd/Battle/Enemy.java +++ b/src/main/java/ruscz/game/gameOfProd/Battle/Enemy.java @@ -11,6 +11,7 @@ public class Enemy extends BattlePerson { this.id = id; } + //this constructor is here for of tests public Enemy(int hp, int lvl, String name, int str, int id) { super(hp, lvl, name, str); this.id = id; diff --git a/src/main/java/ruscz/game/gameOfProd/Battle/Hero.java b/src/main/java/ruscz/game/gameOfProd/Battle/Hero.java index 41f8e57..48bc300 100644 --- a/src/main/java/ruscz/game/gameOfProd/Battle/Hero.java +++ b/src/main/java/ruscz/game/gameOfProd/Battle/Hero.java @@ -15,6 +15,7 @@ public class Hero extends BattlePerson { isBlocking = false; } + //this constructor is here for of tests public Hero(int hp, int lvl, String name, int str, int mana, int defence){ super(hp, lvl, name, str); this.mana = mana; diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/Block.java b/src/main/java/ruscz/game/gameOfProd/Cells/Block.java index 73e7ce0..5705280 100644 --- a/src/main/java/ruscz/game/gameOfProd/Cells/Block.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/Block.java @@ -40,6 +40,12 @@ public class Block extends Cell { } + /** + * @param x X position + * @param y Y position + * @param half is half-block + * @return true if Block is upper half-block + */ public boolean isInBlock(int x, int y, boolean half) { return (this.getX() == x) && (this.getY() == y) && !(partial.equals("d")); } diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/ChestCell.java b/src/main/java/ruscz/game/gameOfProd/Cells/ChestCell.java index 7be716b..21f5bf0 100644 --- a/src/main/java/ruscz/game/gameOfProd/Cells/ChestCell.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/ChestCell.java @@ -12,6 +12,9 @@ import java.io.FileNotFoundException; import java.util.LinkedList; import java.util.Scanner; +/** + * Special type of Interaction cell that holds an inventory + */ public class ChestCell extends InteractionCell { private final LinkedList chestInventory; private boolean showItem; @@ -33,6 +36,10 @@ public class ChestCell extends InteractionCell { fillChest(inventory); } + /** + * Fills chest with item from file + * @param inventory name of inventory file + */ private void fillChest(String inventory) { try { File inventoryInfo = new File("src/main/resources/chests/" + inventory + ".txt"); @@ -55,6 +62,9 @@ public class ChestCell extends InteractionCell { } } + /** + * Puts an item in Players inventory + */ private void putItemToInventory() { if (chestInventory.size() == 0) { endEvent(); diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/DoorCell.java b/src/main/java/ruscz/game/gameOfProd/Cells/DoorCell.java index 3f61c22..647c25a 100644 --- a/src/main/java/ruscz/game/gameOfProd/Cells/DoorCell.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/DoorCell.java @@ -7,6 +7,9 @@ import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; import java.awt.*; +/** + * Special type of Interaction cell that can act as a Block or as Empty + */ public class DoorCell extends InteractionCell { private boolean isOpen; private boolean isLocked; @@ -45,6 +48,9 @@ public class DoorCell extends InteractionCell { super.useItem(item); } + /** + * Sets sound that is played on interaction + */ private void setSound() { if (isOpen) { sound = super.getSoundManager().getSoundMap().get("doorOpen"); diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/EventMoveToCell.java b/src/main/java/ruscz/game/gameOfProd/Cells/EventMoveToCell.java index fc4d2b1..084229f 100644 --- a/src/main/java/ruscz/game/gameOfProd/Cells/EventMoveToCell.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/EventMoveToCell.java @@ -5,6 +5,9 @@ import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; import java.awt.*; +/** + * Cell that moves Player between maps + */ public class EventMoveToCell extends Cell { private final Map map; private final WindowOfFreeMove window; @@ -29,6 +32,9 @@ public class EventMoveToCell extends Cell { public int getDirectionOut() { return directionOut; } + /** + * Moves player to map that is linked with this Moveto cell + */ public void moveToMap() { window.getMapManager().getActualMap().setIdExit(id); window.setMapManager(this.map); @@ -39,6 +45,10 @@ public class EventMoveToCell extends Cell { WindowOfFreeMove.setCanPersonMove(true); } + /** + * Checks for active Trigger cells in the directionOut from Door + * @return true if there is an active Trigger cell + */ private boolean isActiveTriggerBehindMoveTo() { int x = window.getMapManager().getActualMap().getPerson().getX(); int y = window.getMapManager().getActualMap().getPerson().getY(); diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java b/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java index 181288f..811cb9a 100644 --- a/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java @@ -17,6 +17,9 @@ import java.io.FileNotFoundException; import java.util.Objects; import java.util.Scanner; +/** + * Cell that is interactible by Player + */ public class InteractionCell extends Cell { protected String message; protected Dialog dialog; @@ -38,6 +41,9 @@ public class InteractionCell extends Cell { this.paint = paint; } + /** + * Starts regular event or cut-scene + */ public void startEvent() { if (message != null) { if (message.contains("cutscene")) { @@ -56,6 +62,10 @@ public class InteractionCell extends Cell { } } + /** + * Reads event file and passes in on to readNextLine + * @param name event file name + */ public void readDialogFile(String name) { try { File dialogFile = new File("src/main/resources/dialogs/" + name + ".txt"); @@ -67,6 +77,9 @@ public class InteractionCell extends Cell { } } + /** + * Parses line of event text into set of commands + */ public void readNextLine() { if (scanner.hasNextLine() && !dialog.getTimerIsRunning()) { String data = scanner.nextLine(); @@ -211,6 +224,9 @@ public class InteractionCell extends Cell { } } + /** + * Ends event and bounds camera + */ public void endEvent() { if (dialog != null) { dialog.hideText(); @@ -226,6 +242,11 @@ public class InteractionCell extends Cell { } } + /** + * Parses line of cut-scene text into a set of commands if the sequence numbers are equal + * @param name text to parse + * @param i sequence number + */ public void playCustscene(String name, int i) { try { File cutsceneFile = new File("src/main/resources/dialogs/cutscenes/" + name + ".txt"); @@ -257,7 +278,7 @@ public class InteractionCell extends Cell { String[] texts = line.split(""); final int[] j = {0}; textTimer = new Timer(100, e -> { - if (j[0] == texts.length - 1) stopTextTimer(); + if (j[0] == texts.length - 1) textTimer.stop(); if (!dialog.getTimerIsRunning()) { if (texts[j[0]].contains("
")) { texts[j[0]] = "" + texts[j[0]] + ""; @@ -370,10 +391,10 @@ public class InteractionCell extends Cell { } } - private void stopTextTimer() { - textTimer.stop(); - } - + /** + * Uses a selected item + * @param item item to be used + */ public void useItem(Item item) { InventoryManager.removeItem(item, 1); } diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/Npc.java b/src/main/java/ruscz/game/gameOfProd/Cells/Npc.java index 63c6e3c..efbd45f 100644 --- a/src/main/java/ruscz/game/gameOfProd/Cells/Npc.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/Npc.java @@ -15,6 +15,9 @@ import java.io.IOException; import java.util.LinkedList; import java.util.Scanner; +/** + * Person-like cell that is controlled by application + */ public class Npc extends Person { private final MapManager mapManager; private String name; @@ -41,6 +44,11 @@ public class Npc extends Person { this.mapManager = mapManager; } + /** + * Finds closest path from current position to end and moves NPC accordingly + * @param endX ending X value + * @param endY ending Y value + */ public void move(int endX, int endY) { PathFinder pathFinder = new PathFinder(getMap()); LinkedList directions = pathFinder.getWayWithCollision(getX(), getY(), endX, endY); @@ -75,6 +83,11 @@ public class Npc extends Person { timer.start(); } + /** + * Stops NPC's movement and if battle name is not null and there is Player in front of NPC, is starts battle sequence + * @param endX ending X value + * @param endY ending Y value + */ private void stopNPCMove(int endX, int endY) { timer.stop(); if (battle != null && endX == mapManager.getActualMap().getPerson().getX() && endY == mapManager.getActualMap().getPerson().getY()) { @@ -82,30 +95,45 @@ public class Npc extends Person { } } + /** + * Moves NPC up one cell + */ private void moveUp() { int y = getY() - 1; set(getX(), y); direction = 2; } + /** + * Moves NPC down one cell + */ private void moveDown() { int y = getY() + 1; set(getX(), y); direction = 1; } + /** + * Moves NPC left one cell + */ private void moveLeft() { int x = getX() - 1; set(x, getY()); direction = 0; } + /** + * Moves NPC right one cell + */ private void moveRight() { int x = getX() + 1; set(x, getY()); direction = 3; } + /** + * Loads NPC's attributes from file + */ private void loadNpc() { File dialogFile = new File("src/main/resources/characters/" + name + "/" + name + ".txt"); Scanner scanner = null; diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/Person.java b/src/main/java/ruscz/game/gameOfProd/Cells/Person.java index eb4098d..7f74e13 100644 --- a/src/main/java/ruscz/game/gameOfProd/Cells/Person.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/Person.java @@ -6,6 +6,9 @@ import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; import java.awt.*; +/** + * Class managing Player + */ public class Person extends Cell { private final int WALKING_SPEED = 3; @@ -17,6 +20,7 @@ public class Person extends Cell { private boolean isMoving; private static boolean isInEvent; private int distanceOfAnimation; + private long time; public Map getMap() { return map; @@ -61,6 +65,9 @@ public class Person extends Cell { this.imagePerson = new ImagePerson(name, rectangles); } + /** + * Checks for user input then checks if movement is possible then moves Player + */ public void move() { if (!isMoving) { int x = this.getX(); @@ -173,16 +180,37 @@ public class Person extends Cell { } } + /** + * Checks if there is an Event cell in front of Player + * @param x X position of Player + * @param y Y position of Player + * @param directionSight direction of sight of Player + * @return true if there is an event in front of Player + */ private boolean isEventInFront(int x, int y, int directionSight) { int[] coords = map.directionSightSwitch(x, y, directionSight); return map.isInteractionCell(coords[0], coords[1]); } + /** + * Checks if there is a Door cell in front of Player + * @param x X position of Player + * @param y Y position of Player + * @param directionSight direction of sight of Player + * @return true if there is a door in front of Player + */ private boolean isDoorInFront(int x, int y, int directionSight) { int[] coords = map.directionSightSwitch(x, y, directionSight); return map.isDoor(coords[0], coords[1]); } + /** + * Checks if there is a Chest cell in front of Player + * @param x X position of Player + * @param y Y position of Player + * @param directionSight direction of sight of Player + * @return true if there is a chest in front of Player + */ private boolean isChestInFront(int x, int y, int directionSight) { int[] coords = map.directionSightSwitch(x, y, directionSight); return map.isActiveChest(coords[0], coords[1]); @@ -229,7 +257,15 @@ public class Person extends Cell { } } + /** + * Animates Players move throughout the map + * @param g graphics for painting + * @param direction Player's movement direction + */ public void animateMove(Graphics2D g, int direction){ + if (System.currentTimeMillis() - time < WindowOfFreeMove.REPAINT_DELAY) + WindowOfFreeMove.sleep(WindowOfFreeMove.REPAINT_DELAY - (System.currentTimeMillis() - time)); + time = System.currentTimeMillis(); int Xsize = 0; int Ysize = 0; switch (direction) { diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/TriggerCell.java b/src/main/java/ruscz/game/gameOfProd/Cells/TriggerCell.java index 74b255a..7360263 100644 --- a/src/main/java/ruscz/game/gameOfProd/Cells/TriggerCell.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/TriggerCell.java @@ -6,6 +6,9 @@ import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; import java.awt.*; +/** + * Special type of Interaction cell that is triggered on Player stepping onto it + */ public class TriggerCell extends InteractionCell { private boolean isActive; diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/TypeOfCell.java b/src/main/java/ruscz/game/gameOfProd/Cells/TypeOfCell.java index b4c3774..0edf946 100644 --- a/src/main/java/ruscz/game/gameOfProd/Cells/TypeOfCell.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/TypeOfCell.java @@ -1,5 +1,8 @@ package ruscz.game.gameOfProd.Cells; +/** + * Enumeration of basic cell types + */ public enum TypeOfCell { BLOCK, EMPTY, MOVETO, EVENT, SPAWNPOINT; } diff --git a/src/main/java/ruscz/game/gameOfProd/Image/ImageCell.java b/src/main/java/ruscz/game/gameOfProd/Image/ImageCell.java index 41d9a51..433d19c 100644 --- a/src/main/java/ruscz/game/gameOfProd/Image/ImageCell.java +++ b/src/main/java/ruscz/game/gameOfProd/Image/ImageCell.java @@ -25,9 +25,9 @@ public class ImageCell { private int[][] mapForeground; /** + * Creates new matrices based on winth and height values * @param width is width of new map * @param height is height of new map - * Creates new matrices based on winth and height values */ public void readMapFile(int width, int height) { mapBackground = new int[width][height]; @@ -35,8 +35,8 @@ public class ImageCell { } /** - * @param name is name of map file * Reads and parses (map-name)-tileset.txt file into matrices and arrays, separates values and passes them on for further parsing + * @param name is name of map file */ public void readMapFile(String name) { try { @@ -75,8 +75,8 @@ public class ImageCell { } /** - * @param tilesetInfo is name of tileset image * Parses tileset image into a tileset (array) + * @param tilesetInfo is name of tileset image */ public void imageTileset(String[] tilesetInfo) { try { @@ -113,8 +113,8 @@ public class ImageCell { } /** - * @param file is name of map tp be parsed * Parses (map-name)-objectset.txt file into a matrix + * @param file is name of map tp be parsed */ public void imageObjectset(String file) { try { @@ -134,8 +134,8 @@ public class ImageCell { } /** - * @param cellInfo is text representation of cellMap * Parses text into a hash map + * @param cellInfo is text representation of cellMap */ public void loadCellMap(String[] cellInfo) { if (cellMap == null) @@ -158,8 +158,8 @@ public class ImageCell { } /** - * @param itemInfo is name of item image * Parses item image into array + * @param itemInfo is name of item image */ public void imageItem(String itemInfo) { int imageWidth = 0; diff --git a/src/main/java/ruscz/game/gameOfProd/Image/ImageDoor.java b/src/main/java/ruscz/game/gameOfProd/Image/ImageDoor.java index fa1eea8..443d5e4 100644 --- a/src/main/java/ruscz/game/gameOfProd/Image/ImageDoor.java +++ b/src/main/java/ruscz/game/gameOfProd/Image/ImageDoor.java @@ -15,8 +15,8 @@ public class ImageDoor { private int size; /** - * @param rectangles is array of door images * Parses images of door into an array + * @param rectangles is array of door images */ public void setAllImagesOfDoor(Rectangle[] rectangles){ imagesOfDoor = new BufferedImage[4]; diff --git a/src/main/java/ruscz/game/gameOfProd/Image/ImagePerson.java b/src/main/java/ruscz/game/gameOfProd/Image/ImagePerson.java index b502f78..2e1084d 100644 --- a/src/main/java/ruscz/game/gameOfProd/Image/ImagePerson.java +++ b/src/main/java/ruscz/game/gameOfProd/Image/ImagePerson.java @@ -19,8 +19,8 @@ public class ImagePerson { private int subimageHeight; /** - * @param rectangles is array of hero images * Parses images of hero into an array + * @param rectangles is array of hero images */ public void setAllImagesOfDirection(Rectangle[] rectangles){ imagesOfDirection = new BufferedImage[12]; @@ -54,9 +54,9 @@ public class ImagePerson { } /** + * Resizes image to be properly displayed in game * @param img is image to be resized * @return resized image - * Resizes image to be properly displayed in game */ public BufferedImage resize(BufferedImage img) { Image tmp; diff --git a/src/main/java/ruscz/game/gameOfProd/LevelEditor/CellSetConfig.java b/src/main/java/ruscz/game/gameOfProd/LevelEditor/CellSetConfig.java index 889f270..0bcecf6 100644 --- a/src/main/java/ruscz/game/gameOfProd/LevelEditor/CellSetConfig.java +++ b/src/main/java/ruscz/game/gameOfProd/LevelEditor/CellSetConfig.java @@ -91,10 +91,10 @@ public class CellSetConfig { } /** + * Creates new JLabel with name of cell type * @param name is name of label * @param offset is offset of label * @return new JLabel - * Creates new JLabel with name of cell type */ private JLabel nameLabel(String name, int offset) { JLabel label = new JLabel("
" + name + "
"); @@ -103,10 +103,10 @@ public class CellSetConfig { } /** + * Creates new JLabel with image of the selected tile * @param name is name of label * @param offset is offset of label * @return new JLabel - * Creates new JLabel with image of the selected tile */ private JLabel iconLabel(String name, int offset) { JLabel label = new JLabel(); @@ -118,9 +118,9 @@ public class CellSetConfig { } /** + * Creates label with 'Inner Value:' text * @param offset is offset of label * @return new JLabel - * Creates label with 'Inner Value:' text */ private JLabel valueLabel(int offset) { JLabel label = new JLabel("Inner Value:"); @@ -129,10 +129,10 @@ public class CellSetConfig { } /** + * Creates text field for value input * @param name is name of field * @param offset is offset of field * @return new JTextField - * Creates text field for value input */ private JTextField numField(String name, int offset) { JTextField field = new JTextField(String.valueOf(editor.getCellMap().get(name))); @@ -142,11 +142,11 @@ public class CellSetConfig { } /** + * Creates new button for importing value from Tileset Overview * @param iconLabel is label to be changed * @param tileNum is text field to be changed * @param offset is offset of button * @return new JButton - * Creates new button for importing value from Tileset Overview */ private JButton importButton(JLabel iconLabel, JTextField tileNum, int offset) { JButton button = new JButton("Import selected tile"); @@ -166,10 +166,10 @@ public class CellSetConfig { } /** + * Creates new button for selecting a tile in Tileset Overview * @param importButton is reference for connected import button * @param offset is offset of button * @return new JButton - * Creates new button for selecting a tile in Tileset Overview */ private JButton selectButton(JButton importButton, int offset) { JButton button = new JButton("Select tile"); @@ -186,9 +186,9 @@ public class CellSetConfig { } /** + * Creates new label that is used as a divider between different blocks of fields * @param offset is offset of label * @return new JLabel - * Creates new label that is used as a divider between different blocks of fields */ private JLabel dividerLabel(int offset) { JLabel label = new JLabel(); diff --git a/src/main/java/ruscz/game/gameOfProd/LevelEditor/DetailedCellInfo.java b/src/main/java/ruscz/game/gameOfProd/LevelEditor/DetailedCellInfo.java index 1cc4203..c126ffd 100644 --- a/src/main/java/ruscz/game/gameOfProd/LevelEditor/DetailedCellInfo.java +++ b/src/main/java/ruscz/game/gameOfProd/LevelEditor/DetailedCellInfo.java @@ -23,8 +23,8 @@ public class DetailedCellInfo extends JPanel { } /** - * @param type is type of cell * Displays detailed info based on the type of cell provided + * @param type is type of cell */ public void displayDetailedCellInfo(String type) { removeAll(); @@ -68,11 +68,11 @@ public class DetailedCellInfo extends JPanel { } /** + * Displays set of radio buttons for true/false selection * @param title is tile of this field * @param trueLabel is true value * @param falseLabel is false value * @param offset is offset from top of menu - * Displays set of radio buttons for true/false selection */ private void trueFalseInfo(String title, String trueLabel, String falseLabel, int offset) { JLabel label = new JLabel("
Is " + title + "
"); @@ -102,10 +102,10 @@ public class DetailedCellInfo extends JPanel { } /** + * Displays one text field with a name * @param title is tile of this field * @param fieldName is name of text field * @param offset is offset from top of menu - * Displays one text field with a name */ private void fieldInfo(String title, String fieldName, int offset) { JLabel label = new JLabel("
" + title + "
"); @@ -162,8 +162,8 @@ public class DetailedCellInfo extends JPanel { } /** - * @param offset is offset from top of menu * Displays set of four radio buttons for direction selection + * @param offset is offset from top of menu */ private void directionInfo(int offset) { JLabel label = new JLabel("
Direction Out
"); @@ -208,9 +208,9 @@ public class DetailedCellInfo extends JPanel { } /** + * Saves all attributes from menu into text * @param type type of cell * @return cell value as it would be in a text file - * Saves all attributes from menu into text */ public String getCellInfo(String type) { String info = type; @@ -262,9 +262,9 @@ public class DetailedCellInfo extends JPanel { } /** + * Changes type of cell based on visibility value * @param type type of cell * @return changed type of cell - * Changes type of cell based on visibility value */ private String getVisibleInfo(String type) { String info = ""; @@ -282,8 +282,8 @@ public class DetailedCellInfo extends JPanel { } /** - * @return text to determine if block is half-block * Checks if a block is supposed to be half-block + * @return text to determine if block is half-block */ private String getUpperLowerInfo() { String info = ""; @@ -301,10 +301,10 @@ public class DetailedCellInfo extends JPanel { } /** + * Saves field value * @param fieldName name of field to be saved * @param isRequired is this field required to be filled in * @return value form field - * Saves field value */ private String getFieldInfo(String fieldName, boolean isRequired) { String info = ""; @@ -324,9 +324,9 @@ public class DetailedCellInfo extends JPanel { } /** + * Checks id field value is an integer and saves it * @param fieldName name of field to be saved * @return value form field - * Checks id field value is an integer and saves it */ private String getFieldIntegerInfo(String fieldName) { String info = ""; @@ -344,10 +344,10 @@ public class DetailedCellInfo extends JPanel { } /** + * Saves true/false value as text * @param trueLabel is name of true button * @param falseLabel is name of false button * @return text representation - * Saves true/false value as text */ private String getTrueFalseInfo(String trueLabel, String falseLabel) { String info = ""; @@ -365,8 +365,8 @@ public class DetailedCellInfo extends JPanel { } /** - * @return text representation of direction * Saves direction info as text + * @return text representation of direction */ private String getDirectionInfo() { String info = ""; @@ -392,9 +392,9 @@ public class DetailedCellInfo extends JPanel { } /** + * Changes type of cell based on direction value * @param type type of cell * @return changed type of cell - * Changes type of cell based on direction value */ private String getDoorInfo(String type) { String info = ""; @@ -408,8 +408,8 @@ public class DetailedCellInfo extends JPanel { } /** - * @return text representation * Saves if door is supposed to be locked + * @return text representation */ private String getLockedInfo() { String info = ""; @@ -471,8 +471,8 @@ public class DetailedCellInfo extends JPanel { } /** - * @param value is text true/false value * Parses value and checks corresponding button + * @param value is text true/false value */ private void setTrueFalseInfo(String value) { if (value.equals("false")) { @@ -502,8 +502,8 @@ public class DetailedCellInfo extends JPanel { } /** - * @param value is text half-block value * Parses value and checks corresponding button + * @param value is text half-block value */ private void setUpperLowerInfo(String value) { String name = ""; @@ -524,9 +524,9 @@ public class DetailedCellInfo extends JPanel { } /** + * Fills a selected field with value * @param fieldName is name of field to be filled in * @param value is new value of field - * Fills a selected field with value */ private void setFieldInfo(String fieldName, String value) { for (JTextField field : textFields) { @@ -538,8 +538,8 @@ public class DetailedCellInfo extends JPanel { } /** - * @param value is text direction value * Parses value and checks corresponding button + * @param value is text direction value */ private void setDirectionInfo(String value) { String name = ""; diff --git a/src/main/java/ruscz/game/gameOfProd/LevelEditor/EditorSaveManager.java b/src/main/java/ruscz/game/gameOfProd/LevelEditor/EditorSaveManager.java index 30aeac7..8f2b50e 100644 --- a/src/main/java/ruscz/game/gameOfProd/LevelEditor/EditorSaveManager.java +++ b/src/main/java/ruscz/game/gameOfProd/LevelEditor/EditorSaveManager.java @@ -32,8 +32,8 @@ public class EditorSaveManager { } /** - * @return is tileset valid * Checks if a tileset exists and is not empty + * @return is tileset valid */ public boolean validate() { boolean valid = editor.getImagesOfTiles() != null && editor.getImagesOfTiles().size() > 0; diff --git a/src/main/java/ruscz/game/gameOfProd/LevelEditor/InfoManager.java b/src/main/java/ruscz/game/gameOfProd/LevelEditor/InfoManager.java index 417a0a0..acf32f1 100644 --- a/src/main/java/ruscz/game/gameOfProd/LevelEditor/InfoManager.java +++ b/src/main/java/ruscz/game/gameOfProd/LevelEditor/InfoManager.java @@ -23,11 +23,11 @@ public class InfoManager { } /** + * Decides which type of info is needed for a selected cell * @param label is label to be parsed and displayed * @param layer is name of layer on which the cell is located * @param x is X value of cell * @param y is Y value of cell - * Decides which type of info is needed for a selected cell */ protected void displayInfo(JLabel label, String layer, int x, int y) { if (info != null) { @@ -62,11 +62,11 @@ public class InfoManager { } /** + * Displays info regarding object cells and tile cells * @param label is label to be parsed and displayed * @param x is X value of cell * @param y is Y value of cell * @param isObject is cell on object layer - * Displays info regarding object cells and tile cells */ private void displayObjectAndTileInfo(JLabel label, int x, int y, boolean isObject) { JLabel infoLabel = new JLabel(); @@ -176,10 +176,10 @@ public class InfoManager { } /** + * Displays info regarding 'physical' cells (from mapArray) * @param label is label to be parsed and displayed * @param x is X value of cell * @param y is Y value of cell - * Displays info regarding 'physical' cells (from mapArray) */ private void displayCellInfo(JLabel label, int x, int y) { String[] array = {"EMPTY", "BLOCK", "INTER", "TRIGGER", "MOVETO", "DOOR", "DOORTO", "CHEST"}; @@ -264,10 +264,10 @@ public class InfoManager { } /** + * Puts DOOR cell into correct places in map's cell matrix * @param value is value of cell to ba parsed * @param x is X value of cell * @param y is Y value of cell - * Puts DOOR cell into correct places in map's cell matrix */ private void saveDoor(String value, int x, int y) { if (value.split(",")[0].contains("DOOR") && y == 0) { diff --git a/src/main/java/ruscz/game/gameOfProd/LevelEditor/LevelEditor.java b/src/main/java/ruscz/game/gameOfProd/LevelEditor/LevelEditor.java index 29431d1..4ef4645 100644 --- a/src/main/java/ruscz/game/gameOfProd/LevelEditor/LevelEditor.java +++ b/src/main/java/ruscz/game/gameOfProd/LevelEditor/LevelEditor.java @@ -128,10 +128,10 @@ public class LevelEditor extends JFrame { } /** + * Creates new map and populates it's cell matrix and passes it on * @param name is name of new map * @param width is width of new map * @param height is height of new map - * Creates new map and populates it's cell matrix and passes it on */ public void createNewMap(String name, int width, int height) { TypeOfCell[][] mapArray = new TypeOfCell[width][height]; @@ -316,8 +316,8 @@ public class LevelEditor extends JFrame { } /** - * @param message is text to be displayed * Displays message as an error in the error field + * @param message is text to be displayed */ protected void displayError(String message) { errorMessage.setText("" + message + ""); @@ -325,8 +325,8 @@ public class LevelEditor extends JFrame { } /** - * @param message is text to be displayed * Displays message as a normal text in the error field + * @param message is text to be displayed */ protected void displayMessage(String message) { errorMessage.setText(message); diff --git a/src/main/java/ruscz/game/gameOfProd/LevelEditor/MapLayersManager.java b/src/main/java/ruscz/game/gameOfProd/LevelEditor/MapLayersManager.java index d187f72..7740ad7 100644 --- a/src/main/java/ruscz/game/gameOfProd/LevelEditor/MapLayersManager.java +++ b/src/main/java/ruscz/game/gameOfProd/LevelEditor/MapLayersManager.java @@ -184,10 +184,10 @@ public class MapLayersManager { } /** + * Sets cell a corresponding icon from cellMap dictionary * @param cell is cell to ba updated * @param i is cell's Y value * @param j is cell's X value - * Sets cell a corresponding icon from cellMap dictionary */ private void setCellIcon(JLabel cell, int i, int j) { String value; @@ -220,9 +220,9 @@ public class MapLayersManager { } /** + * Converts image to buffered image * @param img is image to be converted * @return converted image - * Converts image to buffered image */ private BufferedImage toBufferedImage(Image img) { BufferedImage bimage = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB); @@ -233,10 +233,10 @@ public class MapLayersManager { } /** + * Converts regulat image (50x50px) to a half block (upper or lower) * @param img is image to be tilified * @param isUp is an upper block * @return tilified image - * Converts regulat image (50x50px) to a half block (upper or lower) */ private BufferedImage tilify(BufferedImage img, boolean isUp) { BufferedImage image = new BufferedImage(50, 50, BufferedImage.TYPE_INT_ARGB); @@ -248,9 +248,9 @@ public class MapLayersManager { } /** + * Sets corresponding image to a door cell (and one cell above/lower) * @param cell is cell to be updated * @param info cell text value - * Sets corresponding image to a door cell (and one cell above/lower) */ private void setDoorImage(JLabel cell, String[] info) { if (editor.getCellMap().get("DOOR/DOORTO") == 0) { diff --git a/src/main/java/ruscz/game/gameOfProd/LevelEditor/TilesetOverview.java b/src/main/java/ruscz/game/gameOfProd/LevelEditor/TilesetOverview.java index 32512dc..38433e3 100644 --- a/src/main/java/ruscz/game/gameOfProd/LevelEditor/TilesetOverview.java +++ b/src/main/java/ruscz/game/gameOfProd/LevelEditor/TilesetOverview.java @@ -34,8 +34,8 @@ public class TilesetOverview extends JFrame { } /** - * @param folder is folder with tileset images * Displays menu all possible images to be parsed into tileset + * @param folder is folder with tileset images */ public void listFilesForFolder(File folder) { activeTilesets = new LinkedList<>(); @@ -79,8 +79,8 @@ public class TilesetOverview extends JFrame { } /** - * @param name is image name * Displays name of file with a designated checkbox + * @param name is image name */ private void loadTileset(String name) { JLabel text = new JLabel(name); diff --git a/src/main/java/ruscz/game/gameOfProd/Map/Map.java b/src/main/java/ruscz/game/gameOfProd/Map/Map.java index 31035b0..206fb96 100644 --- a/src/main/java/ruscz/game/gameOfProd/Map/Map.java +++ b/src/main/java/ruscz/game/gameOfProd/Map/Map.java @@ -51,10 +51,10 @@ public class Map { } /** + * Finds map by name in a list of loaded maps * @param nameOfMap is map name that is being searched for * @param window is reference for WindowOfFreeMove * @return found map - * Finds map by name in a list of loaded maps */ public static Map findMapByName(String nameOfMap, WindowOfFreeMove window) { LinkedList mapLinkedList = window.getMapLinkedList(); @@ -66,10 +66,10 @@ public class Map { } /** + * Creates map and prepares all fields, then passes map on loadMap * @param name is map file name * @param window is reference for WindowOfFreeMove * @return loaded map - * Creates map and prepares all fields, then passes map on loadMap */ public static Map loadMapFromFile(String name, WindowOfFreeMove window) { try { @@ -99,12 +99,12 @@ public class Map { } /** + * Parses line of text into corresponding cells with attributes and populates corresponding lists wit them * @param map is map being loaded * @param data is line of map file to be parsed * @param size is array of map's size in cells * @param y is current Y value of line being parsed * @param window is reference for WindowOfFreeMove - * Parses line of text into corresponding cells with attributes and populates corresponding lists wit them */ public static void loadMap(Map map, String data, String[] size, int y, WindowOfFreeMove window) { String[] line = data.split(" "); @@ -161,9 +161,9 @@ public class Map { /** + * Parses MOVETO and DOORTO cells, which link different maps together * @param map is map being linked * @param window is reference on WindowOfFreeMove - * Parses MOVETO and DOORTO cells, which link different maps together */ public void linkMaps(Map map, WindowOfFreeMove window) { try { @@ -204,8 +204,8 @@ public class Map { } /** - * @param moveToCell is MOVETO cell being added * Updates map's cell matrix and adds cell to corresponding list + * @param moveToCell is MOVETO cell being added */ public void addMoveToEvent(EventMoveToCell moveToCell) { mapArray[moveToCell.getX()][moveToCell.getY()] = TypeOfCell.MOVETO; @@ -213,8 +213,8 @@ public class Map { } /** - * @param interactionCell is INTER cell being added * Updates map's cell matrix and adds cell to corresponding list + * @param interactionCell is INTER cell being added */ public void addInteractionEvent(InteractionCell interactionCell) { mapArray[interactionCell.getX()][interactionCell.getY()] = TypeOfCell.EVENT; @@ -222,8 +222,8 @@ public class Map { } /** - * @param triggerCell is TRIGGER cell being added * Updates map's cell matrix and adds cell to corresponding list + * @param triggerCell is TRIGGER cell being added */ public void addInteractionEvent(TriggerCell triggerCell) { mapArray[triggerCell.getX()][triggerCell.getY()] = TypeOfCell.EVENT; @@ -231,8 +231,8 @@ public class Map { } /** - * @param doorCell is DOOR(TO) cell being added * Updates map's cell matrix and adds cell to corresponding list + * @param doorCell is DOOR(TO) cell being added */ public void addInteractionEvent(DoorCell doorCell) { mapArray[doorCell.getX()][doorCell.getY()] = TypeOfCell.EVENT; @@ -240,8 +240,8 @@ public class Map { } /** - * @param chestCell is CHEST cell being added * Updates map's cell matrix and adds cell to corresponding list + * @param chestCell is CHEST cell being added */ public void addInteractionEvent(ChestCell chestCell) { mapArray[chestCell.getX()][chestCell.getY()] = TypeOfCell.EVENT; @@ -489,11 +489,11 @@ public class Map { } /** + * Translates direction of sight into new coords * @param x is starting X value * @param y is starting Y value * @param directionSight is direction of hero's sight * @return array of new X & Y coordinates - * Translates direction of sight into new coords */ public int[] directionSightSwitch(int x, int y, int directionSight) { switch (directionSight) { diff --git a/src/main/java/ruscz/game/gameOfProd/Map/MapManager.java b/src/main/java/ruscz/game/gameOfProd/Map/MapManager.java index 09e7344..ed3e7dd 100644 --- a/src/main/java/ruscz/game/gameOfProd/Map/MapManager.java +++ b/src/main/java/ruscz/game/gameOfProd/Map/MapManager.java @@ -32,8 +32,8 @@ public class MapManager { } /** - * @param map is map to be set * Sets map as the one that is currently used, if that map is not present in map list, the map is added + * @param map is map to be set */ public void setMap(Map map) { if (maps.contains(map)) { @@ -131,8 +131,8 @@ public class MapManager { } /** - * @param size is array of new sizes for canvas * Sets canvas size based on current map + * @param size is array of new sizes for canvas */ public void resizeCanvas(int[] size) { canvas.setPreferredSize(new Dimension( diff --git a/src/main/java/ruscz/game/gameOfProd/Save/LoadManager.java b/src/main/java/ruscz/game/gameOfProd/Save/LoadManager.java index 362cd2a..d95503e 100644 --- a/src/main/java/ruscz/game/gameOfProd/Save/LoadManager.java +++ b/src/main/java/ruscz/game/gameOfProd/Save/LoadManager.java @@ -31,8 +31,8 @@ public class LoadManager { } /** - * @return are save files empty * Checks if save files are empty (if there is no saved progress) + * @return are save files empty */ public static boolean isSaveEmpty() { File personFile = new File("src/main/resources/save/savedGame/person.txt"); diff --git a/src/main/java/ruscz/game/gameOfProd/Scripts/PathFinder.java b/src/main/java/ruscz/game/gameOfProd/Scripts/PathFinder.java index 0344ec3..355cd1b 100644 --- a/src/main/java/ruscz/game/gameOfProd/Scripts/PathFinder.java +++ b/src/main/java/ruscz/game/gameOfProd/Scripts/PathFinder.java @@ -20,12 +20,12 @@ public class PathFinder { } /** + * Finds path with A* algorithm and translates it to directions using Direction enumeration * @param startX is starting X value * @param startY is starting Y value * @param endX is ending X value * @param endY is ending Y value * @return list of directions for NPC - * Finds path with A* algorithm and translates it to directions using Direction enumeration */ public LinkedList getWayWithCollision(int startX, int startY, int endX, int endY) { AStar aStar = new AStar(map.getMapArray().length, map.getMapArray()[0].length, new Node(startX, startY), new Node(endX, endY)); diff --git a/src/main/java/ruscz/game/gameOfProd/Scripts/TextParser.java b/src/main/java/ruscz/game/gameOfProd/Scripts/TextParser.java index 5aa1fd7..e034fb1 100644 --- a/src/main/java/ruscz/game/gameOfProd/Scripts/TextParser.java +++ b/src/main/java/ruscz/game/gameOfProd/Scripts/TextParser.java @@ -19,8 +19,8 @@ public class TextParser { private String action; /** - * @param text is input from player * Separates incoming text into parts and passes them on to be parsed further + * @param text is input from player */ public void parseBattleText(String text) { textToParse = text; @@ -33,8 +33,8 @@ public class TextParser { } /** - * @param personText is name of battle person * Finds battle person based on text input and sets it as actor of action + * @param personText is name of battle person */ private void parseBattlePerson(String personText) { switch (personText) { @@ -51,8 +51,8 @@ public class TextParser { } /** - * @param action is name of action * Calls corresponding action to user input + * @param action is name of action */ private void parseBattleAction(String action) { this.action = action; @@ -87,8 +87,8 @@ public class TextParser { } /** - * @param targetText name of battle person * Finds battle person based on text input and sets it as target of action + * @param targetText name of battle person */ private void parseBattleTarget(String targetText) { switch (targetText) { diff --git a/src/main/java/ruscz/game/gameOfProd/Sounds/MusicManager.java b/src/main/java/ruscz/game/gameOfProd/Sounds/MusicManager.java index ba56d5b..2164d6e 100644 --- a/src/main/java/ruscz/game/gameOfProd/Sounds/MusicManager.java +++ b/src/main/java/ruscz/game/gameOfProd/Sounds/MusicManager.java @@ -63,8 +63,8 @@ public class MusicManager { } /** - * @param delay is timer delay in milliseconds * Fades music in (slowly raises volume to maxVolume) + * @param delay is timer delay in milliseconds */ public void fadeIn(int delay) { timerIn = new Timer(delay, actionEvent -> { @@ -77,8 +77,8 @@ public class MusicManager { } /** - * @param delay is timer delay in milliseconds * Fades music out (slowly lowers volume to 'zero') + * @param delay is timer delay in milliseconds */ public void fadeOut(int delay) { timerOut = new Timer(delay, actionEvent -> { diff --git a/src/main/java/ruscz/game/gameOfProd/Sounds/SoundManager.java b/src/main/java/ruscz/game/gameOfProd/Sounds/SoundManager.java index 8b44411..98d2fe5 100644 --- a/src/main/java/ruscz/game/gameOfProd/Sounds/SoundManager.java +++ b/src/main/java/ruscz/game/gameOfProd/Sounds/SoundManager.java @@ -23,8 +23,8 @@ public class SoundManager { } /** - * @param file is name of file * Parses sound map for different entities (currently only for doors) + * @param file is name of file */ public void loadSoundMap(String file) { try { @@ -50,9 +50,9 @@ public class SoundManager { } /** + * Plays sound once * @param name is sound name * @param volume is designated volume os float - * Plays sound once */ public void playSound(String name, float volume){ AudioInputStream audioIn; @@ -73,10 +73,10 @@ public class SoundManager { } /** + * Plays sound repeatedly after delay * @param name is sound name * @param delay is timer delay in milliseconds * @param volume is designated volume as float - * Plays sound repeatedly after delay */ public void playSoundRepeatedly(String name, int delay, float volume) { if (this.delay == delay) { diff --git a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java index d31d7e7..59da4d1 100644 --- a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java +++ b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java @@ -123,8 +123,8 @@ public class WindowOfBattle extends JPanel { } /** - * @param name is battle file name * Starts battle sequence - parses actors & other assets + * @param name is battle file name */ public void start(String name) { LinkedList heroes = new LinkedList<>(); @@ -196,8 +196,8 @@ public class WindowOfBattle extends JPanel { } /** - * @param s is text to be displayed * Displays text in situationText field + * @param s is text to be displayed */ public void writeToOutput(String s) { Font f = new Font(Font.SERIF, Font.BOLD, 20); @@ -212,9 +212,9 @@ public class WindowOfBattle extends JPanel { } /** + * Styles button * @param button is button to be styled * @return styled button - * Styles button */ public JButton style(JButton button) { Font f = new Font(Font.SERIF, Font.BOLD, 16); @@ -267,8 +267,8 @@ public class WindowOfBattle extends JPanel { private Timer timer; /** - * @param name is image name * Adds image into list of images to be displayed & sets it as the current image + * @param name is image name */ public void addImage(String name) { try { @@ -288,8 +288,8 @@ public class WindowOfBattle extends JPanel { } /** - * @param delay is timer delay in miliseconds * Selects random inmage from list of images to be displayed -creates flickering effect + * @param delay is timer delay in miliseconds */ public void flicker(int delay) { timer = new Timer(delay, actionEvent -> { diff --git a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java index 1e8be4f..842ce9d 100644 --- a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java +++ b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java @@ -27,6 +27,7 @@ public class WindowOfFreeMove extends JLayeredPane { public static int CANVAS_HEIGHT = 50; public static final int WINDOW_WIDTH = 13; public static final int WINDOW_HEIGHT = 13; + public static final int REPAINT_DELAY = 20; private static boolean canPersonMove; private static int nextMove; @@ -181,8 +182,8 @@ public class WindowOfFreeMove extends JLayeredPane { } /** - * @param newGame is a reference to main class Game * Starts the game itself - loads all needed maps, starts a new game or loads saved game and starts timer for repainting + * @param newGame is a reference to main class Game */ public void start(boolean newGame) { centerContent(); @@ -207,7 +208,7 @@ public class WindowOfFreeMove extends JLayeredPane { mapManager.createMap(); isReadyToPaint = true; - Timer timer = new Timer(20, actionEvent -> { + Timer timer = new Timer(REPAINT_DELAY, actionEvent -> { mapManager.getActualMap().getPerson().move(); camera.moveCamera(); canvas.repaint(); @@ -232,8 +233,8 @@ public class WindowOfFreeMove extends JLayeredPane { } /** - * @param name is name of battle file * Starts new battle sequence + * @param name is name of battle file */ public void startBattle(String name) { setVisible(false); @@ -291,9 +292,9 @@ public class WindowOfFreeMove extends JLayeredPane { } /** + * Checks if a cell is being shown in window and has to be repainted * @param cell is cell to be validated * @return is cell in view or near view - * Checks if a cell is being shown in window and has to be repainted */ private boolean isinView(Cell cell) { Boolean xValue = (CELL_SIZE * (cell.getX()+1) > -canvas.getLocation().x) && (CELL_SIZE * (cell.getX()-1) < (-canvas.getLocation().x + CELL_SIZE * WINDOW_WIDTH)); @@ -302,10 +303,10 @@ public class WindowOfFreeMove extends JLayeredPane { } /** + * Checks if a cell (referenced by X & Y) is being shown in window and has to be repainted * @param x is X value of a cell * @param y is Y value of a cell * @return is cell (referenced by X & Y) in view or near view - * Checks if a cell (referenced by X & Y) is being shown in window and has to be repainted */ private boolean isinView(int x, int y) { Boolean xValue = (CELL_SIZE * (x+1) > -canvas.getLocation().x) && (CELL_SIZE * (x-1) < (-canvas.getLocation().x + CELL_SIZE * WINDOW_WIDTH)); @@ -342,10 +343,10 @@ public class WindowOfFreeMove extends JLayeredPane { } /** + * Gradually changes alpha value of a displayed color * @param startAlpha is starting alpha value * @param endAlpha is ending alpha value * @param delay is delay for timer - * Gradually changes alpha value of a displayed color */ public void fade(int startAlpha, int endAlpha, int delay) { a = startAlpha; @@ -375,8 +376,8 @@ public class WindowOfFreeMove extends JLayeredPane { } /** - * @param tm is time in milliseconds * Pauses thread for a designated length of time + * @param tm is time in milliseconds */ public static void sleep(long tm) { try { diff --git a/src/main/resources/save/savedGame/events.txt b/src/main/resources/save/savedGame/events.txt index bffc5e3..86e28da 100644 --- a/src/main/resources/save/savedGame/events.txt +++ b/src/main/resources/save/savedGame/events.txt @@ -1,164 +1,15 @@ - tutorial + m1 + + + + + m6 11 - 6 + 11 false - - openspace - - - 6 - 4 - true - - - 14 - 16 - false - - - 1 - 2 - true - - - 15 - 7 - true - - - 8 - 4 - false - false - - - 2 - 6 - true - false - - - 6 - 6 - false - false - - - 16 - 10 - true - false - - - 8 - 13 - false - false - - - - - office - - - 4 - 2 - false - - - 1 - 9 - true - - - 12 - 1 - true - false - - - 17 - 1 - true - false - - - 7 - 12 - true - false - - - 12 - 12 - true - false - - - 4 - 1 - false - false - - - 2 - 12 - false - true - - - 17 - 12 - true - false - - - - - boss - - - 4 - 18 - true - - - 4 - 19 - false - false - - - - - treasure - - - 6 - 1 - true - - - - - storageroom - - - 6 - 2 - true - - - 6 - 1 - false - true - - - diff --git a/src/main/resources/save/savedGame/person.txt b/src/main/resources/save/savedGame/person.txt index ec0fcae..43cfc91 100644 --- a/src/main/resources/save/savedGame/person.txt +++ b/src/main/resources/save/savedGame/person.txt @@ -1,6 +1,6 @@ - storageroom - 6 - 2 - 0 + m1 + 3 + 7 + 2 \ No newline at end of file diff --git a/src/test/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMoveTest.java b/src/test/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMoveTest.java index 9faf8de..20009a6 100644 --- a/src/test/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMoveTest.java +++ b/src/test/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMoveTest.java @@ -78,7 +78,7 @@ public class WindowOfFreeMoveTest { //Act final int[] i = {0}; - timer = new Timer(10, actionEvent -> { + timer = new Timer(20, actionEvent -> { if (!person.getIsMoving()) { if (i[0] == directions.length) { stopTimer(); @@ -114,10 +114,11 @@ public class WindowOfFreeMoveTest { public void moveToMap_CharacterMovesToDifferentMap_CharacterIsOnCorrectMap() { //Arrange int[] directions = {KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN}; + freeMove.revalidate(); //Act final int[] i = {0}; - timer = new Timer(10, actionEvent -> { + timer = new Timer(WindowOfFreeMove.REPAINT_DELAY, actionEvent -> { if (!person.getIsMoving()) { if (i[0] == directions.length) { stopTimer(); @@ -141,7 +142,7 @@ public class WindowOfFreeMoveTest { //Act final boolean[] flag = {false}; - timer = new Timer(10, actionEvent -> { + timer = new Timer(WindowOfFreeMove.REPAINT_DELAY, actionEvent -> { if (!freeMove.getMapManager().getActualMap().getPerson().getIsMoving() && WindowOfFreeMove.canPersonMove()) { if (!flag[0]) { freeMove.getMapManager().getActualMap().getPerson().setDirectionMove(KEY_DOWN); @@ -169,10 +170,11 @@ public class WindowOfFreeMoveTest { public void startEvent_CharacterEntersEventThenGoesThroughEventThenExitsEvent_CorrectCharacterResponses() { //Arrange int[] directions = {KEY_UP, KEY_UP, KEY_UP, KEY_UP, KEY_UP, KEY_UP, KEY_UP, KEY_UP, KEY_UP, KEY_UP, KEY_UP, KEY_UP, KEY_UP}; + freeMove.revalidate(); //Act final int[] i = {0}; - timer = new Timer(10, actionEvent -> { + timer = new Timer(WindowOfFreeMove.REPAINT_DELAY, actionEvent -> { if (!person.getIsMoving()) { if (i[0] == directions.length) { stopTimer(); @@ -223,7 +225,7 @@ public class WindowOfFreeMoveTest { } final boolean[] flag = {false}; - timer = new Timer(10, actionEvent -> { + timer = new Timer(WindowOfFreeMove.REPAINT_DELAY, actionEvent -> { if (!person.getIsMoving()) { if (!flag[0]) { person.setDirectionMove(KEY_LEFT); @@ -252,6 +254,7 @@ public class WindowOfFreeMoveTest { public void saveGame_CharacterInteractsWithTriggerCellThenMovesToDifferentMapThenGameIsSaved_CorrectlySavedProgress() { //Assert SaveManager saveManager; + freeMove.revalidate(); //Act startEvent_CharacterEntersEventThenGoesThroughEventThenExitsEvent_CorrectCharacterResponses(); @@ -259,7 +262,7 @@ public class WindowOfFreeMoveTest { int[] directions = {KEY_RIGHT, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN}; final int[] i = {0}; - timer = new Timer(10, actionEvent -> { + timer = new Timer(WindowOfFreeMove.REPAINT_DELAY, actionEvent -> { if (!person.getIsMoving()) { if (i[0] == directions.length) { stopTimer(); @@ -279,7 +282,7 @@ public class WindowOfFreeMoveTest { moveToMap_CharacterMovesToDifferentMap_CharacterIsOnCorrectMap(); final boolean[] flag = {false}; - timer = new Timer(10, actionEvent -> { + timer = new Timer(WindowOfFreeMove.REPAINT_DELAY, actionEvent -> { if (!freeMove.getMapManager().getActualMap().getPerson().getIsMoving() && WindowOfFreeMove.canPersonMove()) { if (!flag[0]) { freeMove.getMapManager().getActualMap().getPerson().setDirectionMove(KEY_DOWN);