Javadoc
This commit is contained in:
parent
22d6595797
commit
490f607986
@ -12,35 +12,27 @@ import java.util.Collections;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for Battle with graphic implementation
|
||||||
|
*/
|
||||||
public class Battle {
|
public class Battle {
|
||||||
private final LinkedList<Enemy> enemies;
|
private final LinkedList<Enemy> enemies;
|
||||||
private final LinkedList<Hero> heroes;
|
private final LinkedList<Hero> heroes;
|
||||||
private final WindowOfBattle windowOfBattle;
|
private final WindowOfBattle windowOfBattle;
|
||||||
private Timer timer;
|
private Timer timer;
|
||||||
|
|
||||||
private final SoundManager soundManager;
|
private final SoundManager soundManager;
|
||||||
|
|
||||||
private BattlePerson turnBelongTo;
|
private BattlePerson turnBelongTo;
|
||||||
|
|
||||||
private LinkedList<BattlePerson> turnOrder;
|
private LinkedList<BattlePerson> turnOrder;
|
||||||
|
|
||||||
private int turnCount;
|
|
||||||
private int delay;
|
private int delay;
|
||||||
|
|
||||||
private boolean playerAttack;
|
private boolean playerAttack;
|
||||||
|
|
||||||
public void setDelay(int delay) { this.delay = delay; }
|
|
||||||
|
|
||||||
public boolean isTimerStopped() {
|
|
||||||
return timerStopped;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTimerStopped(boolean timerStopped) {
|
|
||||||
this.timerStopped = timerStopped;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean timerStopped;
|
private boolean timerStopped;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide Menu and Enemy Description
|
||||||
|
* Set Attack of Player
|
||||||
|
* @param playerAttack
|
||||||
|
*/
|
||||||
public void setPlayerAttack(boolean playerAttack) {
|
public void setPlayerAttack(boolean playerAttack) {
|
||||||
windowOfBattle.getMenuOfActions().setVisible(false);
|
windowOfBattle.getMenuOfActions().setVisible(false);
|
||||||
windowOfBattle.getEnemyDescription().setVisible(false);
|
windowOfBattle.getEnemyDescription().setVisible(false);
|
||||||
@ -67,14 +59,25 @@ public class Battle {
|
|||||||
return heroes;
|
return heroes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks, if all enemies dies
|
||||||
|
* @return true if all dies
|
||||||
|
*/
|
||||||
public boolean checkHealthOfEnemies(){
|
public boolean checkHealthOfEnemies(){
|
||||||
return enemies.isEmpty();
|
return enemies.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks, if all heroes dies
|
||||||
|
* @return true if all dies
|
||||||
|
*/
|
||||||
public boolean checkHealthOfHeroes(){
|
public boolean checkHealthOfHeroes(){
|
||||||
return heroes.isEmpty();
|
return heroes.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start fight by showing menu and creating Timer of battle
|
||||||
|
*/
|
||||||
public void startBattle() {
|
public void startBattle() {
|
||||||
turnBelongTo = heroes.getFirst();
|
turnBelongTo = heroes.getFirst();
|
||||||
windowOfBattle.getMenuOfActions().setVisible(true);
|
windowOfBattle.getMenuOfActions().setVisible(true);
|
||||||
@ -98,6 +101,10 @@ public class Battle {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* End battle and start cutscene of win or lose
|
||||||
|
* @param b true if win, false if lose
|
||||||
|
*/
|
||||||
public void endBattle(boolean b) {
|
public void endBattle(boolean b) {
|
||||||
timer.stop();
|
timer.stop();
|
||||||
timerStopped = true;
|
timerStopped = true;
|
||||||
@ -124,6 +131,9 @@ public class Battle {
|
|||||||
// saveManager.saveGame();
|
// saveManager.saveGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show all Menus and Enemy Description
|
||||||
|
*/
|
||||||
private void returnControlToPlayer(){
|
private void returnControlToPlayer(){
|
||||||
timer.stop();
|
timer.stop();
|
||||||
timerStopped = true;
|
timerStopped = true;
|
||||||
@ -133,8 +143,12 @@ public class Battle {
|
|||||||
windowOfBattle.getSituationText().hideText();
|
windowOfBattle.getSituationText().hideText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attack with animation and logic
|
||||||
|
* Do delay of 2 seconds
|
||||||
|
* @param e Enemy to attack
|
||||||
|
*/
|
||||||
private void attackByHero(Enemy e) {
|
private void attackByHero(Enemy e) {
|
||||||
turnCount++;
|
|
||||||
windowOfBattle.repaint();
|
windowOfBattle.repaint();
|
||||||
turnBelongTo.attack(e);
|
turnBelongTo.attack(e);
|
||||||
turnBelongTo.setImageEffect("attack");
|
turnBelongTo.setImageEffect("attack");
|
||||||
@ -151,6 +165,9 @@ public class Battle {
|
|||||||
delay = 2;
|
delay = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function, which decide who will attack next
|
||||||
|
*/
|
||||||
private void nextTurn() {
|
private void nextTurn() {
|
||||||
windowOfBattle.getMenuOfActions().setVisible(false);
|
windowOfBattle.getMenuOfActions().setVisible(false);
|
||||||
windowOfBattle.getEnemyDescription().setVisible(false);
|
windowOfBattle.getEnemyDescription().setVisible(false);
|
||||||
@ -174,8 +191,12 @@ public class Battle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attack with animation and logic
|
||||||
|
* Do delay of 2 seconds
|
||||||
|
* @param e Hero to attack
|
||||||
|
*/
|
||||||
private void attackByMonster(Hero e) {
|
private void attackByMonster(Hero e) {
|
||||||
turnCount++;
|
|
||||||
turnBelongTo.attack(e);
|
turnBelongTo.attack(e);
|
||||||
turnBelongTo.setImageEffect("attack");
|
turnBelongTo.setImageEffect("attack");
|
||||||
if (windowOfBattle.getHitSound() != null) soundManager.playSound(windowOfBattle.getHitSound(), -10.0f);
|
if (windowOfBattle.getHitSound() != null) soundManager.playSound(windowOfBattle.getHitSound(), -10.0f);
|
||||||
@ -191,12 +212,20 @@ public class Battle {
|
|||||||
turnBelongTo = null;
|
turnBelongTo = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Random enemy from list
|
||||||
|
* @return Random enemy
|
||||||
|
*/
|
||||||
private Enemy randomEnemy(){
|
private Enemy randomEnemy(){
|
||||||
LinkedList list = getEnemies();
|
LinkedList list = getEnemies();
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
return (Enemy) list.get(rand.nextInt(list.size()));
|
return (Enemy) list.get(rand.nextInt(list.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Random hero from list
|
||||||
|
* @return Random hero
|
||||||
|
*/
|
||||||
private Hero randomHero(){
|
private Hero randomHero(){
|
||||||
LinkedList list = getHeroes();
|
LinkedList list = getHeroes();
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
@ -218,8 +247,23 @@ public class Battle {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove person from one of the list, if died
|
||||||
|
* @param person Person to delete
|
||||||
|
*/
|
||||||
public void removePersonFromList(BattlePerson person) {
|
public void removePersonFromList(BattlePerson person) {
|
||||||
if (person.getClass().getName().equals("ruscz.game.gameOfProd.Battle.Hero")) heroes.remove(person);
|
if (person.getClass().getName().equals("ruscz.game.gameOfProd.Battle.Hero")) heroes.remove(person);
|
||||||
else enemies.remove(person);
|
else enemies.remove(person);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDelay(int delay) { this.delay = delay; }
|
||||||
|
|
||||||
|
public boolean isTimerStopped() {
|
||||||
|
return timerStopped;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimerStopped(boolean timerStopped) {
|
||||||
|
this.timerStopped = timerStopped;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
package ruscz.game.gameOfProd.Battle;
|
package ruscz.game.gameOfProd.Battle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enemy class for battle
|
||||||
|
*/
|
||||||
public class Enemy extends BattlePerson {
|
public class Enemy extends BattlePerson {
|
||||||
private int id;
|
private final int id;
|
||||||
|
|
||||||
public Enemy(int hp, int lvl, String name, int str, int id, String image) {
|
public Enemy(int hp, int lvl, String name, int str, int id, String image) {
|
||||||
super(hp, lvl, name, str, image);
|
super(hp, lvl, name, str, image);
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
package ruscz.game.gameOfProd.Battle;
|
package ruscz.game.gameOfProd.Battle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hero class for Battle
|
||||||
|
*/
|
||||||
public class Hero extends BattlePerson {
|
public class Hero extends BattlePerson {
|
||||||
private int mana;
|
private int mana;
|
||||||
private int defence;
|
private int defence;
|
||||||
|
|||||||
@ -8,6 +8,10 @@ import java.awt.*;
|
|||||||
|
|
||||||
import static ruscz.game.gameOfProd.Windows.WindowOfBattle.CELL_SIZE;
|
import static ruscz.game.gameOfProd.Windows.WindowOfBattle.CELL_SIZE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JPanel with commands to game command line
|
||||||
|
* Used, but because of Text Parser doesn't have any of commands
|
||||||
|
*/
|
||||||
public class CommandList extends JPanel {
|
public class CommandList extends JPanel {
|
||||||
public CommandList(WindowOfBattle window){
|
public CommandList(WindowOfBattle window){
|
||||||
setSize(CELL_SIZE * 8, CELL_SIZE * 6);
|
setSize(CELL_SIZE * 8, CELL_SIZE * 6);
|
||||||
|
|||||||
@ -8,6 +8,10 @@ import java.awt.*;
|
|||||||
|
|
||||||
import static ruscz.game.gameOfProd.Windows.WindowOfBattle.*;
|
import static ruscz.game.gameOfProd.Windows.WindowOfBattle.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JPanel with command line
|
||||||
|
* Used, but because of Text Parser doesn't work
|
||||||
|
*/
|
||||||
public class ConsoleInput extends JPanel {
|
public class ConsoleInput extends JPanel {
|
||||||
private final JTextPane input;
|
private final JTextPane input;
|
||||||
private final JButton submit;
|
private final JButton submit;
|
||||||
|
|||||||
@ -9,6 +9,9 @@ import java.util.LinkedList;
|
|||||||
|
|
||||||
import static ruscz.game.gameOfProd.Windows.WindowOfBattle.*;
|
import static ruscz.game.gameOfProd.Windows.WindowOfBattle.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JPanel with info about Enemies and Heroes
|
||||||
|
*/
|
||||||
public class EnemyDescription extends JPanel {
|
public class EnemyDescription extends JPanel {
|
||||||
|
|
||||||
private final WindowOfBattle windowOfBattle;
|
private final WindowOfBattle windowOfBattle;
|
||||||
@ -23,6 +26,9 @@ public class EnemyDescription extends JPanel {
|
|||||||
setVisible(false);
|
setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates info about all persons in battle
|
||||||
|
*/
|
||||||
public void updateDescription() {
|
public void updateDescription() {
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
deletePreviousDescription();
|
deletePreviousDescription();
|
||||||
@ -31,6 +37,9 @@ public class EnemyDescription extends JPanel {
|
|||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add all Components to JPanel (Description of Person: name, level, health)
|
||||||
|
*/
|
||||||
private void addNewDescription() {
|
private void addNewDescription() {
|
||||||
if (getComponentCount() != 0) return;
|
if (getComponentCount() != 0) return;
|
||||||
if (windowOfBattle.getBattle() == null) return;
|
if (windowOfBattle.getBattle() == null) return;
|
||||||
@ -60,6 +69,9 @@ public class EnemyDescription extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all Components from JPanel
|
||||||
|
*/
|
||||||
private void deletePreviousDescription() {
|
private void deletePreviousDescription() {
|
||||||
if (getComponentCount() == 0) return;
|
if (getComponentCount() == 0) return;
|
||||||
for (Component c: getComponents())
|
for (Component c: getComponents())
|
||||||
|
|||||||
@ -12,6 +12,9 @@ import java.awt.*;
|
|||||||
|
|
||||||
import static ruscz.game.gameOfProd.Windows.WindowOfBattle.CELL_SIZE;
|
import static ruscz.game.gameOfProd.Windows.WindowOfBattle.CELL_SIZE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JPanel with Inventory
|
||||||
|
*/
|
||||||
public class ItemsInventory extends JPanel {
|
public class ItemsInventory extends JPanel {
|
||||||
private final JPanel items;
|
private final JPanel items;
|
||||||
private final ImageCell imageCell;
|
private final ImageCell imageCell;
|
||||||
@ -43,6 +46,10 @@ public class ItemsInventory extends JPanel {
|
|||||||
add(returnToMenu);
|
add(returnToMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh all Items by deleting all previous info and adding new (Description of Item: image, name, multiplicity and action of that)
|
||||||
|
* Have enabled or disabled button Use
|
||||||
|
*/
|
||||||
public void refreshItemsInField() {
|
public void refreshItemsInField() {
|
||||||
for (Component c: items.getComponents())
|
for (Component c: items.getComponents())
|
||||||
items.remove(c);
|
items.remove(c);
|
||||||
|
|||||||
@ -8,6 +8,9 @@ import java.util.Random;
|
|||||||
|
|
||||||
import static ruscz.game.gameOfProd.Windows.WindowOfBattle.*;
|
import static ruscz.game.gameOfProd.Windows.WindowOfBattle.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JPanel with menu of Action, that User can do
|
||||||
|
*/
|
||||||
public class MenuOfActions extends JPanel {
|
public class MenuOfActions extends JPanel {
|
||||||
private final JButton attack;
|
private final JButton attack;
|
||||||
private final JButton console;
|
private final JButton console;
|
||||||
|
|||||||
@ -7,6 +7,9 @@ import java.awt.*;
|
|||||||
|
|
||||||
import static ruscz.game.gameOfProd.Windows.WindowOfBattle.*;
|
import static ruscz.game.gameOfProd.Windows.WindowOfBattle.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JPanel with text, describing fight
|
||||||
|
*/
|
||||||
public class SituationText extends JPanel {
|
public class SituationText extends JPanel {
|
||||||
public SituationText(WindowOfBattle window) {
|
public SituationText(WindowOfBattle window) {
|
||||||
setSize(CELL_SIZE * CANVAS_WIDTH, CELL_SIZE * CANVAS_HEIGHT / 4);
|
setSize(CELL_SIZE * CANVAS_WIDTH, CELL_SIZE * CANVAS_HEIGHT / 4);
|
||||||
@ -15,6 +18,9 @@ public class SituationText extends JPanel {
|
|||||||
setBorder(BorderFactory.createLineBorder(new Color(213, 108, 18), 2));
|
setBorder(BorderFactory.createLineBorder(new Color(213, 108, 18), 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide text from JPanel (Just deleting them)
|
||||||
|
*/
|
||||||
public void hideText() {
|
public void hideText() {
|
||||||
JLabel label = (JLabel) getComponent(0);
|
JLabel label = (JLabel) getComponent(0);
|
||||||
label.setText("");
|
label.setText("");
|
||||||
|
|||||||
@ -7,10 +7,13 @@ import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cell with collision to Player
|
||||||
|
*/
|
||||||
public class Block extends Cell {
|
public class Block extends Cell {
|
||||||
private ImageCell imageCell;
|
private final ImageCell imageCell;
|
||||||
private boolean paint;
|
private final boolean paint;
|
||||||
private String partial;
|
private final String partial;
|
||||||
|
|
||||||
public Block(int x, int y, Map map, boolean paint) {
|
public Block(int x, int y, Map map, boolean paint) {
|
||||||
super(x, y, WindowOfFreeMove.CELL_SIZE, Color.BLUE);
|
super(x, y, WindowOfFreeMove.CELL_SIZE, Color.BLUE);
|
||||||
@ -26,10 +29,17 @@ public class Block extends Cell {
|
|||||||
this.paint = paint;
|
this.paint = paint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if this Block in this position
|
||||||
|
* @param x X position
|
||||||
|
* @param y Y position
|
||||||
|
* @return true if Block is in this position
|
||||||
|
*/
|
||||||
public boolean isInBlock(int x, int y) {
|
public boolean isInBlock(int x, int y) {
|
||||||
return (this.getX() == x) && (this.getY() == y);
|
return (this.getX() == x) && (this.getY() == y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isInBlock(int x, int y, boolean half) {
|
public boolean isInBlock(int x, int y, boolean half) {
|
||||||
return (this.getX() == x) && (this.getY() == y) && !(partial.equals("d"));
|
return (this.getX() == x) && (this.getY() == y) && !(partial.equals("d"));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,9 +2,12 @@ package ruscz.game.gameOfProd.Cells;
|
|||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* General class for Cell
|
||||||
|
*/
|
||||||
public class Cell {
|
public class Cell {
|
||||||
private int x, y;
|
private int x, y;
|
||||||
private int size;
|
private final int size;
|
||||||
private Color color;
|
private Color color;
|
||||||
|
|
||||||
public Cell(int x, int y, int size, Color color) {
|
public Cell(int x, int y, int size, Color color) {
|
||||||
@ -13,6 +16,11 @@ public class Cell {
|
|||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set position of Cell
|
||||||
|
* @param x X position
|
||||||
|
* @param y Y position
|
||||||
|
*/
|
||||||
public void set(int x, int y) {
|
public void set(int x, int y) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import java.util.LinkedList;
|
|||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class ChestCell extends InteractionCell {
|
public class ChestCell extends InteractionCell {
|
||||||
private LinkedList<Item> chestInventory;
|
private final LinkedList<Item> chestInventory;
|
||||||
private boolean showItem;
|
private boolean showItem;
|
||||||
private boolean isActive;
|
private boolean isActive;
|
||||||
|
|
||||||
|
|||||||
@ -10,11 +10,8 @@ import java.awt.*;
|
|||||||
public class DoorCell extends InteractionCell {
|
public class DoorCell extends InteractionCell {
|
||||||
private boolean isOpen;
|
private boolean isOpen;
|
||||||
private boolean isLocked;
|
private boolean isLocked;
|
||||||
private boolean directionVert;
|
private final boolean directionVert;
|
||||||
private String sound;
|
private String sound;
|
||||||
private String soundOpen;
|
|
||||||
private String soundClose;
|
|
||||||
private String soundLocked;
|
|
||||||
private float volume;
|
private float volume;
|
||||||
|
|
||||||
public DoorCell(int x, int y, boolean directionVert, String message, Dialog dialog, Map map, WindowOfFreeMove window) {
|
public DoorCell(int x, int y, boolean directionVert, String message, Dialog dialog, Map map, WindowOfFreeMove window) {
|
||||||
|
|||||||
@ -6,11 +6,11 @@ import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class EventMoveToCell extends Cell {
|
public class EventMoveToCell extends Cell {
|
||||||
private Map map;
|
private final Map map;
|
||||||
private WindowOfFreeMove window;
|
private final WindowOfFreeMove window;
|
||||||
private int id;
|
private final int id;
|
||||||
private int directionOut;
|
private final int directionOut;
|
||||||
private boolean paint;
|
private final boolean paint;
|
||||||
|
|
||||||
public int getId(){
|
public int getId(){
|
||||||
return id;
|
return id;
|
||||||
@ -36,7 +36,7 @@ public class EventMoveToCell extends Cell {
|
|||||||
window.paintMapOnWindow();
|
window.paintMapOnWindow();
|
||||||
window.repaintCanvas();
|
window.repaintCanvas();
|
||||||
if (!isActiveTriggerBehindMoveTo())
|
if (!isActiveTriggerBehindMoveTo())
|
||||||
window.setCanPersonMove(true);
|
WindowOfFreeMove.setCanPersonMove(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isActiveTriggerBehindMoveTo() {
|
private boolean isActiveTriggerBehindMoveTo() {
|
||||||
|
|||||||
@ -19,11 +19,11 @@ import java.util.Scanner;
|
|||||||
|
|
||||||
public class InteractionCell extends Cell {
|
public class InteractionCell extends Cell {
|
||||||
protected String message;
|
protected String message;
|
||||||
protected ruscz.game.gameOfProd.Dialog.Dialog dialog;
|
protected Dialog dialog;
|
||||||
protected Scanner scanner;
|
protected Scanner scanner;
|
||||||
private ImageCell imageCell;
|
private final ImageCell imageCell;
|
||||||
private SoundManager soundManager;
|
private final SoundManager soundManager;
|
||||||
private WindowOfFreeMove window;
|
private final WindowOfFreeMove window;
|
||||||
protected boolean paint;
|
protected boolean paint;
|
||||||
private Timer timer;
|
private Timer timer;
|
||||||
private Timer textTimer;
|
private Timer textTimer;
|
||||||
@ -50,7 +50,7 @@ public class InteractionCell extends Cell {
|
|||||||
readDialogFile("empty");
|
readDialogFile("empty");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
window.setCanPersonMove(false);
|
WindowOfFreeMove.setCanPersonMove(false);
|
||||||
readDialogFile(message);
|
readDialogFile(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,10 +7,9 @@ import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class Person extends Cell {
|
public class Person extends Cell {
|
||||||
|
|
||||||
private final int WALKING_SPEED = 3;
|
private final int WALKING_SPEED = 3;
|
||||||
|
|
||||||
private Map map;
|
private final Map map;
|
||||||
private ImagePerson imagePerson;
|
private ImagePerson imagePerson;
|
||||||
private int directionMove;
|
private int directionMove;
|
||||||
private int directionSight;
|
private int directionSight;
|
||||||
|
|||||||
@ -1,17 +0,0 @@
|
|||||||
package ruscz.game.gameOfProd.Cells;
|
|
||||||
|
|
||||||
import ruscz.game.gameOfProd.Game;
|
|
||||||
import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public class RandomEncounterCell extends Cell {
|
|
||||||
private final int level;
|
|
||||||
private final Game game;
|
|
||||||
|
|
||||||
public RandomEncounterCell(int x, int y, int lvl, Game game) {
|
|
||||||
super(x, y, WindowOfFreeMove.CELL_SIZE, Color.pink);
|
|
||||||
this.level = lvl;
|
|
||||||
this.game = game;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -7,15 +7,18 @@ import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for showing text on Dialog Bar
|
||||||
|
*/
|
||||||
public class Dialog {
|
public class Dialog {
|
||||||
private String text;
|
private String text;
|
||||||
private int textLength;
|
private int textLength;
|
||||||
private ImageDialog imageDialog;
|
private ImageDialog imageDialog;
|
||||||
private Timer timer;
|
private Timer timer;
|
||||||
private DialogBar dialogBar;
|
private final DialogBar dialogBar;
|
||||||
private int charNumber;
|
private int charNumber;
|
||||||
private boolean timerIsRunning;
|
private boolean timerIsRunning;
|
||||||
private SoundManager soundManager;
|
private final SoundManager soundManager;
|
||||||
private String voice;
|
private String voice;
|
||||||
private boolean voiceover;
|
private boolean voiceover;
|
||||||
|
|
||||||
@ -27,7 +30,11 @@ public class Dialog {
|
|||||||
voiceover = true;
|
voiceover = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes String of Text and prepare JLabel with all settings needed
|
||||||
|
* @param string Text to show
|
||||||
|
* @return JLabel with text
|
||||||
|
*/
|
||||||
public JLabel prepareDialogBar(String string) {
|
public JLabel prepareDialogBar(String string) {
|
||||||
int cellSize = WindowOfFreeMove.CELL_SIZE;
|
int cellSize = WindowOfFreeMove.CELL_SIZE;
|
||||||
Font f1 = new Font("Times New Roman", Font.PLAIN, cellSize / 2);
|
Font f1 = new Font("Times New Roman", Font.PLAIN, cellSize / 2);
|
||||||
@ -51,6 +58,10 @@ public class Dialog {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function, that add next symbol from text to DialogBar
|
||||||
|
* Stop timer of adding symbols, if full text is showed
|
||||||
|
*/
|
||||||
private void showByChar() {
|
private void showByChar() {
|
||||||
if (charNumber >= textLength)
|
if (charNumber >= textLength)
|
||||||
return;
|
return;
|
||||||
@ -66,6 +77,9 @@ public class Dialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Showing DialogBar with animation of adding symbol
|
||||||
|
*/
|
||||||
public void showText() {
|
public void showText() {
|
||||||
charNumber = 0;
|
charNumber = 0;
|
||||||
if (text.contains("<html>"))
|
if (text.contains("<html>"))
|
||||||
@ -81,6 +95,9 @@ public class Dialog {
|
|||||||
timer.start();
|
timer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Showing block of text with fast changing of text (while, not Timer)
|
||||||
|
*/
|
||||||
public void showFastText() {
|
public void showFastText() {
|
||||||
charNumber = 0;
|
charNumber = 0;
|
||||||
if (text.contains("<html>"))
|
if (text.contains("<html>"))
|
||||||
@ -96,6 +113,9 @@ public class Dialog {
|
|||||||
timerIsRunning = false;
|
timerIsRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skip for animation of symbols
|
||||||
|
*/
|
||||||
public void skipShowText() {
|
public void skipShowText() {
|
||||||
timer.stop();
|
timer.stop();
|
||||||
timerIsRunning = false;
|
timerIsRunning = false;
|
||||||
@ -105,6 +125,9 @@ public class Dialog {
|
|||||||
dialogBar.repaint();
|
dialogBar.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide text from Dialog Bar
|
||||||
|
*/
|
||||||
public void hideText() {
|
public void hideText() {
|
||||||
dialogBar.setVisible(false);
|
dialogBar.setVisible(false);
|
||||||
dialogBar.unsetImageDialog();
|
dialogBar.unsetImageDialog();
|
||||||
|
|||||||
@ -6,6 +6,9 @@ import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Graphical interpretation for Dialog, used to show text
|
||||||
|
*/
|
||||||
public class DialogBar extends JPanel {
|
public class DialogBar extends JPanel {
|
||||||
private ImageDialog imageDialog;
|
private ImageDialog imageDialog;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +0,0 @@
|
|||||||
package ruscz.game.gameOfProd.Dialog;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
public class MenuBar extends JPanel {
|
|
||||||
}
|
|
||||||
@ -22,7 +22,7 @@ import java.util.LinkedList;
|
|||||||
* It also holds references to all major classes
|
* It also holds references to all major classes
|
||||||
*/
|
*/
|
||||||
public class WindowOfFreeMove extends JLayeredPane {
|
public class WindowOfFreeMove extends JLayeredPane {
|
||||||
public static final int CELL_SIZE = 69;
|
public static final int CELL_SIZE = 70;
|
||||||
public static int CANVAS_WIDTH = 50;
|
public static int CANVAS_WIDTH = 50;
|
||||||
public static int CANVAS_HEIGHT = 50;
|
public static int CANVAS_HEIGHT = 50;
|
||||||
public static final int WINDOW_WIDTH = 13;
|
public static final int WINDOW_WIDTH = 13;
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
<trigger>
|
<trigger>
|
||||||
<x>6</x>
|
<x>6</x>
|
||||||
<y>4</y>
|
<y>4</y>
|
||||||
<active>false</active>
|
<active>true</active>
|
||||||
</trigger>
|
</trigger>
|
||||||
<trigger>
|
<trigger>
|
||||||
<x>14</x>
|
<x>14</x>
|
||||||
@ -24,7 +24,7 @@
|
|||||||
<chest>
|
<chest>
|
||||||
<x>1</x>
|
<x>1</x>
|
||||||
<y>2</y>
|
<y>2</y>
|
||||||
<active>false</active>
|
<active>true</active>
|
||||||
</chest>
|
</chest>
|
||||||
<chest>
|
<chest>
|
||||||
<x>15</x>
|
<x>15</x>
|
||||||
@ -35,7 +35,7 @@
|
|||||||
<x>8</x>
|
<x>8</x>
|
||||||
<y>4</y>
|
<y>4</y>
|
||||||
<locked>false</locked>
|
<locked>false</locked>
|
||||||
<open>true</open>
|
<open>false</open>
|
||||||
</dooŕ>
|
</dooŕ>
|
||||||
<door>
|
<door>
|
||||||
<x>2</x>
|
<x>2</x>
|
||||||
@ -152,7 +152,7 @@
|
|||||||
<trigger>
|
<trigger>
|
||||||
<x>6</x>
|
<x>6</x>
|
||||||
<y>2</y>
|
<y>2</y>
|
||||||
<active>false</active>
|
<active>true</active>
|
||||||
</trigger>
|
</trigger>
|
||||||
<door>
|
<door>
|
||||||
<x>6</x>
|
<x>6</x>
|
||||||
|
|||||||
@ -1,6 +0,0 @@
|
|||||||
<item>
|
|
||||||
<name>cup-o'-coffee</name>
|
|
||||||
<multiplicity>1</multiplicity>
|
|
||||||
<image>295</image>
|
|
||||||
<action>heal</action>
|
|
||||||
</item>
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<location>
|
<location>
|
||||||
<map>openspace</map>
|
<map>storageroom</map>
|
||||||
<x>8</x>
|
<x>6</x>
|
||||||
<y>15</y>
|
<y>2</y>
|
||||||
<direction>3</direction>
|
<direction>0</direction>
|
||||||
</location>
|
</location>
|
||||||
Loading…
x
Reference in New Issue
Block a user