示例#1
0
 public void incDifficulty() {
   DisplayMetrics displaymetrics = new DisplayMetrics();
   this.difficulty++;
   field.removeAll();
   activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
   this.height = (int) (displaymetrics.heightPixels - (displaymetrics.density * dp + 0.5f));
   this.width = displaymetrics.widthPixels;
   levelObject = new Level(levelGround, this.width, this.height, this.difficulty);
   levelObject.createLevel(levelGround);
   field.addObject(levelObject);
   figure.setScale(new BytehawksVector(levelObject.mScale, levelObject.mScale));
   figure.mPosition.set(figure.mScale.mX * 32, figure.mScale.mX * 32);
   figure.moveToDestination(new BytehawksVector(0, 0));
   figureLayout = new BytehawksSpriteLayout(activity.mGLSurfaceView, 64, 64, R.drawable.android);
   figure = new AndroidFigure(figureLayout, levelObject);
   field.addObject(figure);
   this.sequencebar.setMaxLength(levelObject.getMaxAllowedMoves());
   this.sequencebar.setMinLength(levelObject.getMinAllowedMoves());
   this.controlbar =
       new Controlbar(
           this.sequencebar,
           (ImageButton) activity.findViewById(R.id.c_down),
           (ImageButton) activity.findViewById(R.id.c_right),
           (Button) activity.findViewById(R.id.c_delete),
           (Button) activity.findViewById(R.id.c_start),
           figure,
           this);
   this.sequencebar.clearSequence();
   activity.setTitle(
       "Level:" + levelObject.getDifficulty() + " Max moves:" + levelObject.getMaxAllowedMoves());
 }
示例#2
0
  public GameUI(BytehawksActivity activity) {
    super(activity);
    this.activity = activity;
    DisplayMetrics displaymetrics = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    this.height = (int) (displaymetrics.heightPixels - (displaymetrics.density * dp + 0.5f));
    this.width = displaymetrics.widthPixels;
    field = addObject(new BytehawksObject());
    levelGround = new BytehawksTileBank(activity.mGLSurfaceView, R.drawable.tilemap, 5, 5, 32, 32);
    levelObject = new Level(levelGround, this.width, this.height, this.difficulty);
    levelObject.createLevel(levelGround);
    field.addObject(levelObject);
    figureLayout = new BytehawksSpriteLayout(activity.mGLSurfaceView, 64, 64, R.drawable.android);
    figure = new AndroidFigure(figureLayout, levelObject);
    field.addObject(figure);

    this.sequencebar =
        new Sequence(
            levelObject.getMinAllowedMoves(),
            levelObject.getMaxAllowedMoves(),
            activity,
            (LinearLayout) activity.findViewById(R.id.seqeunce_container));
    this.controlbar =
        new Controlbar(
            this.sequencebar,
            (ImageButton) activity.findViewById(R.id.c_down),
            (ImageButton) activity.findViewById(R.id.c_right),
            (Button) activity.findViewById(R.id.c_delete),
            (Button) activity.findViewById(R.id.c_start),
            figure,
            this);
    activity.setTitle(
        "Level:" + levelObject.getDifficulty() + " Max moves:" + levelObject.getMaxAllowedMoves());
  }
示例#3
0
  /**
   * Writes the passed level data into the passed file.
   *
   * @param level the level to be saved
   * @param PrintWriter the file to write to
   */
  private final void writeLevelToFile(Level level, PrintWriter file) {

    // Stores the board data of the level.
    List<String> boardData;

    file.println();
    file.println();
    file.println(level.getTitle());
    file.println();

    // Get the board data of the level.
    boardData = level.getBoardData();

    // Write the board to the file.
    for (String boardRow : boardData) {
      file.println(boardRow);
    }

    // Empty line between board and transformation data.
    file.println();

    // Save the transformation.
    if (!Transformation.getTransformationAsString().isEmpty()) {

      // Write the transformation string.
      file.write(Transformation.getTransformationAsString());

      // Write empty lines.
      file.println();
      file.println();
    }

    // Write the additional level data.
    if (level.getComment().length() > 0) {
      file.println(level.getComment());
    }

    Author author = level.getAuthor();
    if (!author.getName().equals(Texts.getText("unknown"))) {
      file.println("Author: " + author.getName());
    }
    if (author.getEmail().length() > 0) {
      file.println("Email: " + author.getEmail());
    }
    if (author.getWebsiteURL().length() > 0) {
      file.println("Homepage: " + author.getWebsiteURL());
    }
    if (author.getComment().length() > 0) {
      file.println("Author comment: " + author.getComment());
    }
    if (level.getDifficulty().length() > 0) {
      file.println("Difficulty: " + level.getDifficulty());
    }

    // Save the solution information.
    SolutionsManager solutions = level.getSolutionsManager();

    for (int solutionNo = 0; solutionNo < solutions.getSolutionCount(); solutionNo++) {
      Solution solution = solutions.getSolution(solutionNo);

      file.println();
      file.println("Solution " + solution.movesCount + "/" + solution.pushesCount);
      // FFS/hm: also write minor metrics?
      file.println(solution.lurd);
      if (solution.name.length() > 0) {
        file.println("Solution name: " + solution.name);
      }
      if (solution.isOwnSolution) {
        file.println("Own solution: yes");
      }
      if (solution.comment.length() > 0) {
        file.println("Solution comment: " + solution.comment);
        file.println("Solution comment end:");
      }
    }

    // Get the LURD-representation of the history.
    String historyLURD = level.getHistory().getHistoryAsSaveGame();

    // Save the history string if there is any
    if (!historyLURD.isEmpty()) {
      file.println();
      file.println("Savegame:");
      file.println(historyLURD);
    }
  }