parent
d14ce39ee1
commit
e3ce590d1d
@ -12,6 +12,7 @@ public class Stargate {
|
|||||||
public Stargate other;
|
public Stargate other;
|
||||||
private boolean isSpawned;
|
private boolean isSpawned;
|
||||||
private Wall currentWall;
|
private Wall currentWall;
|
||||||
|
private Direction exitDirection;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private static Map<Color, Stargate> stargates = new HashMap<>();
|
private static Map<Color, Stargate> stargates = new HashMap<>();
|
||||||
@ -42,8 +43,10 @@ public class Stargate {
|
|||||||
return currentWall;
|
return currentWall;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentWall(Wall wall) {
|
public void setCurrentWall(Wall wall, Direction direction) {
|
||||||
currentWall = wall;
|
currentWall = wall;
|
||||||
|
if(direction != null)
|
||||||
|
exitDirection = Direction.invert(direction);
|
||||||
if(wall != null) {
|
if(wall != null) {
|
||||||
isSpawned = true;
|
isSpawned = true;
|
||||||
}
|
}
|
||||||
@ -60,18 +63,12 @@ public class Stargate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Direction getExitDirection() {
|
private Direction getExitDirection() {
|
||||||
if(currentWall.getAdjacentTile(Direction.EAST) == null)
|
return exitDirection;
|
||||||
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) {
|
public void teleport(PlayerBase player) {
|
||||||
player.setCurrentTile(other.getCurrentWall().getAdjacentTile(getExitDirection()));
|
if(isOpen())
|
||||||
|
player.setCurrentTile(other.getCurrentWall().getAdjacentTile(other.getExitDirection()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,7 +13,7 @@ public class Wall extends Tile {
|
|||||||
stargate.getCurrentWall().clearStargate();
|
stargate.getCurrentWall().clearStargate();
|
||||||
if (sg == null) {
|
if (sg == null) {
|
||||||
sg = stargate;
|
sg = stargate;
|
||||||
sg.setCurrentWall(this);
|
sg.setCurrentWall(this, direction);
|
||||||
Game.instance.updateDisplay();
|
Game.instance.updateDisplay();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -30,7 +30,7 @@ public class Wall extends Tile {
|
|||||||
|
|
||||||
public void clearStargate() {
|
public void clearStargate() {
|
||||||
if(sg != null) {
|
if(sg != null) {
|
||||||
sg.setCurrentWall(null);
|
sg.setCurrentWall(null, null);
|
||||||
sg = null;
|
sg = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user