public void exit() {
   settings.save();
   saveServers();
   logger.info("Client beendet");
   logDate();
   System.exit(0);
 }
  private void updateRunning(float deltaTime) {
    List<TouchEvent> touchEvents = game.getInput().getTouchEvents();
    int len = touchEvents.size();
    for (int i = 0; i < len; i++) {
      TouchEvent event = touchEvents.get(i);
      if (event.type != TouchEvent.TOUCH_UP) continue;

      touchPoint.set(event.x, event.y);
      guiCam.touchToWorld(touchPoint);

      if (OverlapTester.pointInRectangle(pauseBounds, touchPoint)) {
        Assets.playSound(Assets.clickSound);
        state = GAME_PAUSED;
        return;
      }
    }

    world.update(deltaTime, game.getInput().getAccelX());
    if (world.score != lastScore) {
      lastScore = world.score;
      scoreString = "" + lastScore;
    }
    if (world.state == World.WORLD_STATE_NEXT_LEVEL) {
      state = GAME_LEVEL_END;
    }
    if (world.state == World.WORLD_STATE_GAME_OVER) {
      state = GAME_OVER;
      if (lastScore >= Settings.highscores[4]) scoreString = "new highscore: " + lastScore;
      else scoreString = "score: " + lastScore;
      Settings.addScore(lastScore);
      Settings.save(game.getFileIO());
    }
  }
  /*
   * Save game score
   * @see com.mygame.framework.Screen#pause()
   */
  @Override
  public void pause() {
    if (state == GameState.Running) state = GameState.Paused;

    if (world.gameOver || world.gameWon) {
      Settings.addScore(world.score);
      Settings.save(game.getFileIO());
    }
  }
Exemple #4
0
  private void btnOkActionPerformed(
      java.awt.event.ActionEvent evt) // GEN-FIRST:event_btnOkActionPerformed
      { // GEN-HEADEREND:event_btnOkActionPerformed
    Settings.objectDBUpdate = chkObjectDBUpdate.isSelected();
    Settings.useShaders = chkUseShaders.isSelected();
    Settings.fastDrag = chkFastDrag.isSelected();
    Settings.save();

    dispose();
  } // GEN-LAST:event_btnOkActionPerformed
  /*
   * Durante el periodo de juego en la actualizacion se realizan diferentes comprobaciones
   * y acciones.
   */
  private void updateRunning(float deltaTime) {
    // Capturamos los eventos de usuario con la pantalla
    List<TouchEvent> touchEvents = game.getInput().getTouchEvents();
    int len = touchEvents.size();
    for (int i = 0; i < len; i++) {
      TouchEvent event = touchEvents.get(i);
      // comprobamos que el evento actual es de levantar el dedo.
      if (event.type != TouchEvent.TOUCH_UP) continue;

      // inicializamos el punto de pantalla
      touchPoint.set(event.x, event.y);
      // lo convertimos en coordenadas del juego.
      guiCam.touchToWorld(touchPoint);

      // Comprobamos si la pulsacion ha sido sobre el icono de pausa.
      if (OverlapTester.pointInRectangle(pauseBounds, touchPoint)) {
        // En caso afirmativo cambiamos el estado del juego y reproducimos un sonido.
        Assets.playSound(Assets.clickSound);
        state = GAME_PAUSED;
        return;
      }
      if (OverlapTester.pointInRectangle(moveRightBounds, touchPoint)) {
        world.bob.velocity.x = 10 / 10 * Bob.BOB_MOVE_VELOCITY;
        world.bob.update(deltaTime);
      }
      if (OverlapTester.pointInRectangle(moveLeftBounds, touchPoint)) {
        world.bob.velocity.x = -10 / 10 * Bob.BOB_MOVE_VELOCITY;
        world.bob.update(deltaTime);
      }
    }

    // Actualizamos la puntuacion actual
    world.update(deltaTime, game.getInput().getAccelX());
    if (world.score != lastScore) {
      lastScore = world.score;
      scoreString = "" + lastScore;
    }
    // Comprobamos si hemos llegado al destino, para finalizar el juego.
    if (world.state == World.WORLD_STATE_NEXT_LEVEL) {
      state = GAME_LEVEL_END;
    }
    // Comprobamos si el estado del mundo es game over, para finalizarel juego.
    if (world.state == World.WORLD_STATE_GAME_OVER) {
      state = GAME_OVER;
      // Si la puntuacion obtenida es mejor a las existintes lo indicamos
      if (lastScore >= Settings.highscores[4]) scoreString = "nuevo record: " + lastScore;
      else scoreString = "puntos: " + lastScore;
      // Actualizamos las puntuaciones y guardamos el fichero de propiedades.
      Settings.addScore(lastScore);
      Settings.save(game.getFileIO());
    }
  }
  private void updateRunning(float deltaTime) {
    if (Gdx.input.justTouched()) {
      guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));

      if (OverlapTester.pointInRectangle(pauseBounds, touchPoint.x, touchPoint.y)) {
        Assets.playSound(Assets.clickSound);
        state = GAME_PAUSED;
        return;
      }
    }

    ApplicationType appType = Gdx.app.getType();

    // should work also with Gdx.input.isPeripheralAvailable(Peripheral.Accelerometer)
    if (appType == ApplicationType.Android || appType == ApplicationType.iOS) {
      world.update(deltaTime, Gdx.input.getAccelerometerX());
    } else {
      float accel = 0;
      if (Gdx.input.isKeyPressed(Keys.DPAD_LEFT)) accel = 5f;
      if (Gdx.input.isKeyPressed(Keys.DPAD_RIGHT)) accel = -5f;
      world.update(deltaTime, accel);
    }
    if (world.score != lastScore) {
      lastScore = world.score;
      scoreString = "SCORE: " + lastScore;
    }
    if (world.state == World.WORLD_STATE_NEXT_LEVEL) {
      state = GAME_LEVEL_END;
    }
    if (world.state == World.WORLD_STATE_GAME_OVER) {
      state = GAME_OVER;
      if (lastScore >= Settings.highscores[4]) scoreString = "NEW HIGHSCORE: " + lastScore;
      else scoreString = "SCORE: " + lastScore;
      Settings.addScore(lastScore);
      Settings.save();
    }
  }
