Пример #1
0
  @Override
  public void update() {
    if (readyToConnect && !connectStarted) {
      Client.reset(new LanClient());
      Input.setup(Client.get());
      connectStarted = true;
    }
    if (Input.isActive(Commands.get(Aigilas.Commands.Start), 0)) {
      if (ipIn.getText() != null && !ipIn.getText().isEmpty()) {
        String[] contents = ipIn.getText().split(":");
        String address = contents[0];
        if (contents.length > 1) {
          int port = Parse.inte(contents[1]);
          Config.get().setPort(port);
        }

        label.setText(waitMessage);
        Config.get().setServerIp(address);
        readyToConnect = true;
        ipIn.setVisible(false);
      }
    }
    if (Client.get().isGameStarting()) {
      for (int ii = 0; ii < Client.get().getPlayerCount(); ii++) {
        Input.setContext(Contexts.get(Sps.Contexts.Free), ii);
      }
      StateManager.loadState(new LoadingState());
    }
  }
Пример #2
0
 @Override
 public void create() {
   Sps.setup();
   Renderer.get().setWindowsBackground(Color.BLACK);
   Renderer.get().setStrategy(new FrameStrategy());
   Renderer.get().setRefreshInstance(this);
   Client.reset(new LocalClient());
   Input.get().setup(Client.get());
   SpriteSheetManager.setup(SpriteTypes.getDefs());
   StateManager.loadState(new MainMenuState());
   ParticleEngine.reset();
   MusicPlayer.get(new DefaultMusicPlayer());
   StateManager.loadContent();
 }
Пример #3
0
  public JoinServerAsGuestState() {
    Input.setContext(Contexts.get(Sps.Contexts.Non_Free), Client.get().getFirstPlayerIndex());
    stage = new Stage();

    Gdx.input.setInputProcessor(stage);

    Label.LabelStyle lblStyle = new Label.LabelStyle(Assets.get().font(), Color.WHITE);
    label = new Label("Server IP:", lblStyle);

    TextField.TextFieldStyle style = new TextField.TextFieldStyle();
    style.font = Assets.get().font();
    style.cursor = UiAssets.getNewCursor();

    style.fontColor = Color.WHITE;
    style.background = UiAssets.getNewBtnBg();
    ipIn = new TextField("", style);
    stage.setKeyboardFocus(ipIn);

    ipIn.addListener(
        new ChangeListener() {

          @Override
          public void changed(ChangeEvent changeEvent, Actor actor) {
            ipIn.setBlinkTime(1);
          }
        });

    Table table = new Table();
    table.setFillParent(true);
    table.add(label);
    table.add(ipIn).minWidth(300);

    stage.addActor(table);
  }
Пример #4
0
  @Override
  public void render() {
    try {
      // $$$ Logger.devConsole("" + Gdx.graphics.getFramesPerSecond() + ": " +
      // Gdx.graphics.getDeltaTime());

      // Update
      Input.get().update();
      if (Input.get()
          .isActive(
              sps.bridge.Commands.get(Commands.ToggleDevConsole),
              Client.get().getFirstPlayerIndex())) {
        DevConsole.get().toggle();
      }
      if (Input.get()
          .isActive(sps.bridge.Commands.get(Commands.Back), Client.get().getFirstPlayerIndex())) {
        StateManager.loadState(new MainMenuState());
      }
      if (Input.get()
          .isActive(sps.bridge.Commands.get(Commands.Music), Client.get().getFirstPlayerIndex())) {
        MusicPlayer.get().toggle();
      }
      if (Input.get()
          .isActive(
              sps.bridge.Commands.get(Commands.ToggleFullScreen),
              Client.get().getFirstPlayerIndex())) {
        Renderer.get().toggleFullScreen();
      }

      StateManager.asyncUpdate();

      if (Client.get().nextTurn()) {
        ParticleEngine.update();
        StateManager.update();
        Client.get().prepareForNextTurn();
      } else {
        Client.get().heartBeat();
      }
      if (!IsRunning) {
        System.exit(0);
      }

      TextPool.get().update();

      // Render
      Renderer.get().begin();
      StateManager.draw();
      ParticleEngine.draw();
      HudRenderer.get().draw();
      TextPool.get().draw();
      DevConsole.get().draw();
      Renderer.get().end();
    } catch (Exception e) {
      Logger.exception(e);
    }
  }