added method Tile.isSteppable() for obvious reasons...

This commit is contained in:
Kjistóf 2016-05-13 17:59:14 +02:00
parent 39a442ba14
commit 06f4e32942
7 changed files with 48 additions and 4 deletions

View File

@ -11,6 +11,13 @@ public class Field extends cicaprojekt.Tile {
super();
}
@Override
public boolean isSteppable() {
if (boxStack.isEmpty())
return true;
return false;
}
@Override
public void spawnStargate(cicaprojekt.Stargate stargate, Direction direction) {

View File

@ -5,6 +5,12 @@ public class Gap extends cicaprojekt.Tile {
super();
}
@Override
public boolean isSteppable()
{
return true;
}
@Override
public void spawnStargate(cicaprojekt.Stargate stargate, Direction direction) {
adjacentTile.get(direction).spawnStargate(stargate, direction);

View File

@ -24,6 +24,15 @@ public class Gate extends Tile {
}
}
@Override
public boolean isSteppable()
{
if (open)
return true;
return false;
}
public boolean isOpen() {
return open;
}

View File

@ -32,12 +32,15 @@ public class PlayerBase implements Destroyable {
public void move(Direction direction) {
this.setFacingDirection(direction);
Tile tile = this.getCurrentTile().getAdjacentTile(direction);
Tile adjtile = this.getCurrentTile().getAdjacentTile(direction);
if (tile != null)
if (adjtile != null)
{
tile.onEntry(this);
setCurrentTile(tile);
if (adjtile.isSteppable())
{
adjtile.onEntry(this);
setCurrentTile(adjtile);
}
}
}

View File

@ -14,6 +14,15 @@ public class Scale extends Field {
boxStack = new Stack<Box>();
}
@Override
public boolean isSteppable()
{
if (boxStack.isEmpty())
return true;
return false;
}
@Override
public void onEntry(PlayerBase playerBase) {
gateConnected.setOpen(true);

View File

@ -31,6 +31,8 @@ public abstract class Tile {
this.y = y;
}
public abstract boolean isSteppable();
public Tile getAdjacentTile(Direction direction) {
return adjacentTile.get(direction);
}

View File

@ -18,6 +18,14 @@ public class Wall extends Tile {
return;
}
@Override
public boolean isSteppable() {
if (sg != null)
return true;
return false;
}
public void clearStargate() {
if(sg != null) {
sg.setCurrentWall(null);