diff --git a/cicaprojekt/Stargate.java b/cicaprojekt/Stargate.java index a61a5d2..b043163 100644 --- a/cicaprojekt/Stargate.java +++ b/cicaprojekt/Stargate.java @@ -35,7 +35,19 @@ public class Stargate { return isSpawned & other.isSpawned; } - public void teleport(Direction incomingDirection) { + private Direction getExitDirection() { + if(currentWall.getAdjacentTile(Direction.EAST) == null) + return Direction.WEST; + else if(currentWall.getAdjacentTile(Direction.WEST) == null) + return Direction.EAST; + else if(currentWall.getAdjacentTile(Direction.NORTH) == null) + return Direction.SOUTH; + else + return Direction.NORTH; + } + + public void teleport(PlayerBase player) { + player.setCurrentTile(other.getCurrentWall().getAdjacentTile(getExitDirection())); } @Override