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