|
@@ -0,0 +1,41 @@
|
|
|
|
+package me.hammerle.supersnuvi.gamelogic;
|
|
|
|
+
|
|
|
|
+import me.hammerle.supersnuvi.Game;
|
|
|
|
+import me.hammerle.supersnuvi.tiles.Tile;
|
|
|
|
+import me.hammerle.supersnuvi.util.CollisionObject;
|
|
|
|
+import me.hammerle.supersnuvi.util.Pair;
|
|
|
|
+
|
|
|
|
+import java.util.HashSet;
|
|
|
|
+import java.util.Set;
|
|
|
|
+
|
|
|
|
+public class LevelPathParser {
|
|
|
|
+
|
|
|
|
+ public static Set<Pair<Integer, Integer>> getCoordinatesOfCollisionTiles(Level lvl){
|
|
|
|
+
|
|
|
|
+ Set<Pair<Integer, Integer>> res = new HashSet<>();
|
|
|
|
+
|
|
|
|
+ if(lvl == null) return res;
|
|
|
|
+
|
|
|
|
+ LevelData lvldata = lvl.getData();
|
|
|
|
+
|
|
|
|
+ int backgroundIndex = lvldata.getBackgroundIndex();
|
|
|
|
+ int width = lvldata.getWidth();
|
|
|
|
+ int height = lvldata.getHeight();
|
|
|
|
+
|
|
|
|
+ for(int x = 0; x < width; x++){
|
|
|
|
+ for(int y = 0; y < height; y++){
|
|
|
|
+
|
|
|
|
+ int tileid = lvldata.getTile(backgroundIndex, x, y);
|
|
|
|
+ Tile tile = Game.get().getTile(tileid);
|
|
|
|
+
|
|
|
|
+ if(tile.getMovementBox(x, y, lvl) != CollisionObject.NULL_BOX){
|
|
|
|
+
|
|
|
|
+ Pair<Integer, Integer> point = new Pair<>(x, y);
|
|
|
|
+ res.add(point);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+}
|