Added player entity zone detection

Added player entity zone detection
Player neutral and walk animations will display the correct town version if in town
This commit is contained in:
Collin Smith 2019-03-18 14:12:33 -07:00
parent aa84393b27
commit db627b0076
3 changed files with 12 additions and 4 deletions

View File

@ -87,6 +87,8 @@ public class Player extends Entity {
boolean ignoreUpdate;
public Stats stats;
public Skills skills;
public Map map;
public Map.Zone curZone;
public final CharacterClass charClass;
Array<Item> inventory = new Array<>();
@ -149,12 +151,12 @@ public class Player extends Entity {
@Override
public byte getNeutralMode() {
return MODE_NU;
return (curZone != null && curZone.isTown()) ? MODE_TN : MODE_NU;
}
@Override
public byte getWalkMode() {
return MODE_WL;
return (curZone != null && curZone.isTown()) ? MODE_TW : MODE_WL;
}
@Override

View File

@ -327,6 +327,7 @@ public class Map implements Disposable {
if (DEBUG_BUILD) Gdx.app.debug(TAG, "Select " + fileName);
Zone zone = map.addZone(level, diff, preset, select);
zone.town = true;
Zone prev = zone;
level = Riiablo.files.Levels.get(2);
@ -658,6 +659,7 @@ public class Map implements Disposable {
byte flags[][];
Array<Entity> entities;
IntIntMap warps;
boolean town;
Generator generator;
@ -735,6 +737,10 @@ public class Map implements Disposable {
return warps.get(src, -1);
}
public boolean isTown() {
return town;
}
public void setPosition(int x, int y) {
this.x = x;
this.y = y;

View File

@ -502,7 +502,7 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
Map.Zone prevZone = curZone;
mapRenderer.update();
curZone = map.getZone(player.position());
curZone = player.curZone = map.getZone(player.position());
if (prevZone != curZone && prevZone != null) {
displayEntry();
}
@ -558,7 +558,7 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
Riiablo.music.stop();
Riiablo.assets.get(windowopenDescriptor).play();
Map.instance = map = Riiablo.assets.get(mapDescriptor); // TODO: remove Map.instance
Map.instance = map = player.map = Riiablo.assets.get(mapDescriptor); // TODO: remove Map.instance
mapRenderer = new MapRenderer(Riiablo.batch, viewport.getWorldWidth(), viewport.getWorldHeight());
//mapRenderer = new MapRenderer(Riiablo.batch, 480f * 16f / 9f, 480f);
mapRenderer.setMap(map);