From 6700c33b8dba7d857ffcf26377ee1f986ef08878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bokros=20B=C3=A1lint?= Date: Fri, 13 May 2016 20:47:18 +0200 Subject: [PATCH] Player is now floating between dimensions if the exit of the other stargate is blocked also fixes #7 --- cicaprojekt/Stargate.java | 6 +++++- cicaprojekt/Wall.java | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cicaprojekt/Stargate.java b/cicaprojekt/Stargate.java index 4066cd8..8f6e900 100644 --- a/cicaprojekt/Stargate.java +++ b/cicaprojekt/Stargate.java @@ -59,7 +59,9 @@ public class Stargate { return isSpawned; } public boolean isOpen() { - return isSpawned & other.isSpawned; + if(isSpawned & other.isSpawned) + return other.getCurrentWall().getAdjacentTile(other.getExitDirection()).isSteppable(); + return false; } private Direction getExitDirection() { @@ -69,6 +71,8 @@ public class Stargate { public void teleport(PlayerBase player) { if(isOpen()) player.setCurrentTile(other.getCurrentWall().getAdjacentTile(other.getExitDirection())); + else + player.setCurrentTile(this.getCurrentWall()); } @Override diff --git a/cicaprojekt/Wall.java b/cicaprojekt/Wall.java index 3b3567c..c100da8 100644 --- a/cicaprojekt/Wall.java +++ b/cicaprojekt/Wall.java @@ -44,6 +44,7 @@ public class Wall extends Tile { } public void onExit(PlayerBase playerBase) throws IllegalStateException { + if(sg != null) return; throw new IllegalStateException("Hiba! Te hogy kerültél a falba?"); }