mirror of
https://github.com/Stefan-5422/School-Programming-Projekt-022022.git
synced 2026-09-10 07:36:05 +02:00
- Change Stacker design
- Fix stack behavior - Set status text at start
This commit is contained in:
@@ -47,6 +47,8 @@ public class StackBehaviour extends Component {
|
|||||||
parent.setData(receiveDataKey1, null);
|
parent.setData(receiveDataKey1, null);
|
||||||
parent.setData(receiveDataKey2, null);
|
parent.setData(receiveDataKey2, null);
|
||||||
|
|
||||||
|
progress = 0;
|
||||||
|
|
||||||
} else if (parent.getData(receiveDataKey1) != null && parent.getData(receiveDataKey2) != null) {
|
} else if (parent.getData(receiveDataKey1) != null && parent.getData(receiveDataKey2) != null) {
|
||||||
progress++;
|
progress++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,22 +15,30 @@ public class Stacker extends Entity {
|
|||||||
|
|
||||||
public Stacker() {
|
public Stacker() {
|
||||||
super();
|
super();
|
||||||
Polygon p = new Polygon();
|
Polygon p1 = new Polygon();
|
||||||
p.getPoints().addAll(
|
p1.getPoints().addAll(
|
||||||
Chunk.ENTITY_SIZE / 2d, 0.0,
|
Chunk.ENTITY_SIZE / 2d, 0.0,
|
||||||
0.0, (double) Chunk.ENTITY_SIZE,
|
0.0, (double) Chunk.ENTITY_SIZE,
|
||||||
(double) Chunk.ENTITY_SIZE, (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) {
|
public Stacker(BlockContainer blockContainer) {
|
||||||
this();
|
this();
|
||||||
this.addBehaviour(new PlaceBehaviour(this, blockContainer));
|
this.addBehaviour(new PlaceBehaviour(this, blockContainer));
|
||||||
this.addBehaviour(new StackBehaviour(this, blockContainer, "Input1", "Input2", "Output", 2));
|
this.addBehaviour(new StackBehaviour(this, blockContainer, "Input1", "Input2", "Output", 2));
|
||||||
this.addBehaviour(new OfferBehaviour(this, blockContainer, Direction.UP, "Output"));
|
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"));
|
this.addBehaviour(new ReceiveBehaviour(this, blockContainer, Direction.RIGHT, "Input2"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public class HubManager {
|
|||||||
public void initialize() {
|
public void initialize() {
|
||||||
GlobalEventHandler.addListener("hub:objectiveCompletion", this, this::objectiveCompletion);
|
GlobalEventHandler.addListener("hub:objectiveCompletion", this, this::objectiveCompletion);
|
||||||
newLevel();
|
newLevel();
|
||||||
|
GlobalEventHandler.trigger("hub:statusText", getStatusText());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void newLevel() {
|
private void newLevel() {
|
||||||
@@ -36,18 +37,17 @@ public class HubManager {
|
|||||||
int layerCount = (level / 10) + 1;
|
int layerCount = (level / 10) + 1;
|
||||||
int complexity = level % 10; //TODO: Make complexity make stuff more complex
|
int complexity = level % 10; //TODO: Make complexity make stuff more complex
|
||||||
|
|
||||||
//for (int l = 0; l < layerCount && l < 4; l++) {
|
for (int l = 0; l < layerCount && l < 4; l++) {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
//item.setPart(l, i, new Square(Color.RED));
|
item.setPart(l, i, new Square(Color.RED));
|
||||||
item.setPart(0, i, new Square(Color.GREEN));
|
item.setPart(0, i, new Square(Color.GREEN));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//}
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getStatusText() {
|
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) {
|
private void objectiveCompletion(Item item) {
|
||||||
|
|||||||
Reference in New Issue
Block a user