예제 #1
0
  private void processGameState(GameStateResponseMessage message) {
    final long[] alivePlayerIds = message.getAlivePlayers();
    final Vector3f[] alivePlayerPositions = message.getAlivePlayerPositions();

    for (int i = 0; i < alivePlayerIds.length; i++) {
      final long playerId = alivePlayerIds[i];
      final Vector3f position = alivePlayerPositions[i];

      final Player player = playersContainer.getPlayer(playerId);

      if (player != null) {
        enqueueHelper.enqueue(
            new Callable<Void>() {
              @Override
              public Void call() throws Exception {
                eventBus.fireEvent(new RespawnPlayerEvent(player, position, Vector3f.UNIT_Z));
                return null;
              }
            });
      } else {
        log.warn("Player with id " + playerId + " not found!");
      }
    }

    enqueueHelper.enqueue(
        new Callable<Void>() {

          @Override
          public Void call() throws Exception {
            loadingState.setEnabled(false);
            ingameState.setEnabled(true);
            spawnMenuState.setEnabled(true);

            bulletAppState.setEnabled(true);
            syncState.setEnabled(true);

            return null;
          }
        });
  }
예제 #2
0
  private void closeGame(boolean isServerRestart) {
    try {
      if (!isServerRestart) {
        clientState.cleanup();
        setupNetwork();
      }

      playersContainer.clear();
      syncState.cleanup();

      teamsContainer.clear();

      bulletAppState.setEnabled(false);
      physicsWrapper.cleanup(ingameState.getRootNode());

      ingameState.cleanup();

      initInput();
      stateManager.detach(hudState);
      stateManager.detach(spawnMenuState);
      stateManager.detach(scoreBoardState);

      ingameState.setEnabled(false);
      loadingState.setEnabled(false);
      syncState.setEnabled(false);

      localPlayer = null;

      if (endState != null) {
        stateManager.detach(endState);
        endState = null;
      }

      menuState.setEnabled(!isServerRestart);
    } catch (IllegalAccessException e) {
      // TODO
      e.printStackTrace();
    }
  }