diff --git a/HeatUp/src/de/heatup/mapengine/MapEngine.java b/HeatUp/src/de/heatup/mapengine/MapEngine.java index 33c8523..0a67769 100644 --- a/HeatUp/src/de/heatup/mapengine/MapEngine.java +++ b/HeatUp/src/de/heatup/mapengine/MapEngine.java @@ -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> allMapTiles = new HashMap>(); @@ -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= 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> getAllMapTiles() { return allMapTiles; } + protected ArrayList getAvailableHardwareTileTypes() { return availableHardwareTileTypes; } + protected ArrayList 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 getAllMapObjects() { return MapObjectHandler.getAllMapObjects(this); } + public ArrayList getAllHardwareObjects() { return MapObjectHandler.getAllHardwareObjects(); } + public ArrayList getAllWallObjects() { return MapObjectHandler.getAllWallObjects(); } + public ArrayList getAllWayObjects() { return MapObjectHandler.getAllWayObjects(); } + public ArrayList 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++) { diff --git a/HeatUp/src/de/heatup/mapengine/MapGrid.java b/HeatUp/src/de/heatup/mapengine/MapGrid.java index a9c3520..05b67b5 100644 --- a/HeatUp/src/de/heatup/mapengine/MapGrid.java +++ b/HeatUp/src/de/heatup/mapengine/MapGrid.java @@ -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]; diff --git a/HeatUp/src/de/heatup/mapengine/MapGridCell.java b/HeatUp/src/de/heatup/mapengine/MapGridCell.java index 0713ac5..6fa0eee 100644 --- a/HeatUp/src/de/heatup/mapengine/MapGridCell.java +++ b/HeatUp/src/de/heatup/mapengine/MapGridCell.java @@ -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; }