コード例 #1
0
ファイル: StateLoading.java プロジェクト: jinbing/Terasology
  @Override
  public void init(GameEngine engine) {
    EngineTime time = (EngineTime) CoreRegistry.get(Time.class);
    time.setPaused(true);
    time.setGameTime(0);

    CoreRegistry.get(Game.class).load(gameManifest);
    switch (netMode) {
      case CLIENT:
        initClient();
        break;
      default:
        initHost();
        break;
    }

    progress = 0;
    maxProgress = 0;
    for (LoadProcess process : loadProcesses) {
      maxProgress += process.getExpectedCost();
    }

    popStep();
    loadingScreen = nuiManager.setScreen("engine:loadingScreen", LoadingScreen.class);
    loadingScreen.updateStatus(current.getMessage(), current.getProgress());
  }
コード例 #2
0
ファイル: StateLoading.java プロジェクト: jinbing/Terasology
 @Override
 public void update(float delta) {
   long startTime = 1000 * Sys.getTime() / Sys.getTimerResolution();
   while (current != null && 1000 * Sys.getTime() / Sys.getTimerResolution() - startTime < 20) {
     if (current.step()) {
       popStep();
     }
   }
   if (current == null) {
     nuiManager.popScreen();
     CoreRegistry.get(GameEngine.class).changeState(new StateIngame());
   } else {
     float progressValue =
         (progress + current.getExpectedCost() * current.getProgress()) / maxProgress;
     loadingScreen.updateStatus(current.getMessage(), progressValue);
     nuiManager.update(delta);
   }
 }