Exemple #7
0
 public void setHeight(String height) {
   this.height = height;
   Settings.save();
 }
Exemple #8
0
 public void setMaxMemory(String maxMemory) {
   this.maxMemory = maxMemory;
   Settings.save();
 }
  @Override
  public void update(float deltaTime) {
    List<Input.TouchEvent> touchEvents = game.getInput().getTouchEvents();

    int touchEventsListSize = touchEvents.size();
    Log.i("MainMenuScreen", "size is " + String.valueOf(touchEventsListSize));
    // TODO: Keep or remove sync below
    synchronized (touchEvents) {
      // removed toucheventslistsize, used size() instead
      for (int touchEventIndex = 0; touchEventIndex < touchEvents.size(); touchEventIndex++) {
        Input.TouchEvent event = touchEvents.get(touchEventIndex);
        if (event.type == Input.TouchEvent.TOUCH_DOWN) {
          // If PLAY button pressed, start game
          if (!at_settings && inBounds(event, 95, 468, 240, 76)) {
            game.setScreen(new GameScreen(game));
          }
          // If SETTINGS button pressed, update at_settings to draw Settings window
          int SETTINGS_CHANGE_X_POSITION = 94;
          int SETTINGS_CHANGE_Y_POSITION = 418;
          int SETTINGS_CHANGE_WIDTH = 294;
          int SETTINGS_CHANGE_HEIGHT = 68;
          int SETTINGS_BACK_X_POSITION = 192;
          int SETTINGS_BACK_Y_POSITION = 522;
          int SETTINGS_BACK_WIDTH = 88;
          int SETTINGS_BACK_HEIGHT = 66;
          if (!at_settings && inBounds(event, 95, 680, 290, 76)) {
            at_settings = true;
            // If Settings window open, check for button press to enable/disable sound and
            // update Settings variable
          } else if (at_settings
              && Settings.soundEnabled
              && inBounds(
                  event,
                  SETTINGS_CHANGE_X_POSITION,
                  SETTINGS_CHANGE_Y_POSITION,
                  SETTINGS_CHANGE_WIDTH,
                  SETTINGS_CHANGE_HEIGHT)) {
            Settings.soundEnabled = false;
          } else if (at_settings
              && !Settings.soundEnabled
              && inBounds(
                  event,
                  SETTINGS_CHANGE_X_POSITION,
                  SETTINGS_CHANGE_Y_POSITION,
                  SETTINGS_CHANGE_WIDTH,
                  SETTINGS_CHANGE_HEIGHT)) {
            Settings.soundEnabled = true;
            // If Settings window open, check for back button press or SETTINGS button press to
            // update appropriate variable and save Settings file
          } else if (at_settings
                  && inBounds(
                      event,
                      SETTINGS_BACK_X_POSITION,
                      SETTINGS_BACK_Y_POSITION,
                      SETTINGS_BACK_WIDTH,
                      SETTINGS_BACK_HEIGHT)
              || inBounds(event, 95, 680, 290, 76)) {
            at_settings = false;
            Settings.save(game.getFileIO());
          }
          // If RANKS button pressed, update at_leaderboards to cause Google API to open
          // leaderboards window
          // CHANGE WHEN LEADERBOARDS FULLY IMPLEMENTED
          if (!at_settings && inBounds(event, 95, 572, 250, 76)) {
            at_leaderboards = true;
          }

          if (!at_settings && inBounds(event, 95, 572, 250, 76)) {
            // TODO: Uncomment below
            // game.goToLeaderboard();
            Log.i("MainMenuS", "went to Leaderboards");
          }
        }
      }
    }
  }
Exemple #10
0
 public void setServerIp(String serverIp) {
   this.serverIp = serverIp;
   Settings.save();
 }
