now "flying" Stargates destroy Replicators, and belonging bugfix

Game.playerBaseDestroyed() is not called everythime a PlayerBase is
destroyed.
This commit is contained in:
Kjistóf 2016-05-13 23:52:10 +02:00
parent 7d059701cc
commit 89a1da497f
9 changed files with 16 additions and 4 deletions

View File

@ -17,6 +17,7 @@ public class Field extends cicaprojekt.Tile {
} }
public void onEntry(PlayerBase playerBase) { public void onEntry(PlayerBase playerBase) {
super.onEntry(playerBase);
if (boxStack.size() > 0) if (boxStack.size() > 0)
return; return;
playerBase.setCurrentTile(this); playerBase.setCurrentTile(this);

View File

@ -12,7 +12,9 @@ public class Gap extends cicaprojekt.Tile {
} }
public void onEntry(PlayerBase playerBase) { public void onEntry(PlayerBase playerBase) {
super.onEntry(playerBase);
playerBase.destroy(); playerBase.destroy();
Game.instance.playerBaseDestroyed(playerBase);
} }
public void onExit(PlayerBase playerBase) throws IllegalStateException { public void onExit(PlayerBase playerBase) throws IllegalStateException {

View File

@ -13,6 +13,7 @@ public class Gate extends Tile {
} }
public void onEntry(PlayerBase playerBase) { public void onEntry(PlayerBase playerBase) {
super.onEntry(playerBase);
if (open) { if (open) {
playerBase.setCurrentTile(this); playerBase.setCurrentTile(this);
} else } else

View File

@ -20,7 +20,6 @@ public class PlayerBase implements Destroyable {
public void destroy() { public void destroy() {
destroyed = true; destroyed = true;
Game.instance.playerBaseDestroyed(this);
} }
public Tile getCurrentTile() { public Tile getCurrentTile() {

View File

@ -25,6 +25,7 @@ public class Scale extends Field {
@Override @Override
public void onEntry(PlayerBase playerBase) { public void onEntry(PlayerBase playerBase) {
super.onEntry(playerBase);
gateConnected.setOpen(true); gateConnected.setOpen(true);
} }

View File

@ -58,6 +58,7 @@ public class Stargate {
public boolean isSpawned() { public boolean isSpawned() {
return isSpawned; return isSpawned;
} }
public boolean isOpen() { public boolean isOpen() {
if(isSpawned & other.isSpawned) if(isSpawned & other.isSpawned)
return other.getCurrentWall().getAdjacentTile(other.getExitDirection()).isSteppable(); return other.getCurrentWall().getAdjacentTile(other.getExitDirection()).isSteppable();

View File

@ -10,6 +10,7 @@ public abstract class Tile {
protected Stack<Box> boxStack; protected Stack<Box> boxStack;
protected int y = -666; protected int y = -666;
protected int x = -666; protected int x = -666;
protected PlayerBase playerBaseOnTile = null;
public Tile() { public Tile() {
@ -42,10 +43,15 @@ public abstract class Tile {
} }
public void spawnStargate(Stargate stargate, Direction direction) { public void spawnStargate(Stargate stargate, Direction direction) {
if (playerBaseOnTile != null && playerBaseOnTile.name.equals("Replicator"))
playerBaseOnTile.destroy();
adjacentTile.get(direction).spawnStargate(stargate, direction); adjacentTile.get(direction).spawnStargate(stargate, direction);
} }
public abstract void onEntry(PlayerBase playerBase); public void onEntry(PlayerBase playerBase) {
playerBaseOnTile = playerBase;
}
public abstract void onExit(PlayerBase playerBase); public abstract void onExit(PlayerBase playerBase);

View File

@ -36,6 +36,7 @@ public class Wall extends Tile {
} }
public void onEntry(PlayerBase playerBase) { public void onEntry(PlayerBase playerBase) {
super.onEntry(playerBase);
if (sg == null) { if (sg == null) {
return; return;
} else { } else {

View File

@ -2,8 +2,8 @@
150 150
W W W W W W W W W W
W R W F W W R F F W
W X O F W W F O F W
W F F Z W W F F Z W
W W W W W W W W W W