예제 #1
0
  public void levelChange() {

    initSize();
    m_progress_bar.setTotalTime(Constant.TOTAL_TIME);
    _score.setLevel(_level);
    _score.reset();
    removeList.clear();
    m_game_state.setSize(grid_size);
    createGame();
    NumSprite.istouchable = true;
    m_progress_bar.resume();
  }
예제 #2
0
 public void restartGame() {
   removeMap();
   m_progress_bar.reset();
   m_progress_bar.start();
   removeList.clear();
   _score.reset();
   createGame();
 }
예제 #3
0
 private void createHUD() {
   gameHUD = new HUD();
   t_score_text =
       new Text(
           shift_row / 2,
           6 * GameActivity.getCameraHeight() / 7,
           m_resource_manager.font,
           "Score: 0123456789",
           new TextOptions(org.andengine.util.adt.align.HorizontalAlign.CENTER),
           m_vbom);
   t_score_text.setSkewCenter(0, 0);
   t_score_text.setText("Score: \n 0");
   t_score_text.setPosition(t_score_text.getWidth(), 6 * GameActivity.getCameraHeight() / 7);
   gameHUD.attachChild(t_score_text);
   m_camera.setHUD(gameHUD);
   _score = new Score(_level);
   _score.setTextScore(t_score_text);
 }
예제 #4
0
  public void timeOut() {
    // TODO Auto-generated method stub
    // Check if high score & display high score
    if (m_high_score.inHighscore(_score.getScore())) {
      //			Log.i(Constant.TAG, "High Score");
      // 			Display InputName dialog
      m_activity.runOnUiThread(
          new Runnable() {

            @Override
            public void run() {
              // TODO Auto-generated method stub
              new DialogName(m_activity).show();
            }
          });
    } else {
      displayGameOver();
    }
  }
예제 #5
0
 public void updateHighScore(String name) {
   Log.i(Constant.TAG, name);
   m_high_score.addScore(name, _score.getScore());
 }
예제 #6
0
  private void processArchivement() {
    // TODO Auto-generated method stub
    if (!archiveRow.isEmpty()) {
      for (int i = 0; i < archiveRow.size(); i++) {
        // remove row from hash
        for (int j = 0; j < grid_size; j++) {
          Point p = m_game_state.getPxPy(archiveRow.get(i), j);
          NumSprite sprite = _map.get(p);
          sprite.rotateSprite();
          _map.remove(p);
          removeList.add(m_game_state.getMatrix()[archiveRow.get(i)][j]);
        }
        m_game_state.removeRow(archiveRow.get(i));
        _score.addScore(1);
      }
    }

    if (!archiveCol.isEmpty()) {
      for (int i = 0; i < archiveCol.size(); i++) {
        // remove col from hash
        for (int j = 0; j < grid_size; j++) {
          Point p = m_game_state.getPxPy(j, archiveCol.get(i));
          NumSprite sprite = _map.get(p);
          sprite.rotateSprite();
          _map.remove(p);
          removeList.add(m_game_state.getMatrix()[j][archiveCol.get(i)]);
        }
        m_game_state.removeCol(archiveCol.get(i));
        _score.addScore(1);
      }
    }

    if (cross_down) {
      // remove item

      for (int j = 0; j < grid_size; j++)
        for (int i = 0; i < grid_size; i++) {
          if (i + j == grid_size - 1) {
            Point p = m_game_state.getPxPy(i, j);
            NumSprite sprite = _map.get(p);
            sprite.rotateSprite();
            _map.remove(p);
            removeList.add(m_game_state.getMatrix()[i][j]);
          }
        }

      m_game_state.removeCrossDown();
      _score.addScore(2);
    }

    if (cross_up) {
      // remove item
      for (int j = 0; j < grid_size; j++)
        for (int i = 0; i < grid_size; i++) {
          if (i == j) {
            Point p = m_game_state.getPxPy(i, j);
            NumSprite sprite = _map.get(p);
            sprite.rotateSprite();
            _map.remove(p);
            removeList.add(m_game_state.getMatrix()[i][j]);
          }
        }
      m_game_state.removeCrossUp();
      _score.addScore(2);
    }
    boolean wait = false;
    new Thread(
            new Runnable() {
              public void run() {
                /* Do things */
                try {
                  Thread.sleep(200);
                } catch (InterruptedException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                } /* Wait 1000 milliseconds */
                fillGameState();
                m_progress_bar.resume();
              }
            })
        .start();
  }