This commit is contained in:
Tobydrama 2020-04-14 12:37:03 +02:00
commit 1b04ed462c

View File

@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.utils.viewport.ExtendViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import inf112.fiasko.roborally.element_properties.GameState;
import inf112.fiasko.roborally.game_wrapper.RoboRallyWrapper;
/**
@ -18,6 +19,8 @@ public class LoadingScreen extends AbstractScreen {
private long startTime;
private GameState initialGameState;
/**
* Instantiates a new loading screen
* @param roboRallyWrapper The Robo Rally wrapper which is parent of this screen
@ -44,19 +47,24 @@ public class LoadingScreen extends AbstractScreen {
roboRallyWrapper.batch.end();
long time = System.currentTimeMillis();
//TODO: Allow to set any condition and next screen
if (time - startTime > 5000){
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getBoardActiveScreen(this.roboRallyWrapper));
if (roboRallyWrapper.roboRallyGame.getGameState() != initialGameState) {
handleScreenChange();
}
}
private void handleScreenChange() {
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getBoardActiveScreen(this.roboRallyWrapper));
}
@Override
public void resize(int width, int height) {
viewport.update(width, height);
}
@Override
public void show(){
public void show() {
startTime = System.currentTimeMillis();
initialGameState = roboRallyWrapper.roboRallyGame.getGameState();
}
}