This commit is contained in:
iryupnik 2020-03-15 11:15:53 +01:00
parent f011048ed6
commit 2e028db9f0
6 changed files with 48 additions and 42 deletions

View File

@ -27,7 +27,11 @@ public class TriggerCell extends InteractionCell {
getY() * WindowOfFreeMove.CELL_SIZE, WindowOfFreeMove.CELL_SIZE, WindowOfFreeMove.CELL_SIZE, null);
}
public boolean getActive() { return isActive; }
public void setActive(boolean isActive) { this.isActive = isActive; }
public boolean getActive() {
return isActive;
}
public void setActive(boolean isActive) {
this.isActive = isActive;
}
}

View File

@ -14,7 +14,6 @@ import java.util.Scanner;
public class ImageCell {
private static BufferedImage image;
private static LinkedList<BufferedImage> imagesOfTiles;
private Scanner scanner;
private int[] mapBackground;
public void readMapFile(String name) {
@ -22,14 +21,13 @@ public class ImageCell {
mapBackground = new int[WindowOfFreeMove.CANVAS_WIDTH * WindowOfFreeMove.CANVAS_HEIGHT];
int count = 0;
File mapFile = new File("src/main/resources/maps/" + name + ".txt");
scanner = new Scanner(mapFile);
Scanner scanner = new Scanner(mapFile);
while (scanner.hasNextLine()) {
String data = scanner.nextLine();
if (data.contains("<tileset>")) {
String[] mapInfo = data.split(" ");
ImageTileset(mapInfo);
}
else {
} else {
String[] mapColumn = data.split(" ");
for (int i = 0; i < mapColumn.length; i++) {
mapBackground[count] = Integer.parseInt(mapColumn[i]);

View File

@ -23,8 +23,8 @@ public class Map {
private boolean isBlocked;
private int idExit;
private ImageCell imageCell;
private static Scanner scanner;
private static LinkedList<String[]> listOfMoveToCells;
public Map(int height, int width) {
name = "Spawn";
@ -115,7 +115,7 @@ public class Map {
Map map = new Map(mapArray);
map.setName(name);
map.getImageCell().readMapFile(name + "-tileset");
listOfMoveToCells = new LinkedList<>();
LinkedList<String[]> listOfMoveToCells = new LinkedList<>();
int y = 0;
while (scanner.hasNextLine()) {
loadMap(map, size, y, window);
@ -137,22 +137,18 @@ public class Map {
cellType = TypeOfCell.BLOCK;
map.getMapArray()[x][y] = cellType;
map.getBlocks().add(new Block(x, y, map.getImageCell()));
}
else if (line[x].equals("EMPTY")) {
} else if (line[x].equals("EMPTY")) {
cellType = TypeOfCell.EMPTY;
map.getMapArray()[x][y] = cellType;
}
else if (line[x].contains("INTER")) {
} else if (line[x].contains("INTER")) {
ImageCell imageCell = new ImageCell();
String[] event = line[x].split(",");
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();
String[] trigger = line[x].split(",");
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);
}
}
@ -234,9 +230,13 @@ public class Map {
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) {

View File

@ -18,8 +18,7 @@ public class MapPainter {
public void setMap(Map map) {
if (maps.contains(map)) {
actualMap = map;
}
else {
} else {
maps.add(map);
actualMap = map;
}
@ -84,7 +83,4 @@ public class MapPainter {
}
}
}
}

View File

@ -1,4 +1,5 @@
package ruscz.game.gameOfProd.Windows;
import ruscz.game.gameOfProd.Cells.Cell;
import ruscz.game.gameOfProd.Cells.EventMoveToCell;
import ruscz.game.gameOfProd.Cells.InteractionCell;
@ -52,7 +53,8 @@ public class WindowOfFreeMove extends JFrame {
}
public void setMap(Map map) {
; this.
;
this.
map.
setMap(map);
}
@ -61,11 +63,17 @@ public class WindowOfFreeMove extends JFrame {
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() {
isReadyToPaint = false;

View File

@ -6,7 +6,7 @@
0 0 83 95 0 0 83 95 0 0
0 0 0 0 0 0 0 0 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