Player is now floating between dimensions if the exit of the other stargate is blocked

also fixes #7
This commit is contained in:
Bokros Bálint 2016-05-13 20:47:18 +02:00
parent d64fb27413
commit 6700c33b8d
2 changed files with 6 additions and 1 deletions

View File

@ -59,7 +59,9 @@ public class Stargate {
return isSpawned; return isSpawned;
} }
public boolean isOpen() { public boolean isOpen() {
return isSpawned & other.isSpawned; if(isSpawned & other.isSpawned)
return other.getCurrentWall().getAdjacentTile(other.getExitDirection()).isSteppable();
return false;
} }
private Direction getExitDirection() { private Direction getExitDirection() {
@ -69,6 +71,8 @@ public class Stargate {
public void teleport(PlayerBase player) { public void teleport(PlayerBase player) {
if(isOpen()) if(isOpen())
player.setCurrentTile(other.getCurrentWall().getAdjacentTile(other.getExitDirection())); player.setCurrentTile(other.getCurrentWall().getAdjacentTile(other.getExitDirection()));
else
player.setCurrentTile(this.getCurrentWall());
} }
@Override @Override

View File

@ -44,6 +44,7 @@ public class Wall extends Tile {
} }
public void onExit(PlayerBase playerBase) throws IllegalStateException { public void onExit(PlayerBase playerBase) throws IllegalStateException {
if(sg != null) return;
throw new IllegalStateException("Hiba! Te hogy kerültél a falba?"); throw new IllegalStateException("Hiba! Te hogy kerültél a falba?");
} }