cicaprojekt/cicaprojekt/Player.java

56 lines
1.4 KiB
Java

package cicaprojekt;
import java.util.ArrayList;
import java.util.List;
public class Player extends PlayerBase {
private List<ZPM> zpmContainer;
private Box boxLifted;
@Override
public void destroy() {
destroyed = true;
if(hasBox())
boxLifted.destroy();
Game.instance.playerDestroyed(this);
}
public Player(String name, Tile startTile, Direction startDirection) {
super(name, startTile, startDirection);
zpmContainer = new ArrayList<>();
}
public boolean hasBox() {
return (boxLifted != null);
}
public void boxLift() {
if(!isDestroyed())
boxLifted = currentTile.getAdjacentTile(facingDirection).getABox();
}
public void boxDrop() {
if(!isDestroyed()) {
Tile target = currentTile.getAdjacentTile(facingDirection);
if (target.boxPermission()) {
target.putABox(boxLifted);
boxLifted = null;
}
}
}
@Override
public void pickZPM(Tile tile) {
zpmContainer.add(tile.getZPMFromTile());
}
public void shootStargate(Stargate stargate) {
if(!isDestroyed())
this.currentTile.getAdjacentTile(facingDirection).spawnStargate(stargate, facingDirection);
}
public int getZPMCount(){
return zpmContainer.size();
}
}