From e6724662006e2fdbe37ab6fed493331fdb108974 Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Fri, 3 May 2019 17:50:10 -0700 Subject: [PATCH] Added support for draw debug entity sizes Added support for draw debug entity sizes Fixed bug with debug shape type in draw walkable tiles Assigned Player entities to size 2 --- core/src/com/riiablo/entity/Entity.java | 49 +++++++++++++++++++++++ core/src/com/riiablo/entity/Player.java | 1 + core/src/com/riiablo/map/MapRenderer.java | 2 + 3 files changed, 52 insertions(+) diff --git a/core/src/com/riiablo/entity/Entity.java b/core/src/com/riiablo/entity/Entity.java index bf70ee9a..ffbc0156 100644 --- a/core/src/com/riiablo/entity/Entity.java +++ b/core/src/com/riiablo/entity/Entity.java @@ -220,6 +220,12 @@ public abstract class Entity implements Animation.AnimationListener { Arrays.fill(DEFAULT_ALPHA, 1.0f); } + private static final int[][][] SIZES = { + { {0,0} }, + { {0,0}, {-1,0}, {1,0}, {0,-1}, {0,1} }, + { {0,0}, {-1,0}, {1,0}, {0,-1}, {0,1}, {-1,-1}, {1,1}, {1,-1}, {-1,1}, {-2,0}, {2,0}, {0,-2}, {0,2} }, + }; + int uuid = 0; String classname; @@ -257,6 +263,8 @@ public abstract class Entity implements Animation.AnimationListener { Overlay.Entry overlayEntry; Animation overlay; + int size = 1; + private static final Vector2 tmpVec2 = new Vector2(); public static Entity create(Map map, Map.Zone zone, DS1 ds1, DS1.Object object) { @@ -480,10 +488,22 @@ public abstract class Entity implements Animation.AnimationListener { public void drawDebug(PaletteIndexedBatch batch, ShapeRenderer shapes) { + drawDebugSize(shapes); drawDebugStatus(batch, shapes); if (DEBUG_TARGET) drawDebugTarget(shapes); } + public void drawDebugSize(ShapeRenderer shapes) { + shapes.set(ShapeRenderer.ShapeType.Filled); + shapes.setColor(Color.GRAY); + int[][] SIZE = SIZES[size - 1]; + for (int[] subtile : SIZE) { + EngineUtils.worldToScreenCoords(position.x + subtile[0], position.y + subtile[1], tmpVec2); + DebugUtils.drawDiamond(shapes, tmpVec2.x, tmpVec2.y, Tile.SUBTILE_WIDTH, Tile.SUBTILE_HEIGHT); + } + shapes.set(ShapeRenderer.ShapeType.Line); + } + public void drawDebugStatus(PaletteIndexedBatch batch, ShapeRenderer shapes) { float x = screen.x; float y = screen.y; @@ -767,6 +787,25 @@ public abstract class Entity implements Animation.AnimationListener { boolean changed = sequence(newMode, getNeutralMode()); if (!changed) return false; + /* + updateCOF(); // FIXME: required because we need updated COF to bind to trigger -- should really be done on next frame + for (COF.Keyframe keyframe : COF.Keyframe.values()) { + int frame = animation.getCOF().getKeyframeFrame(keyframe); + System.out.println("keyframe[" + keyframe + "]=" + frame); + } + + int frame = animation.getCOF().getKeyframeFrame(COF.Keyframe.ATTACK); + if (frame >= 0) { + animation.addAnimationListener(frame, new Animation.AnimationListener() { + @Override + public void onTrigger(Animation animation, int frame) { + System.out.println("onTrigger " + frame + " " + COF.Keyframe.ATTACK); + animation.removeAnimationListener(frame, this); + } + }); + } + */ + System.out.println("cast " + type.MODE[tm] + "->" + type.MODE[mode]); Riiablo.audio.play(skill.stsound, true); @@ -786,4 +825,14 @@ public abstract class Entity implements Animation.AnimationListener { return true; } + + public void setSize(int size) { + if (this.size != size) { + this.size = size; + } + } + + public int getSize() { + return size; + } } diff --git a/core/src/com/riiablo/entity/Player.java b/core/src/com/riiablo/entity/Player.java index 4461cef6..9fc5fdf9 100644 --- a/core/src/com/riiablo/entity/Player.java +++ b/core/src/com/riiablo/entity/Player.java @@ -99,6 +99,7 @@ public class Player extends Entity implements CharData.EquippedListener { setRunSpeed(9); setRunning(true); angle(-MathUtils.PI / 2); + setSize(2); } private void loadItems(Array items) { diff --git a/core/src/com/riiablo/map/MapRenderer.java b/core/src/com/riiablo/map/MapRenderer.java index 0c5328a7..f777dbd5 100644 --- a/core/src/com/riiablo/map/MapRenderer.java +++ b/core/src/com/riiablo/map/MapRenderer.java @@ -984,7 +984,9 @@ public class MapRenderer { int offY = py + Tile.SUBTILE_OFFSET[t][1]; shapes.setColor(Color.CORAL); + shapes.set(ShapeRenderer.ShapeType.Line); DebugUtils.drawDiamond2(shapes, offX, offY, Tile.SUBTILE_WIDTH, Tile.SUBTILE_HEIGHT); + shapes.set(ShapeRenderer.ShapeType.Filled); offY += Tile.SUBTILE_HEIGHT50;