diff --git a/HeatUp/src/de/heatup/mapengine/GridCell.java b/HeatUp/src/de/heatup/mapengine/GridCell.java new file mode 100644 index 0000000..5192275 --- /dev/null +++ b/HeatUp/src/de/heatup/mapengine/GridCell.java @@ -0,0 +1,25 @@ +package de.heatup.mapengine; + +public class GridCell { + private boolean isPath = false; + private boolean isTrigger = false; + private char correspondingHardwareToTrigger; + public char getCorrespondingHardwareToTrigger() { + return correspondingHardwareToTrigger; + } + public 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; + } +} diff --git a/HeatUp/src/de/heatup/mapengine/MapEngine.java b/HeatUp/src/de/heatup/mapengine/MapEngine.java index 5808d1d..2ab201e 100644 --- a/HeatUp/src/de/heatup/mapengine/MapEngine.java +++ b/HeatUp/src/de/heatup/mapengine/MapEngine.java @@ -56,6 +56,58 @@ public class MapEngine { while (input.hasNextLine() && lineCount <= mapHeight) { String currentLine = input.nextLine(); for (int i = 0; i newTileType = new ArrayList(); newTileType.add(new Point(x,y)); @@ -140,4 +192,15 @@ public class MapEngine { 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) { + return true; + } + } + return false; + } } diff --git a/HeatUp/src/de/heatup/mapengine/MapGrid.java b/HeatUp/src/de/heatup/mapengine/MapGrid.java new file mode 100644 index 0000000..fa8b633 --- /dev/null +++ b/HeatUp/src/de/heatup/mapengine/MapGrid.java @@ -0,0 +1,38 @@ +package de.heatup.mapengine; + +import de.heatup.cfg.Config; + +public class MapGrid { + private static GridCell[][] allGridCells = new GridCell[Config.mapMaxTilesWidth][Config.mapMaxTilesHeight]; + private static GridCell dummyCell = new GridCell(); // 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)) { + GridCell newCell = new GridCell(); + newCell.setPath(isPath); + 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)) { + GridCell newCell = new GridCell(); + newCell.setPath(isPath); + newCell.setTrigger(isTrigger); + newCell.setCorrespondingHardwareToTrigger(correspondingHardwareToTrigger); + 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)) { + GridCell newCell = new GridCell(); + newCell.setTrigger(isTrigger); + newCell.setCorrespondingHardwareToTrigger(correspondingHardwareToTrigger); + allGridCells[x][y] = newCell; + } + } + public static GridCell getGridCell(int x, int y) { + if (!(x < 0 || x > Config.mapMaxTilesWidth || y < 0 || y > Config.mapMaxTilesHeight)) { + return allGridCells[x][y]; + } + return dummyCell; + } +} diff --git a/HeatUp/src/de/heatup/mapengine/MapObjectHandler.java b/HeatUp/src/de/heatup/mapengine/MapObjectHandler.java index 8e858e1..5824d44 100644 --- a/HeatUp/src/de/heatup/mapengine/MapObjectHandler.java +++ b/HeatUp/src/de/heatup/mapengine/MapObjectHandler.java @@ -4,7 +4,6 @@ import java.awt.Point; import java.util.ArrayList; import de.heatup.cfg.Config; -import de.heatup.logging.Logger; import de.heatup.objects.StaticObject; public class MapObjectHandler { @@ -41,7 +40,7 @@ public class MapObjectHandler { Point currentTriggerTilesFirstPoint = new Point(firstPoint.x-(triggerAreaAddition/2),firstPoint.y-(triggerAreaAddition/2)); StaticObject newStaticObject = new StaticObject(currentType, firstPoint, currentTilesTotalWidth, currentTilesTotalHeight); - // Trigger Object + // Trigger Object - auskommentieren sobald implementiert. // StaticObject newTriggerObject = new StaticObject(currentType, firstPoint, currentTilesTotalWidth, currentTilesTotalHeight, true); MapObjectHandler.allMapObjects.add(newStaticObject); // MapObjectHandler.allMapObjects.add(newTriggerObject);