Refactored spawnStargate, with default implementation in base class

This commit is contained in:
Bokros Bálint 2016-05-13 18:14:14 +02:00 committed by Kjistóf
parent 78b7645bfe
commit 314428b273
6 changed files with 7 additions and 22 deletions

View File

@ -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;

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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;