59 lines
1.3 KiB
Java
59 lines
1.3 KiB
Java
package cicaprojekt;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Stack;
|
|
|
|
public abstract class Tile {
|
|
protected Map<Direction, Tile> adjacentTile;
|
|
protected ZPM zpmOnTile;
|
|
protected Stack<Box> boxStack;
|
|
protected int x, y;
|
|
|
|
|
|
public Tile() {
|
|
adjacentTile = new HashMap<Direction, Tile>();
|
|
}
|
|
|
|
public Tile getAdjacentTile(Direction direction) {
|
|
return adjacentTile.get(direction);
|
|
}
|
|
|
|
public void setAdajacentTile(Tile newTile, Direction direction) {
|
|
adjacentTile.put(direction, newTile);
|
|
}
|
|
|
|
public abstract void spawnStargate(Stargate stargate, Direction direction);
|
|
|
|
public abstract void onEntry(PlayerBase playerBase);
|
|
|
|
public abstract void onExit(PlayerBase playerBase);
|
|
|
|
public void setZPMOnTile(ZPM zpm) {
|
|
zpmOnTile = zpm;
|
|
}
|
|
|
|
public ZPM getZPMFromTile() {
|
|
ZPM zpm = zpmOnTile;
|
|
zpmOnTile = null;
|
|
return zpm;
|
|
}
|
|
|
|
public void putABox(Box box) {
|
|
if (box == null)
|
|
return;
|
|
boxStack.push(box);
|
|
}
|
|
|
|
public Box getABox() {
|
|
if (boxStack.isEmpty())
|
|
return null;
|
|
return boxStack.pop();
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return String.format("%d, %d", x, y);
|
|
}
|
|
}
|