mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-21 20:18:14 +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:
parent
5cc2aa55c6
commit
46423e10f7
@ -228,7 +228,7 @@ public class Entity {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void updatePath(Map map) {
|
||||
public void updatePath(Map map, Vector3 target) {
|
||||
map.path(position, target, path);
|
||||
}
|
||||
|
||||
@ -410,6 +410,17 @@ public class Entity {
|
||||
int x = Direction.getOffX(angle);
|
||||
int y = Direction.getOffY(angle);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -15,13 +15,14 @@ public class MapPather {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public boolean path(Point2 src, Point2 dst, GraphPath<Point2> path) {
|
||||
path.clear();
|
||||
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> openSet = new BinaryHeap<>();
|
||||
|
@ -3,8 +3,8 @@ package gdx.diablo.map;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
|
||||
public class Point2 extends BinaryHeap.Node {
|
||||
final int x;
|
||||
final int y;
|
||||
public final int x;
|
||||
public final int y;
|
||||
final int hash;
|
||||
|
||||
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)) {
|
||||
// FIXME: should block click events on UI panels, bugged right now
|
||||
//Actor hit = stage.hit(Gdx.input.getX(), Gdx.input.getY(), true);
|
||||
//if (hit == null) {
|
||||
//if (hit != null) {
|
||||
Vector3 coords = mapRenderer.getCursor();
|
||||
player.target().set(coords);
|
||||
player.updatePath(map);
|
||||
//player.target().set(coords);
|
||||
//player.updatePath(map, coords);
|
||||
//if (player.path().getCount() > 0) {
|
||||
// player.setMode("RN");
|
||||
//}
|
||||
//} else {
|
||||
// System.out.println(hit);
|
||||
//}
|
||||
|
@ -6,6 +6,7 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.InputAdapter;
|
||||
import com.badlogic.gdx.InputMultiplexer;
|
||||
import com.badlogic.gdx.ai.pfa.DefaultGraphPath;
|
||||
import com.badlogic.gdx.ai.pfa.GraphPath;
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
||||
@ -76,7 +77,7 @@ public class MapViewer extends ApplicationAdapter {
|
||||
|
||||
Vector3 src;
|
||||
Vector3 dst;
|
||||
GraphPath<Point2> path;
|
||||
GraphPath<Point2> path = new DefaultGraphPath<>();
|
||||
|
||||
boolean drawCrosshair;
|
||||
boolean drawGrid;
|
||||
@ -172,7 +173,7 @@ public class MapViewer extends ApplicationAdapter {
|
||||
//System.out.println(new Vector2(dstX, dstY).dst(srcX, srcY));
|
||||
System.out.println(src.dst(dst));
|
||||
|
||||
path = map.path(src, dst);
|
||||
map.path(src, dst, path);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
@ -375,7 +376,7 @@ public class MapViewer extends ApplicationAdapter {
|
||||
mapRenderer.renderDebug(shapes);
|
||||
if (src != null && dst != null) {
|
||||
//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 srcY = -(src.x * Tile.SUBTILE_HEIGHT50) - (src.y * Tile.SUBTILE_HEIGHT50);
|
||||
float dstX = +(dst.x * Tile.SUBTILE_WIDTH50) - (dst.y * Tile.SUBTILE_WIDTH50);
|
||||
|
Loading…
Reference in New Issue
Block a user