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(); super();
} }
@Override
public boolean isSteppable() {
if (boxStack.isEmpty())
return true;
return false;
}
@Override @Override
public void spawnStargate(cicaprojekt.Stargate stargate, Direction direction) { public void spawnStargate(cicaprojekt.Stargate stargate, Direction direction) {

View File

@ -5,6 +5,12 @@ public class Gap extends cicaprojekt.Tile {
super(); super();
} }
@Override
public boolean isSteppable()
{
return true;
}
@Override @Override
public void spawnStargate(cicaprojekt.Stargate stargate, Direction direction) { public void spawnStargate(cicaprojekt.Stargate stargate, Direction direction) {
adjacentTile.get(direction).spawnStargate(stargate, 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() { public boolean isOpen() {
return open; return open;
} }

View File

@ -32,12 +32,15 @@ public class PlayerBase implements Destroyable {
public void move(Direction direction) { public void move(Direction direction) {
this.setFacingDirection(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); if (adjtile.isSteppable())
setCurrentTile(tile); {
adjtile.onEntry(this);
setCurrentTile(adjtile);
}
} }
} }

View File

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

View File

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

View File

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