|
@@ -15,7 +15,8 @@ import me.hammerle.supersnuvi.entity.EntityBuilder;
|
|
import me.hammerle.supersnuvi.tiles.Location;
|
|
import me.hammerle.supersnuvi.tiles.Location;
|
|
import me.hammerle.supersnuvi.tiles.StartTile;
|
|
import me.hammerle.supersnuvi.tiles.StartTile;
|
|
import me.hammerle.supersnuvi.tiles.Tile;
|
|
import me.hammerle.supersnuvi.tiles.Tile;
|
|
-import me.hammerle.supersnuvi.util.CollisionBox;
|
|
|
|
|
|
+import me.hammerle.supersnuvi.util.CollisionLine;
|
|
|
|
+import me.hammerle.supersnuvi.util.CollisionObject;
|
|
import me.hammerle.supersnuvi.util.Utils;
|
|
import me.hammerle.supersnuvi.util.Utils;
|
|
|
|
|
|
public final class Level
|
|
public final class Level
|
|
@@ -85,11 +86,15 @@ public final class Level
|
|
}
|
|
}
|
|
|
|
|
|
// debug stuff
|
|
// debug stuff
|
|
- /*if(name.equals("00-Tech Demo"))
|
|
|
|
|
|
+ if(name.equals("00-Tech Demo"))
|
|
{
|
|
{
|
|
- int index = data.getBackgroundIndex() + 1;
|
|
|
|
- data.setTile(index, 10, 6, 2);
|
|
|
|
- data.setTile(index, 11, 6, 1);
|
|
|
|
|
|
+ int index = data.getBackgroundIndex();
|
|
|
|
+ for(int i = 0; i < 5; i++)
|
|
|
|
+ {
|
|
|
|
+ data.setTile(index, 3 + i, 7 - i, 300);
|
|
|
|
+ }
|
|
|
|
+ data.setTile(index, 8, 3, 2);
|
|
|
|
+ data.setTile(index, 9, 4, 2);
|
|
|
|
|
|
/*for(int layer = 0; layer <= data.getBackgroundIndex(); layer++)
|
|
/*for(int layer = 0; layer <= data.getBackgroundIndex(); layer++)
|
|
{
|
|
{
|
|
@@ -127,8 +132,8 @@ public final class Level
|
|
{
|
|
{
|
|
data.setTile(index, x + 6, y + 1, 256 + x + (4 - y) * 5);
|
|
data.setTile(index, x + 6, y + 1, 256 + x + (4 - y) * 5);
|
|
}
|
|
}
|
|
- }
|
|
|
|
- }*/
|
|
|
|
|
|
+ }*/
|
|
|
|
+ }
|
|
// end debug stuff
|
|
// end debug stuff
|
|
|
|
|
|
maxSouls = 0;
|
|
maxSouls = 0;
|
|
@@ -657,19 +662,19 @@ public final class Level
|
|
return Game.get().getTile(i);
|
|
return Game.get().getTile(i);
|
|
}
|
|
}
|
|
|
|
|
|
- private CollisionBox getMovementBox(int x, int y)
|
|
|
|
|
|
+ private CollisionObject getMovementBox(int x, int y)
|
|
{
|
|
{
|
|
int i = data.getInteractionTile(x, y);
|
|
int i = data.getInteractionTile(x, y);
|
|
if(i == -1)
|
|
if(i == -1)
|
|
{
|
|
{
|
|
- return CollisionBox.NULL_BOX;
|
|
|
|
|
|
+ return CollisionObject.NULL_BOX;
|
|
}
|
|
}
|
|
return Game.get().getTile(i).getMovementBox(x, y).reset().offset(Utils.toCoord(x), Utils.toCoord(y));
|
|
return Game.get().getTile(i).getMovementBox(x, y).reset().offset(Utils.toCoord(x), Utils.toCoord(y));
|
|
}
|
|
}
|
|
|
|
|
|
- public List<CollisionBox> getMovementBoxesAt(CollisionBox box, Entity not)
|
|
|
|
|
|
+ public List<CollisionObject> getMovementBoxesAt(CollisionObject box, Entity not)
|
|
{
|
|
{
|
|
- List<CollisionBox> boxes;
|
|
|
|
|
|
+ List<CollisionObject> boxes;
|
|
if(not != null)
|
|
if(not != null)
|
|
{
|
|
{
|
|
boxes = getEntitiesCollidingWith(not, box).stream().map(ent -> ent.getBox()).collect(Collectors.toList());
|
|
boxes = getEntitiesCollidingWith(not, box).stream().map(ent -> ent.getBox()).collect(Collectors.toList());
|
|
@@ -687,8 +692,8 @@ public final class Level
|
|
{
|
|
{
|
|
for(int y = startY; y <= endY; y++)
|
|
for(int y = startY; y <= endY; y++)
|
|
{
|
|
{
|
|
- CollisionBox cb = getMovementBox(x, y);
|
|
|
|
- if(cb.isColliding(box) && cb != CollisionBox.NULL_BOX)
|
|
|
|
|
|
+ CollisionObject cb = getMovementBox(x, y);
|
|
|
|
+ if(cb.mayCollide(box) && cb != CollisionObject.NULL_BOX)
|
|
{
|
|
{
|
|
boxes.add(cb.copy());
|
|
boxes.add(cb.copy());
|
|
}
|
|
}
|
|
@@ -697,18 +702,18 @@ public final class Level
|
|
return boxes;
|
|
return boxes;
|
|
}
|
|
}
|
|
|
|
|
|
- private CollisionBox getCollisionBox(int x, int y)
|
|
|
|
|
|
+ private CollisionObject getCollisionBox(int x, int y)
|
|
{
|
|
{
|
|
int i = data.getInteractionTile(x, y);
|
|
int i = data.getInteractionTile(x, y);
|
|
if(i == -1)
|
|
if(i == -1)
|
|
{
|
|
{
|
|
- return CollisionBox.NULL_BOX;
|
|
|
|
|
|
+ return CollisionObject.NULL_BOX;
|
|
}
|
|
}
|
|
Tile tile = Game.get().getTile(i);
|
|
Tile tile = Game.get().getTile(i);
|
|
return tile.getCollisionBox(x, y).reset().offset(Utils.toCoord(x), Utils.toCoord(y));
|
|
return tile.getCollisionBox(x, y).reset().offset(Utils.toCoord(x), Utils.toCoord(y));
|
|
}
|
|
}
|
|
|
|
|
|
- public List<Location> getCollisionBoxesAt(CollisionBox cb)
|
|
|
|
|
|
+ public List<Location> getCollisionBoxesAt(CollisionObject cb)
|
|
{
|
|
{
|
|
LinkedList<Location> boxes = new LinkedList<>();
|
|
LinkedList<Location> boxes = new LinkedList<>();
|
|
int startX = Utils.toBlock(cb.getMinX());
|
|
int startX = Utils.toBlock(cb.getMinX());
|
|
@@ -729,7 +734,7 @@ public final class Level
|
|
return boxes;
|
|
return boxes;
|
|
}
|
|
}
|
|
|
|
|
|
- public List<Entity> getEntitiesCollidingWith(Entity not, CollisionBox cb)
|
|
|
|
|
|
+ public List<Entity> getEntitiesCollidingWith(Entity not, CollisionObject cb)
|
|
{
|
|
{
|
|
return entities.values().stream().filter(ent -> ent != not && ent.getBox().isColliding(cb)).collect(Collectors.toList());
|
|
return entities.values().stream().filter(ent -> ent != not && ent.getBox().isColliding(cb)).collect(Collectors.toList());
|
|
}
|
|
}
|