From 9013bd44d7a56cb44facc52f5c09422a37f09414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bokros=20B=C3=A1lint?= Date: Mon, 25 Apr 2016 22:16:18 +0200 Subject: [PATCH] Implemented teleport in Stargate --- cicaprojekt/Stargate.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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