Пример #1
0
 public final void ascend() {
   if (area.getType().equals(AreaType.CAVE)) {
     final CaveLevel newLevel = ((Cave) area).getLevelAbove((CaveLevel) location);
     final Tile newTile = newLevel.getStairsDownTile();
     move(newLevel, newTile);
   } else {
     throw new IllegalStateException("Not expecting ascend in area type:" + area.getType());
   }
 }
Пример #2
0
 public final void descend() {
   if (area.getType().equals(AreaType.CAVE)) {
     final CaveLevel newLevel = ((Cave) area).getLevelBelow((CaveLevel) location);
     final Tile newTile = newLevel.getStairsUpTile();
     System.out.println(newTile);
     move(newLevel, newTile);
   } else {
     throw new IllegalStateException();
   }
 }
Пример #3
0
  /**
   * Move to a given floor.
   *
   * @param l level
   */
  public final void goToFloor(final int l) {
    if (area.getType().equals(AreaType.CAVE)) {
      final CaveLevel newFloor = ((Cave) area).getLevel(l);
      Tile newTile;
      CaveLevel currentLevel = (CaveLevel) getLocation();

      if (currentLevel.getLevel() < l) {
        newTile = newFloor.getStairsUpTile();
      } else if (currentLevel.getLevel() < l) {
        newTile = newFloor.getStairsDownTile();
      } else {
        return;
      }
      move(newFloor, newTile);
    } else {
      throw new IllegalStateException(
          "Unexpected goToFloor() when in area of type:" + area.getType());
    }
  }