mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-07-23 14:18:06 +07:00
Disabled path finder movement (new branch)
Disabled path finder movement on this branch Bug fixes to path finder along with distance limiter Incorporated persistent path into MapViewer/Entity
This commit is contained in:
@ -228,7 +228,7 @@ public class Entity {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePath(Map map) {
|
public void updatePath(Map map, Vector3 target) {
|
||||||
map.path(position, target, path);
|
map.path(position, target, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,6 +410,17 @@ public class Entity {
|
|||||||
int x = Direction.getOffX(angle);
|
int x = Direction.getOffX(angle);
|
||||||
int y = Direction.getOffY(angle);
|
int y = Direction.getOffY(angle);
|
||||||
position.add(x, y, 0);
|
position.add(x, y, 0);
|
||||||
|
//if (position.epsilonEquals(target) || target.equals(Vector3.Zero)) {
|
||||||
|
// if (path.getCount() > 0) {
|
||||||
|
// Point2 point = path.get(0);
|
||||||
|
// target.set(point.x, point.y, 0);
|
||||||
|
// } else {
|
||||||
|
// setMode("NU");
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//position.lerp(target, 1f);
|
||||||
|
//position.set(target);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,13 +15,14 @@ public class MapPather {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean path(Vector3 src, Vector3 dst, GraphPath<Point2> path) {
|
public boolean path(Vector3 src, Vector3 dst, GraphPath<Point2> path) {
|
||||||
|
if (src.dst(dst) > 25f) return false;
|
||||||
return path(new Point2(src), new Point2(dst), path);
|
return path(new Point2(src), new Point2(dst), path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean path(Point2 src, Point2 dst, GraphPath<Point2> path) {
|
public boolean path(Point2 src, Point2 dst, GraphPath<Point2> path) {
|
||||||
path.clear();
|
path.clear();
|
||||||
Map.Zone zone = map.getZone(dst.x, dst.y);
|
Map.Zone zone = map.getZone(dst.x, dst.y);
|
||||||
if (zone.flags(dst.x, dst.y) != 0) return false;
|
if (zone == null || zone.flags(dst.x, dst.y) != 0) return false;
|
||||||
|
|
||||||
BinaryHeap<Point2> closedSet = new BinaryHeap<>();
|
BinaryHeap<Point2> closedSet = new BinaryHeap<>();
|
||||||
BinaryHeap<Point2> openSet = new BinaryHeap<>();
|
BinaryHeap<Point2> openSet = new BinaryHeap<>();
|
||||||
|
@ -3,8 +3,8 @@ package gdx.diablo.map;
|
|||||||
import com.badlogic.gdx.math.Vector3;
|
import com.badlogic.gdx.math.Vector3;
|
||||||
|
|
||||||
public class Point2 extends BinaryHeap.Node {
|
public class Point2 extends BinaryHeap.Node {
|
||||||
final int x;
|
public final int x;
|
||||||
final int y;
|
public final int y;
|
||||||
final int hash;
|
final int hash;
|
||||||
|
|
||||||
Point2(int x, int y, float cost) {
|
Point2(int x, int y, float cost) {
|
||||||
|
@ -386,10 +386,13 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
|
|||||||
if (Gdx.input.isButtonPressed(Input.Buttons.LEFT)) {
|
if (Gdx.input.isButtonPressed(Input.Buttons.LEFT)) {
|
||||||
// FIXME: should block click events on UI panels, bugged right now
|
// FIXME: should block click events on UI panels, bugged right now
|
||||||
//Actor hit = stage.hit(Gdx.input.getX(), Gdx.input.getY(), true);
|
//Actor hit = stage.hit(Gdx.input.getX(), Gdx.input.getY(), true);
|
||||||
//if (hit == null) {
|
//if (hit != null) {
|
||||||
Vector3 coords = mapRenderer.getCursor();
|
Vector3 coords = mapRenderer.getCursor();
|
||||||
player.target().set(coords);
|
//player.target().set(coords);
|
||||||
player.updatePath(map);
|
//player.updatePath(map, coords);
|
||||||
|
//if (player.path().getCount() > 0) {
|
||||||
|
// player.setMode("RN");
|
||||||
|
//}
|
||||||
//} else {
|
//} else {
|
||||||
// System.out.println(hit);
|
// System.out.println(hit);
|
||||||
//}
|
//}
|
||||||
|
@ -6,6 +6,7 @@ import com.badlogic.gdx.Gdx;
|
|||||||
import com.badlogic.gdx.Input;
|
import com.badlogic.gdx.Input;
|
||||||
import com.badlogic.gdx.InputAdapter;
|
import com.badlogic.gdx.InputAdapter;
|
||||||
import com.badlogic.gdx.InputMultiplexer;
|
import com.badlogic.gdx.InputMultiplexer;
|
||||||
|
import com.badlogic.gdx.ai.pfa.DefaultGraphPath;
|
||||||
import com.badlogic.gdx.ai.pfa.GraphPath;
|
import com.badlogic.gdx.ai.pfa.GraphPath;
|
||||||
import com.badlogic.gdx.assets.AssetManager;
|
import com.badlogic.gdx.assets.AssetManager;
|
||||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
||||||
@ -76,7 +77,7 @@ public class MapViewer extends ApplicationAdapter {
|
|||||||
|
|
||||||
Vector3 src;
|
Vector3 src;
|
||||||
Vector3 dst;
|
Vector3 dst;
|
||||||
GraphPath<Point2> path;
|
GraphPath<Point2> path = new DefaultGraphPath<>();
|
||||||
|
|
||||||
boolean drawCrosshair;
|
boolean drawCrosshair;
|
||||||
boolean drawGrid;
|
boolean drawGrid;
|
||||||
@ -172,7 +173,7 @@ public class MapViewer extends ApplicationAdapter {
|
|||||||
//System.out.println(new Vector2(dstX, dstY).dst(srcX, srcY));
|
//System.out.println(new Vector2(dstX, dstY).dst(srcX, srcY));
|
||||||
System.out.println(src.dst(dst));
|
System.out.println(src.dst(dst));
|
||||||
|
|
||||||
path = map.path(src, dst);
|
map.path(src, dst, path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -375,7 +376,7 @@ public class MapViewer extends ApplicationAdapter {
|
|||||||
mapRenderer.renderDebug(shapes);
|
mapRenderer.renderDebug(shapes);
|
||||||
if (src != null && dst != null) {
|
if (src != null && dst != null) {
|
||||||
//mapRenderer.renderDebugPath(shapes, src, dst);
|
//mapRenderer.renderDebugPath(shapes, src, dst);
|
||||||
if (path != null) mapRenderer.renderDebugPath2(shapes, path);
|
mapRenderer.renderDebugPath2(shapes, path);
|
||||||
float srcX = +(src.x * Tile.SUBTILE_WIDTH50) - (src.y * Tile.SUBTILE_WIDTH50);
|
float srcX = +(src.x * Tile.SUBTILE_WIDTH50) - (src.y * Tile.SUBTILE_WIDTH50);
|
||||||
float srcY = -(src.x * Tile.SUBTILE_HEIGHT50) - (src.y * Tile.SUBTILE_HEIGHT50);
|
float srcY = -(src.x * Tile.SUBTILE_HEIGHT50) - (src.y * Tile.SUBTILE_HEIGHT50);
|
||||||
float dstX = +(dst.x * Tile.SUBTILE_WIDTH50) - (dst.y * Tile.SUBTILE_WIDTH50);
|
float dstX = +(dst.x * Tile.SUBTILE_WIDTH50) - (dst.y * Tile.SUBTILE_WIDTH50);
|
||||||
|
Reference in New Issue
Block a user