added timermanager

This commit is contained in:
Cedric Beck
2024-12-10 13:26:56 +01:00
parent 0c7030659a
commit 50f0cdfce6
2 changed files with 11 additions and 7 deletions

View File

@@ -21,6 +21,8 @@ public class MatrixAnimation extends ActionControl {
private List<ParticleEmitter> activeEmitter = new ArrayList<>();
private ParticleEmitter radarEmitter = null;
private float timeElapsed = 0f;
private final TimerManager timerManager = new TimerManager();
private enum MatrixState{
RADAR_ON,
@@ -30,6 +32,7 @@ private enum MatrixState{
}
private MatrixState state;
public MatrixAnimation(MdgaApp app, Vector3f radarPos, Runnable runnable){
super(runnable);
this.app = app;
@@ -50,18 +53,18 @@ protected void controlUpdate(float tpf) {
timeElapsed += tpf;
switch(state){
case RADAR_ON -> {
if(timeElapsed >= 2f){
state = MatrixState.RADAR_OFF;
timeElapsed = 0;
radarEmitter.setParticlesPerSec(0);
new Timer().schedule(new TimerTask() {
@Override
public void run() {
app.getRootNode().detachChild(radarEmitter);
}
}, 3000);
timerManager.addTask(3f, () -> app.enqueue(() -> {
app.getRootNode().detachChild(radarEmitter);
return null;
}));
}
}
case RADAR_OFF -> {
@@ -95,6 +98,7 @@ public void run() {
}
}
}
timerManager.update(tpf);
}
private void turnOff(){

View File

@@ -87,7 +87,7 @@ public Game() {
gameStatistics = new Statistic();
initializeDrawPile();
board = new Board();
die = new Die(1,2,3,4,
die = new Die(1,2,
5, 1,1,1
);
}