Dialog fix
This commit is contained in:
parent
3a2b14cee8
commit
22d6595797
@ -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;
|
||||
|
||||
@ -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("<html>"))
|
||||
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("<html>"))
|
||||
charNumber = 6;
|
||||
dialogBar.setVisible(true);
|
||||
dialogBar.repaint();
|
||||
while (charNumber <= text.length()) {
|
||||
if (voiceover)
|
||||
soundManager.playSound(voice + ".wav", -20.0f);
|
||||
|
||||
@ -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<Item> inventory = new LinkedList<Item>();
|
||||
private static LinkedList<Item> 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<Item> 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;
|
||||
|
||||
@ -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":
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
package ruscz.game.gameOfProd.Inventory;
|
||||
|
||||
/**
|
||||
* Enumerations for Item, describing what action provide
|
||||
*/
|
||||
public enum ItemAction {
|
||||
HEAL, MANA, DEFENCE, STRENGTH, KEY;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
12
src/main/resources/maps/custom/name-objectset.txt
Normal file
12
src/main/resources/maps/custom/name-objectset.txt
Normal file
@ -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
|
||||
21
src/main/resources/maps/custom/name-tileset.txt
Normal file
21
src/main/resources/maps/custom/name-tileset.txt
Normal file
@ -0,0 +1,21 @@
|
||||
<tileset> A2_Ground.png
|
||||
<tileset> A5_Tiles.png
|
||||
<cellmap> CHEST 0
|
||||
<cellmap> TRIGGER 0
|
||||
<cellmap> BLOCK 0
|
||||
<cellmap> MOVETO 0
|
||||
<cellmap> EVENT 0
|
||||
<cellmap> DOOR/DOORTO 0
|
||||
<soundmap> 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
|
||||
13
src/main/resources/maps/custom/name.txt
Normal file
13
src/main/resources/maps/custom/name.txt
Normal file
@ -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
|
||||
@ -14,7 +14,7 @@
|
||||
<trigger>
|
||||
<x>6</x>
|
||||
<y>4</y>
|
||||
<active>true</active>
|
||||
<active>false</active>
|
||||
</trigger>
|
||||
<trigger>
|
||||
<x>14</x>
|
||||
@ -24,7 +24,7 @@
|
||||
<chest>
|
||||
<x>1</x>
|
||||
<y>2</y>
|
||||
<active>true</active>
|
||||
<active>false</active>
|
||||
</chest>
|
||||
<chest>
|
||||
<x>15</x>
|
||||
@ -35,7 +35,7 @@
|
||||
<x>8</x>
|
||||
<y>4</y>
|
||||
<locked>false</locked>
|
||||
<open>false</open>
|
||||
<open>true</open>
|
||||
</dooŕ>
|
||||
<door>
|
||||
<x>2</x>
|
||||
@ -110,7 +110,7 @@
|
||||
<x>2</x>
|
||||
<y>12</y>
|
||||
<locked>false</locked>
|
||||
<open>false</open>
|
||||
<open>true</open>
|
||||
</dooŕ>
|
||||
<door>
|
||||
<x>17</x>
|
||||
@ -152,13 +152,13 @@
|
||||
<trigger>
|
||||
<x>6</x>
|
||||
<y>2</y>
|
||||
<active>true</active>
|
||||
<active>false</active>
|
||||
</trigger>
|
||||
<door>
|
||||
<x>6</x>
|
||||
<y>1</y>
|
||||
<locked>false</locked>
|
||||
<open>false</open>
|
||||
<open>true</open>
|
||||
</dooŕ>
|
||||
</events>
|
||||
</map>
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
<item>
|
||||
<name>cup-o'-coffee</name>
|
||||
<multiplicity>1</multiplicity>
|
||||
<image>295</image>
|
||||
<action>heal</action>
|
||||
</item>
|
||||
@ -1,6 +1,6 @@
|
||||
<location>
|
||||
<map>openspace</map>
|
||||
<x>8</x>
|
||||
<y>16</y>
|
||||
<y>15</y>
|
||||
<direction>3</direction>
|
||||
</location>
|
||||
Loading…
x
Reference in New Issue
Block a user