Exemple #11
0
 public void setCanceledWrapper(boolean canceledWrapper) {
   this.canceledWrapper = canceledWrapper;
   Settings.save();
 }
Exemple #12
0
 public void setPermSize(String permSize) {
   this.permSize = permSize;
   Settings.save();
 }
Exemple #13
0
 public void setLauncherVisibility(LauncherVisibility launcherVisibility) {
   this.launcherVisibility = launcherVisibility.ordinal();
   Settings.save();
 }
 /**
  * Since we can change the sound settings on this Screen, we want to make sure that the settings
  * are persisted
  */
 @Override
 public void pause() {
   // Write the current settings to the file in external storages
   Settings.save(game.getFileIO());
 }
  BARControl(String[] args) {
    try {
      // load settings
      Settings.load();

      // parse arguments
      parseArguments(args);

      // init display
      display = new Display();

      // connect to server
      LoginData loginData = new LoginData(serverName, serverPort, serverTLSPort);
      boolean connectOkFlag = false;
      if ((loginData.serverName != null)
          && !loginData.serverName.equals("")
          && (loginData.password != null)
          && !loginData.password.equals("")
          && !loginDialogFlag) {
        // connect to server with preset data
        try {
          BARServer.connect(
              loginData.serverName,
              loginData.port,
              loginData.tlsPort,
              loginData.password,
              serverKeyFileName);
          connectOkFlag = true;
        } catch (ConnectionError error) {
        }
      }
      while (!connectOkFlag) {
        // get login data
        if (!getLoginData(loginData)) {
          System.exit(0);
        }
        if ((loginData.port == 0) && (loginData.tlsPort == 0)) {
          throw new Error("Cannot connect to server. No server ports specified!");
        }
        /// ??? host name scheck

        // connect to server
        try {
          BARServer.connect(
              loginData.serverName,
              loginData.port,
              loginData.tlsPort,
              loginData.password,
              serverKeyFileName);
          connectOkFlag = true;
        } catch (ConnectionError error) {
          if (!Dialogs.confirmError(
              new Shell(),
              "Connection fail",
              "Error: " + error.getMessage(),
              "Try again",
              "Cancel")) {
            System.exit(1);
          }
        }
      }

      // open main window
      createWindow();
      createTabs();
      createMenu();

      // run
      run();

      // disconnect
      BARServer.disconnect();

      // save settings
      Settings.save();
    } catch (org.eclipse.swt.SWTException exception) {
      System.err.println("ERROR graphics: " + exception.getCause());
      if (debug) {
        for (StackTraceElement stackTraceElement : exception.getStackTrace()) {
          System.err.println("  " + stackTraceElement);
        }
      }
    } catch (CommunicationError communicationError) {
      System.err.println("ERROR communication: " + communicationError.getMessage());
    } catch (AssertionError assertionError) {
      System.err.println("INTERNAL ERROR: " + assertionError.toString());
      for (StackTraceElement stackTraceElement : assertionError.getStackTrace()) {
        System.err.println("  " + stackTraceElement);
      }
      System.err.println("");
      System.err.println("Please report this assertion error to [email protected].");
    } catch (InternalError error) {
      System.err.println("INTERNAL ERROR: " + error.getMessage());
    } catch (Error error) {
      System.err.println("ERROR: " + error.getMessage());
      if (debug) {
        for (StackTraceElement stackTraceElement : error.getStackTrace()) {
          System.err.println("  " + stackTraceElement);
        }
      }
    }
  }
Exemple #16
0
 public void setFullscreen(boolean fullscreen) {
   this.fullscreen = fullscreen;
   Settings.save();
 }
Exemple #17
0
 public void setDebug(boolean debug) {
   this.debug = debug;
   Settings.save();
 }
Exemple #18
0
 public Profile setGameDir(String gameDir) {
   this.gameDir = gameDir;
   Settings.save();
   return this;
 }
Exemple #19
0
 public void setGameDirType(GameDirType gameDirType) {
   this.gameDirType = gameDirType.ordinal();
   Settings.save();
 }
Exemple #20
0
 public void setJavaDir(String javaDir) {
   this.javaDir = javaDir;
   Settings.save();
 }
Exemple #21
0
 public void setMinecraftArgs(String minecraftArgs) {
   this.minecraftArgs = minecraftArgs;
   Settings.save();
 }
Exemple #22
0
 public void setJava(Java java) {
   int idx = Settings.JAVA.indexOf(java);
   if (idx == -1) return;
   this.java = java.getName();
   Settings.save();
 }
Exemple #23
0
 public void setWrapperLauncher(String wrapperLauncher) {
   this.wrapperLauncher = wrapperLauncher;
   Settings.save();
 }
Exemple #24
0
 public void setJavaArgs(String javaArgs) {
   this.javaArgs = javaArgs;
   Settings.save();
 }
 @Override
 public void pause() {
   Settings.save(game.getFileIO());
 }
Exemple #26
0
 public void save() {
   Settings.save(this);
 }