示例#1
0
  // add tiles adjacent to a given tile to the open list
  public void addAdjacentTilesToOpenList(Tile theTile) {
    if (theTile == null) {
      return;
    }

    int row = theTile.getRow();
    int col = theTile.getColumn();

    // Since we're working with an isometric grid, the north and south adjacent tiles are going to
    // have greater
    // row values in order to preserve the projection angle.
    addTile(
        tiles.get((row - 2) + "-" + col),
        theTile,
        GameConstants.CONST_MOVEMENT_COST_ORTHOGONAL); // north
    addTile(
        tiles.get((row - 1) + "-" + (col - 1)),
        theTile,
        GameConstants.CONST_MOVEMENT_COST_DIAGONAL); // north-west
    addTile(
        tiles.get(row + "-" + (col - 1)),
        theTile,
        GameConstants.CONST_MOVEMENT_COST_ORTHOGONAL); // west
    addTile(
        tiles.get((row + 1) + "-" + (col - 1)),
        theTile,
        GameConstants.CONST_MOVEMENT_COST_DIAGONAL); // south-west
    addTile(
        tiles.get((row + 2) + "-" + col),
        theTile,
        GameConstants.CONST_MOVEMENT_COST_ORTHOGONAL); // south
    addTile(
        tiles.get((row + 1) + "-" + (col + 1)),
        theTile,
        GameConstants.CONST_MOVEMENT_COST_DIAGONAL); // south-east
    addTile(
        tiles.get(row + "-" + (col + 1)),
        theTile,
        GameConstants.CONST_MOVEMENT_COST_ORTHOGONAL); // east
    addTile(
        tiles.get((row - 1) + "-" + (col + 1)),
        theTile,
        GameConstants.CONST_MOVEMENT_COST_DIAGONAL); // north-east
  }