- Change Stacker design

- Fix stack behavior
- Set status text at start
This commit is contained in:
Stone_Red
2022-06-02 17:32:04 +02:00
parent a20841491d
commit 5d1b6247d4
3 changed files with 22 additions and 12 deletions
@@ -47,6 +47,8 @@ public class StackBehaviour extends Component {
parent.setData(receiveDataKey1, null);
parent.setData(receiveDataKey2, null);
progress = 0;
} else if (parent.getData(receiveDataKey1) != null && parent.getData(receiveDataKey2) != null) {
progress++;
}
@@ -15,22 +15,30 @@ public class Stacker extends Entity {
public Stacker() {
super();
Polygon p = new Polygon();
p.getPoints().addAll(
Polygon p1 = new Polygon();
p1.getPoints().addAll(
Chunk.ENTITY_SIZE / 2d, 0.0,
0.0, (double) Chunk.ENTITY_SIZE,
(double) Chunk.ENTITY_SIZE, (double) Chunk.ENTITY_SIZE);
p.setFill(new Color(1, 0, 0, 1));
p1.setFill(Color.BLACK);
this.getChildren().addAll(p);
Polygon p2 = new Polygon();
p2.getPoints().addAll(
Chunk.ENTITY_SIZE / 2d, Chunk.ENTITY_SIZE / 2d,
(double) Chunk.ENTITY_SIZE, (double) Chunk.ENTITY_SIZE / 4d,
(double) Chunk.ENTITY_SIZE, (double) Chunk.ENTITY_SIZE / 4d * 3);
p2.setFill(Color.GRAY);
this.getChildren().addAll(p1, p2);
}
@SuppressWarnings("unused") // Called dynamically
public Stacker(BlockContainer blockContainer) {
this();
this.addBehaviour(new PlaceBehaviour(this, blockContainer));
this.addBehaviour(new StackBehaviour(this, blockContainer, "Input1", "Input2", "Output", 2));
this.addBehaviour(new OfferBehaviour(this, blockContainer, Direction.UP, "Output"));
this.addBehaviour(new ReceiveBehaviour(this, blockContainer, Direction.LEFT, "Input1"));
this.addBehaviour(new ReceiveBehaviour(this, blockContainer, Direction.DOWN, "Input1"));
this.addBehaviour(new ReceiveBehaviour(this, blockContainer, Direction.RIGHT, "Input2"));
}
}
@@ -15,6 +15,7 @@ public class HubManager {
public void initialize() {
GlobalEventHandler.addListener("hub:objectiveCompletion", this, this::objectiveCompletion);
newLevel();
GlobalEventHandler.trigger("hub:statusText", getStatusText());
}
private void newLevel() {
@@ -36,18 +37,17 @@ public class HubManager {
int layerCount = (level / 10) + 1;
int complexity = level % 10; //TODO: Make complexity make stuff more complex
//for (int l = 0; l < layerCount && l < 4; l++) {
for (int i = 0; i < 4; i++) {
//item.setPart(l, i, new Square(Color.RED));
item.setPart(0, i, new Square(Color.GREEN));
for (int l = 0; l < layerCount && l < 4; l++) {
for (int i = 0; i < 4; i++) {
item.setPart(l, i, new Square(Color.RED));
item.setPart(0, i, new Square(Color.GREEN));
}
}
//}
return item;
}
private String getStatusText() {
return String.format("%s\n%s/%s", level, objectiveCompletion, objectiveTotal);
return String.format("Level: %s\n%s/%s", level, objectiveCompletion, objectiveTotal);
}
private void objectiveCompletion(Item item) {