Scale - finished
This commit is contained in:
parent
fd64fd9165
commit
1c8566d96c
@ -4,7 +4,6 @@ import java.util.Stack;
|
||||
|
||||
public class Scale extends Field {
|
||||
private Gate gateConnected;
|
||||
private Stack<Pickable> itemsOnTile;
|
||||
private int threshold;
|
||||
private int weight;
|
||||
|
||||
@ -12,28 +11,34 @@ public class Scale extends Field {
|
||||
public Scale(Gate gate, int threshold){
|
||||
gateConnected = gate;
|
||||
this.threshold = threshold;
|
||||
itemsOnTile = new Stack<Pickable>();
|
||||
boxStack = new Stack<Box>();
|
||||
}
|
||||
|
||||
public void onEntry() {
|
||||
@Override
|
||||
public void onEntry(PlayerBase playerBase) {
|
||||
gateConnected.setOpen(true);
|
||||
}
|
||||
|
||||
public void onExit() {
|
||||
@Override
|
||||
public void onExit(PlayerBase playerBase) {
|
||||
gateConnected.setOpen(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pickable removeItemFromTile() {
|
||||
weight -= itemsOnTile.peek().weight();
|
||||
public Box getABox() {
|
||||
if(boxStack.isEmpty())
|
||||
return null;
|
||||
weight -= boxStack.peek().weight();
|
||||
stackChanged();
|
||||
return itemsOnTile.pop();
|
||||
return boxStack.pop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemOnTile(Pickable item) {
|
||||
itemsOnTile.push(item);
|
||||
weight += item.weight();
|
||||
public void putABox(Box box) {
|
||||
if(box == null)
|
||||
return;
|
||||
boxStack.push(box);
|
||||
weight += box.weight();
|
||||
stackChanged();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user