mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 09:59:45 +02:00
Alte Methoden entfernt. Code aufgeräumt.
This commit is contained in:
@@ -18,8 +18,11 @@ import de.heatup.objects.*;
|
||||
public class MapEngine {
|
||||
|
||||
private static final int singleTileWidth = Config.singleTilePixels;
|
||||
|
||||
private final int mapHeight = Config.mapMaxTilesHeight;
|
||||
|
||||
private final int mapWidth = Config.mapMaxTilesWidth;
|
||||
|
||||
private final int gamePanelWidth = Config.gamePanelWidth;
|
||||
|
||||
HashMap<Character, ArrayList<Point>> allMapTiles = new HashMap<Character, ArrayList<Point>>();
|
||||
@@ -36,6 +39,7 @@ public class MapEngine {
|
||||
}
|
||||
this.createTiles(input);
|
||||
}
|
||||
|
||||
public MapEngine() {
|
||||
Scanner input = null;
|
||||
try {
|
||||
@@ -49,6 +53,7 @@ public class MapEngine {
|
||||
}
|
||||
this.createTiles(input);
|
||||
}
|
||||
|
||||
private void createTiles(Scanner input) {
|
||||
int lineCount = 0;
|
||||
int x = 0;
|
||||
@@ -120,9 +125,6 @@ public class MapEngine {
|
||||
} else {
|
||||
allMapTiles.get(currentLine.charAt(i)).add(new Point(x,y));
|
||||
}
|
||||
/*
|
||||
* setze x und y auf die koordinaten für das objekt im NÄCHSTEN durchlauf
|
||||
*/
|
||||
if (x+singleTileWidth >= gamePanelWidth) {
|
||||
x = 0;
|
||||
y += singleTileWidth;
|
||||
@@ -133,68 +135,51 @@ public class MapEngine {
|
||||
lineCount++;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* wird wahrscheinlich anders umgesetzt. methode ist für testzwecke enthalten.
|
||||
*/
|
||||
// protected void addAllGameTilesToGamePanel(JPanel gamePanel) throws IOException {
|
||||
// int x = 0;
|
||||
// int y = 0;
|
||||
// for (int i = 0; i<mapHeight; i++) {
|
||||
// for (int j = 0; j < mapWidth; j++) {
|
||||
// Objekt newGameTile = new Objekt(getTiles()[i][j]);
|
||||
// newGameTile.setPosition(x, y);
|
||||
// if (x+25 >= 800) {
|
||||
// x = 0;
|
||||
// y += 25;
|
||||
// } else {
|
||||
// x += 25;
|
||||
// }
|
||||
// gamePanel.add(newGameTile.getLabel());
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// gamePanel.repaint();
|
||||
// }
|
||||
// /*
|
||||
// * get all tiles in a 2 dimensional char array
|
||||
// */
|
||||
// private char[][] getTiles() {
|
||||
// return tiles;
|
||||
// }
|
||||
|
||||
private HashMap<Character, ArrayList<Point>> getAllMapTiles() {
|
||||
return allMapTiles;
|
||||
}
|
||||
|
||||
protected ArrayList<Character> getAvailableHardwareTileTypes() {
|
||||
return availableHardwareTileTypes;
|
||||
}
|
||||
|
||||
protected ArrayList<Point> getAllCoordinatesOfTileType(char c) {
|
||||
return getAllMapTiles().get(c);
|
||||
}
|
||||
|
||||
protected Point getFirstTilesCoordinatesOfTileType(char c) {
|
||||
return getAllMapTiles().get(c).get(0);
|
||||
}
|
||||
|
||||
protected Point getLastTilesCoordinatesOfTileType(char c) {
|
||||
return getAllMapTiles().get(c).get(getAllMapTiles().get(c).size()-1);
|
||||
}
|
||||
|
||||
public ArrayList<StaticObject> getAllMapObjects() {
|
||||
return MapObjectHandler.getAllMapObjects(this);
|
||||
}
|
||||
|
||||
public ArrayList<StaticObject> getAllHardwareObjects() {
|
||||
return MapObjectHandler.getAllHardwareObjects();
|
||||
}
|
||||
|
||||
public ArrayList<StaticObject> getAllWallObjects() {
|
||||
return MapObjectHandler.getAllWallObjects();
|
||||
}
|
||||
|
||||
public ArrayList<StaticObject> getAllWayObjects() {
|
||||
return MapObjectHandler.getAllWayObjects();
|
||||
}
|
||||
|
||||
public ArrayList<StaticObject> getAllHardwareTriggerObjects() {
|
||||
return MapObjectHandler.getAllHardwareTriggerObjects();
|
||||
}
|
||||
|
||||
private boolean checkIfPath(char c) {
|
||||
return (c=='#');
|
||||
}
|
||||
|
||||
private boolean checkIfHardware(char c) {
|
||||
for (char j = '0'; j <= '9'; j++) {
|
||||
if (j==c) {
|
||||
@@ -203,6 +188,7 @@ public class MapEngine {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void printMapGridWithTriggers() {
|
||||
for (int i = 0; i < 24; i++) {
|
||||
for (int j = 0; j < 32; j++) {
|
||||
|
||||
@@ -3,8 +3,11 @@ package de.heatup.mapengine;
|
||||
import de.heatup.cfg.Config;
|
||||
|
||||
public class MapGrid {
|
||||
|
||||
private static MapGridCell[][] allGridCells = new MapGridCell[Config.mapMaxTilesWidth][Config.mapMaxTilesHeight];
|
||||
|
||||
private static MapGridCell dummyCell = new MapGridCell(); // wird zurückgegeben, falls der MapGrid index ausserhalb unserer allGridCells dimension zeigt.
|
||||
|
||||
protected static void addGrid(int x, int y, boolean isPath) {
|
||||
if (!(x < 0 || x > Config.mapMaxTilesWidth || y < 0 || y > Config.mapMaxTilesHeight)) {
|
||||
MapGridCell newCell = new MapGridCell();
|
||||
@@ -12,6 +15,7 @@ public class MapGrid {
|
||||
allGridCells[x][y] = newCell;
|
||||
}
|
||||
}
|
||||
|
||||
protected static void addGrid(int x, int y, boolean isPath, boolean isTrigger, char correspondingHardwareToTrigger) {
|
||||
if (!(x < 0 || x > Config.mapMaxTilesWidth || y < 0 || y > Config.mapMaxTilesHeight)) {
|
||||
MapGridCell newCell = new MapGridCell();
|
||||
@@ -21,6 +25,7 @@ public class MapGrid {
|
||||
allGridCells[x][y] = newCell;
|
||||
}
|
||||
}
|
||||
|
||||
protected static void addGrid(int x, int y, boolean isTrigger, char correspondingHardwareToTrigger) {
|
||||
if (!(x < 0 || x > Config.mapMaxTilesWidth || y < 0 || y > Config.mapMaxTilesHeight)) {
|
||||
MapGridCell newCell = new MapGridCell();
|
||||
@@ -29,6 +34,7 @@ public class MapGrid {
|
||||
allGridCells[x][y] = newCell;
|
||||
}
|
||||
}
|
||||
|
||||
public static MapGridCell getGridCell(int x, int y) {
|
||||
if (!(x < 0 || x > Config.mapMaxTilesWidth-1 || y < 0 || y > Config.mapMaxTilesHeight-1)) {
|
||||
return allGridCells[x][y];
|
||||
|
||||
@@ -1,24 +1,33 @@
|
||||
package de.heatup.mapengine;
|
||||
|
||||
public class MapGridCell {
|
||||
|
||||
private boolean isPath = false;
|
||||
|
||||
private boolean isTrigger = false;
|
||||
|
||||
private char correspondingHardwareToTrigger;
|
||||
|
||||
public char getCorrespondingHardwareToTrigger() {
|
||||
return correspondingHardwareToTrigger;
|
||||
}
|
||||
public void setCorrespondingHardwareToTrigger(char correspondingHardwareToTrigger) {
|
||||
|
||||
protected void setCorrespondingHardwareToTrigger(char correspondingHardwareToTrigger) {
|
||||
this.correspondingHardwareToTrigger = correspondingHardwareToTrigger;
|
||||
}
|
||||
|
||||
public boolean isPath() {
|
||||
return isPath;
|
||||
}
|
||||
|
||||
protected void setPath(boolean isPath) {
|
||||
this.isPath = isPath;
|
||||
}
|
||||
|
||||
public boolean isTrigger() {
|
||||
return isTrigger;
|
||||
}
|
||||
|
||||
protected void setTrigger(boolean isTrigger) {
|
||||
this.isTrigger = isTrigger;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user