예제 #1
0
 /**
  * Calls destroyRow for every row with index in the index-list given by call searchFullRows, and
  * calls levelmanager to handle scoring and levelling accordingly.
  *
  * @param levelManager The LevelManager whose points are updated while destroying rows.
  * @param table The table whose rows are affected.
  */
 public void destroyRows(LevelManager levelManager, Table table) {
   ArrayList<Integer> rowsToDestroy = searchFullRows(levelManager, table);
   if (rowsToDestroy.size() == 1) {
     levelManager.increasePoints(1);
   }
   if (rowsToDestroy.size() == 2) {
     levelManager.increasePoints(3);
   }
   if (rowsToDestroy.size() == 3) {
     levelManager.increasePoints(5);
   }
   if (rowsToDestroy.size() == 4) {
     levelManager.increasePoints(8);
   }
   for (Integer row : rowsToDestroy) {
     destroyRow(row, table);
   }
 }
예제 #2
0
 /**
  * Searches every row in Tables block array with no null values, and adds it's row-index to a
  * list.
  *
  * @param levelManager The LevelManager, whose destroyedRows is updated after collecting the
  *     correct rows.
  * @param table The Table whose rows are effected.
  * @return The list of indexes of rows with no null block -values.
  */
 public ArrayList<Integer> searchFullRows(LevelManager levelManager, Table table) {
   ArrayList<Integer> rowsToDestroy = new ArrayList<>();
   int piecesInRow = 0;
   for (int i = 0; i < table.getHeight(); i++) {
     for (int j = 0; j < table.getWidth(); j++) {
       if (table.getBlocks()[j][i] != null) {
         piecesInRow++;
       }
     }
     if (piecesInRow == table.getWidth()) {
       rowsToDestroy.add(i);
       levelManager.increaseRowsDestroyed();
     }
     piecesInRow = 0;
   }
   return rowsToDestroy;
 }
예제 #3
0
 public void create(AndroidGame game) {
   super.create(game);
   trace("SelectLevels");
   int offsetX = 64;
   int offsetY = 96;
   int perLine = 5;
   for (int i = perLine; i < manager.getLevelCount() + perLine; i++) {
     int posX = formOffsetX + i % perLine * offsetX;
     int posY = formOffsetY - (int) i / perLine * offsetY;
     String num = "" + (i - (perLine - 1));
     levelsbtn.add(
         new Button(
             posX,
             posY,
             num,
             new Sprite(new TextureRegion(new Texture("data/images/levelbtn.png"), 52, 52))));
   }
 }