Пример #1
0
  // Обновляет положение палуб взависимости от координат и поворота
  public void update() {
    if (field == null) return;

    if (rotated) {
      int x = this.x;
      for (int i = 0; i < decks.size(); i++) {
        field.getCell(x, y).addDeck(decks.get(i));
        x++;
      }
    } else {
      int y = this.y;
      for (int i = 0; i < decks.size(); i++) {
        field.getCell(x, y).addDeck(decks.get(i));
        y++;
      }
    }
  }
Пример #2
0
  public void selectCell(int row, int col) {
    if (!field.cellExists(row, col)) {
      clearSelectedCell();
      return;
    }

    Cell currentCell = field.getCell(row, col);

    if (!currentCell.isEmpty()) {
      selectedCell = currentCell;
    } else if (!noSelectedCell() && currentCell.isEmpty()) {
      moveBallAction.moveBall(selectedCell, currentCell);
      clearSelectedCell();
    }
  }
Пример #3
0
 public boolean hasCollision(Field f) {
   Cell cell = f.getCell(this.location.x, this.location.y);
   if (cell == null) return false;
   return (this.state == CellType.SHAPE && (cell.isSolid() || cell.isBlock()));
 }