Clear up
This commit is contained in:
parent
f011048ed6
commit
2e028db9f0
@ -27,7 +27,11 @@ public class TriggerCell extends InteractionCell {
|
|||||||
getY() * WindowOfFreeMove.CELL_SIZE, WindowOfFreeMove.CELL_SIZE, WindowOfFreeMove.CELL_SIZE, null);
|
getY() * WindowOfFreeMove.CELL_SIZE, WindowOfFreeMove.CELL_SIZE, WindowOfFreeMove.CELL_SIZE, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getActive() { return isActive; }
|
public boolean getActive() {
|
||||||
|
return isActive;
|
||||||
public void setActive(boolean isActive) { this.isActive = isActive; }
|
}
|
||||||
|
|
||||||
|
public void setActive(boolean isActive) {
|
||||||
|
this.isActive = isActive;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,6 @@ import java.util.Scanner;
|
|||||||
public class ImageCell {
|
public class ImageCell {
|
||||||
private static BufferedImage image;
|
private static BufferedImage image;
|
||||||
private static LinkedList<BufferedImage> imagesOfTiles;
|
private static LinkedList<BufferedImage> imagesOfTiles;
|
||||||
private Scanner scanner;
|
|
||||||
private int[] mapBackground;
|
private int[] mapBackground;
|
||||||
|
|
||||||
public void readMapFile(String name) {
|
public void readMapFile(String name) {
|
||||||
@ -22,14 +21,13 @@ public class ImageCell {
|
|||||||
mapBackground = new int[WindowOfFreeMove.CANVAS_WIDTH * WindowOfFreeMove.CANVAS_HEIGHT];
|
mapBackground = new int[WindowOfFreeMove.CANVAS_WIDTH * WindowOfFreeMove.CANVAS_HEIGHT];
|
||||||
int count = 0;
|
int count = 0;
|
||||||
File mapFile = new File("src/main/resources/maps/" + name + ".txt");
|
File mapFile = new File("src/main/resources/maps/" + name + ".txt");
|
||||||
scanner = new Scanner(mapFile);
|
Scanner scanner = new Scanner(mapFile);
|
||||||
while (scanner.hasNextLine()) {
|
while (scanner.hasNextLine()) {
|
||||||
String data = scanner.nextLine();
|
String data = scanner.nextLine();
|
||||||
if (data.contains("<tileset>")) {
|
if (data.contains("<tileset>")) {
|
||||||
String[] mapInfo = data.split(" ");
|
String[] mapInfo = data.split(" ");
|
||||||
ImageTileset(mapInfo);
|
ImageTileset(mapInfo);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
String[] mapColumn = data.split(" ");
|
String[] mapColumn = data.split(" ");
|
||||||
for (int i = 0; i < mapColumn.length; i++) {
|
for (int i = 0; i < mapColumn.length; i++) {
|
||||||
mapBackground[count] = Integer.parseInt(mapColumn[i]);
|
mapBackground[count] = Integer.parseInt(mapColumn[i]);
|
||||||
|
|||||||
@ -23,8 +23,8 @@ public class Map {
|
|||||||
private boolean isBlocked;
|
private boolean isBlocked;
|
||||||
private int idExit;
|
private int idExit;
|
||||||
private ImageCell imageCell;
|
private ImageCell imageCell;
|
||||||
|
|
||||||
private static Scanner scanner;
|
private static Scanner scanner;
|
||||||
private static LinkedList<String[]> listOfMoveToCells;
|
|
||||||
|
|
||||||
public Map(int height, int width) {
|
public Map(int height, int width) {
|
||||||
name = "Spawn";
|
name = "Spawn";
|
||||||
@ -115,7 +115,7 @@ public class Map {
|
|||||||
Map map = new Map(mapArray);
|
Map map = new Map(mapArray);
|
||||||
map.setName(name);
|
map.setName(name);
|
||||||
map.getImageCell().readMapFile(name + "-tileset");
|
map.getImageCell().readMapFile(name + "-tileset");
|
||||||
listOfMoveToCells = new LinkedList<>();
|
LinkedList<String[]> listOfMoveToCells = new LinkedList<>();
|
||||||
int y = 0;
|
int y = 0;
|
||||||
while (scanner.hasNextLine()) {
|
while (scanner.hasNextLine()) {
|
||||||
loadMap(map, size, y, window);
|
loadMap(map, size, y, window);
|
||||||
@ -137,22 +137,18 @@ public class Map {
|
|||||||
cellType = TypeOfCell.BLOCK;
|
cellType = TypeOfCell.BLOCK;
|
||||||
map.getMapArray()[x][y] = cellType;
|
map.getMapArray()[x][y] = cellType;
|
||||||
map.getBlocks().add(new Block(x, y, map.getImageCell()));
|
map.getBlocks().add(new Block(x, y, map.getImageCell()));
|
||||||
}
|
} else if (line[x].equals("EMPTY")) {
|
||||||
else if (line[x].equals("EMPTY")) {
|
|
||||||
cellType = TypeOfCell.EMPTY;
|
cellType = TypeOfCell.EMPTY;
|
||||||
map.getMapArray()[x][y] = cellType;
|
map.getMapArray()[x][y] = cellType;
|
||||||
}
|
} else if (line[x].contains("INTER")) {
|
||||||
else if (line[x].contains("INTER")) {
|
|
||||||
ImageCell imageCell = new ImageCell();
|
ImageCell imageCell = new ImageCell();
|
||||||
String[] event = line[x].split(",");
|
String[] event = line[x].split(",");
|
||||||
map.addInteractionEvent(new InteractionCell(x, y, event[1], new Dialog(WindowOfFreeMove.getDialogBar()), map.getImageCell()));
|
map.addInteractionEvent(new InteractionCell(x, y, event[1], new Dialog(WindowOfFreeMove.getDialogBar()), map.getImageCell()));
|
||||||
}
|
} else if (line[x].contains("TRIGGER")) {
|
||||||
else if (line[x].contains("TRIGGER")) {
|
|
||||||
ImageCell imageCell = new ImageCell();
|
ImageCell imageCell = new ImageCell();
|
||||||
String[] trigger = line[x].split(",");
|
String[] trigger = line[x].split(",");
|
||||||
map.addInteractionEvent(new TriggerCell(x, y, trigger[1], new Dialog(WindowOfFreeMove.getDialogBar()), map.getImageCell()));
|
map.addInteractionEvent(new TriggerCell(x, y, trigger[1], new Dialog(WindowOfFreeMove.getDialogBar()), map.getImageCell()));
|
||||||
}
|
} else if (line[x].equals("SPAWN")) {
|
||||||
else if (line[x].equals("SPAWN")) {
|
|
||||||
map.setSpawnPoint(x, y);
|
map.setSpawnPoint(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,9 +230,13 @@ public class Map {
|
|||||||
mapArray[x][y] = TypeOfCell.SPAWNPOINT;
|
mapArray[x][y] = TypeOfCell.SPAWNPOINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageCell getImageCell() { return imageCell; }
|
public ImageCell getImageCell() {
|
||||||
|
return imageCell;
|
||||||
|
}
|
||||||
|
|
||||||
public TypeOfCell[][] getMapArray() { return mapArray; }
|
public TypeOfCell[][] getMapArray() {
|
||||||
|
return mapArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isBusyCell(int x, int y) {
|
public boolean isBusyCell(int x, int y) {
|
||||||
|
|||||||
@ -18,8 +18,7 @@ public class MapPainter {
|
|||||||
public void setMap(Map map) {
|
public void setMap(Map map) {
|
||||||
if (maps.contains(map)) {
|
if (maps.contains(map)) {
|
||||||
actualMap = map;
|
actualMap = map;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
maps.add(map);
|
maps.add(map);
|
||||||
actualMap = map;
|
actualMap = map;
|
||||||
}
|
}
|
||||||
@ -84,7 +83,4 @@ public class MapPainter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
package ruscz.game.gameOfProd.Windows;
|
package ruscz.game.gameOfProd.Windows;
|
||||||
|
|
||||||
import ruscz.game.gameOfProd.Cells.Cell;
|
import ruscz.game.gameOfProd.Cells.Cell;
|
||||||
import ruscz.game.gameOfProd.Cells.EventMoveToCell;
|
import ruscz.game.gameOfProd.Cells.EventMoveToCell;
|
||||||
import ruscz.game.gameOfProd.Cells.InteractionCell;
|
import ruscz.game.gameOfProd.Cells.InteractionCell;
|
||||||
@ -52,7 +53,8 @@ public class WindowOfFreeMove extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setMap(Map map) {
|
public void setMap(Map map) {
|
||||||
; this.
|
;
|
||||||
|
this.
|
||||||
map.
|
map.
|
||||||
setMap(map);
|
setMap(map);
|
||||||
}
|
}
|
||||||
@ -61,11 +63,17 @@ public class WindowOfFreeMove extends JFrame {
|
|||||||
this.map.createMap();
|
this.map.createMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setNextMove(int nextMove) { WindowOfFreeMove.nextMove = nextMove; }
|
public static void setNextMove(int nextMove) {
|
||||||
|
WindowOfFreeMove.nextMove = nextMove;
|
||||||
|
}
|
||||||
|
|
||||||
public static DialogBar getDialogBar() { return WindowOfFreeMove.dialogBar; }
|
public static DialogBar getDialogBar() {
|
||||||
|
return WindowOfFreeMove.dialogBar;
|
||||||
|
}
|
||||||
|
|
||||||
public static LinkedList<Map> getMapLinkedList() { return mapLinkedList; }
|
public static LinkedList<Map> getMapLinkedList() {
|
||||||
|
return mapLinkedList;
|
||||||
|
}
|
||||||
|
|
||||||
public WindowOfFreeMove() {
|
public WindowOfFreeMove() {
|
||||||
isReadyToPaint = false;
|
isReadyToPaint = false;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
0 0 83 95 0 0 83 95 0 0
|
0 0 83 95 0 0 83 95 0 0
|
||||||
0 0 0 0 0 0 0 0 0 0
|
0 0 0 0 0 0 0 0 0 0
|
||||||
0 0 153 0 0 0 0 153 0 0
|
0 0 153 0 0 0 0 153 0 0
|
||||||
0 0 0 153 153 153 153 0 0 0
|
0 0 153 153 153 153 153 0 0 0
|
||||||
0 0 0 0 0 0 0 0 0 0
|
0 0 0 0 0 0 0 0 0 0
|
||||||
0 0 0 0 0 0 0 0 0 0
|
0 0 0 0 0 0 0 0 0 0
|
||||||
0 0 0 0 0 0 0 0 0 0
|
0 0 0 0 0 0 0 0 0 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user