Refactored spawnStargate, with default implementation in base class
This commit is contained in:
parent
78b7645bfe
commit
314428b273
@ -4,9 +4,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Field extends cicaprojekt.Tile {
|
||||
private static int recursionLimit = 0;
|
||||
|
||||
|
||||
public Field() {
|
||||
super();
|
||||
}
|
||||
@ -19,13 +16,6 @@ public class Field extends cicaprojekt.Tile {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnStargate(cicaprojekt.Stargate stargate, Direction direction) {
|
||||
if (recursionLimit++ >= 10)
|
||||
this.adjacentTile.put(direction, new Wall());
|
||||
adjacentTile.get(direction).spawnStargate(stargate, direction);
|
||||
}
|
||||
|
||||
public void onEntry(PlayerBase playerBase) {
|
||||
if (boxStack.size() > 0)
|
||||
return;
|
||||
|
@ -11,11 +11,6 @@ public class Gap extends cicaprojekt.Tile {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnStargate(cicaprojekt.Stargate stargate, Direction direction) {
|
||||
adjacentTile.get(direction).spawnStargate(stargate, direction);
|
||||
}
|
||||
|
||||
public void onEntry(PlayerBase playerBase) {
|
||||
playerBase.destroy();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ public class Gate extends Tile {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnStargate(Stargate stargate, Direction direction) {
|
||||
if (this.open) adjacentTile.get(direction).spawnStargate(stargate, direction);
|
||||
}
|
||||
|
@ -51,10 +51,6 @@ public class Scale extends Field {
|
||||
stackChanged();
|
||||
}
|
||||
|
||||
public void spawnStargate(Stargate stargate, Direction direction) {
|
||||
adjacentTile.get(direction).spawnStargate(stargate, direction);
|
||||
}
|
||||
|
||||
private void stackChanged() {
|
||||
if (weight > threshold)
|
||||
gateConnected.setOpen(true);
|
||||
|
@ -41,7 +41,9 @@ public abstract class Tile {
|
||||
adjacentTile.put(direction, newTile);
|
||||
}
|
||||
|
||||
public abstract void spawnStargate(Stargate stargate, Direction direction);
|
||||
public void spawnStargate(Stargate stargate, Direction direction) {
|
||||
adjacentTile.get(direction).spawnStargate(stargate, direction);
|
||||
}
|
||||
|
||||
public abstract void onEntry(PlayerBase playerBase);
|
||||
|
||||
|
@ -1,18 +1,19 @@
|
||||
package cicaprojekt;
|
||||
|
||||
public class Wall extends Tile {
|
||||
private Stargate sg;
|
||||
private Stargate sg = null;
|
||||
|
||||
public Wall() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnStargate(Stargate stargate, Direction direction) {
|
||||
clearStargate();
|
||||
if (sg == null) {
|
||||
sg = stargate;
|
||||
sg.setCurrentWall(this);
|
||||
|
||||
Game.instance.updateDisplay();
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user