Change means by which Planar Conquest "Chaos Wheel" animation was delaying its ending, so that it renders properly

This commit is contained in:
nefigah
2017-05-10 07:43:04 +00:00
parent 8f06aba64c
commit 5260786a87

View File

@@ -61,6 +61,9 @@ public class ConquestChaosWheel extends FOverlay {
private class WheelSpinAnimation extends ForgeAnimation { private class WheelSpinAnimation extends ForgeAnimation {
private final PhysicsObject rotationManager; private final PhysicsObject rotationManager;
private final float WAIT_DURATION = 1f;
private float timeSpentWaiting = 0f;
private boolean doneSpinning = false;
private WheelSpinAnimation() { private WheelSpinAnimation() {
float initialPosition = Aggregates.randomInt(1, 8) * 45f - 22.5f; //-22.5f because wheel image slightly rotated initially float initialPosition = Aggregates.randomInt(1, 8) * 45f - 22.5f; //-22.5f because wheel image slightly rotated initially
@@ -75,23 +78,27 @@ public class ConquestChaosWheel extends FOverlay {
@Override @Override
protected boolean advance(float dt) { protected boolean advance(float dt) {
rotationManager.advance(dt); if (!doneSpinning) {
Vector2 pos = rotationManager.getPosition(); rotationManager.advance(dt);
while (pos.x > 360f) { //loop back around Vector2 pos = rotationManager.getPosition();
pos.x -= 360f; while (pos.x > 360f) { //loop back around
pos.x -= 360f;
}
if (!rotationManager.isMoving()) {
doneSpinning = true;
}
return true;
} else {
// Wait a bit after the wheel stops spinning before ending
timeSpentWaiting += dt;
return timeSpentWaiting < WAIT_DURATION;
} }
return rotationManager.isMoving();
} }
@Override @Override
protected void onEnd(boolean endingAll) { protected void onEnd(boolean endingAll) {
ThreadUtil.delay(1000, new Runnable() { hide();
@Override callback.run(ChaosWheelOutcome.getWheelOutcome(getWheelRotation()));
public void run() {
hide();
callback.run(ChaosWheelOutcome.getWheelOutcome(getWheelRotation()));
}
});
} }
} }