Beispiel #1
0
 private void renderFullBoardRecursive(
     Graphics g, AbstractList<Space> finished, Space origin, int x, int y, Board b) {
   renderSpace(g, origin, x, y);
   Board.Coordinates coord = b.new Coordinates(x, y);
   Developer dev = b.getDeveloper(coord);
   if (dev != null) {
     renderDeveloper(dev, x, y);
   }
   if (origin.getTop() != null && !finished.contains(origin.getTop())) {
     finished.add(origin.getTop());
     renderFullBoardRecursive(g, finished, origin.getTop(), x, y - 1, b);
   }
   if (origin.getLeft() != null && !finished.contains(origin.getLeft())) {
     finished.add(origin.getLeft());
     renderFullBoardRecursive(g, finished, origin.getLeft(), x - 1, y, b);
   }
   if (origin.getRight() != null && !finished.contains(origin.getRight())) {
     finished.add(origin.getRight());
     renderFullBoardRecursive(g, finished, origin.getRight(), x + 1, y, b);
   }
   if (origin.getBottom() != null && !finished.contains(origin.getBottom())) {
     finished.add(origin.getBottom());
     renderFullBoardRecursive(g, finished, origin.getBottom(), x, y + 1, b);
   }
   int givenHeight = origin.getHeight();
   if (origin.getHeight() > 0 && origin.getTile().getType() == TileType.PALACE) {
     givenHeight = ((PalaceTile) origin.getTile()).getLevel();
   }
   spaceHeights[x][y] = givenHeight;
   renderText(
       g, "" + givenHeight, (x + 1) * TILE_WIDTH, (y + 1) * TILE_HEIGHT + g.getFont().getSize());
 }
Beispiel #2
0
 public void renderFullBoard(Space origin, Board b) {
   Image currentTile;
   for (int x = 0; x < boardWidth; x++) {
     if (x == 0) {
       for (int y = 0; y < boardHeight; y++) {
         currentTile = lowlands;
         if (b.isMountainSpace(b.new Coordinates(x, y))) {
           currentTile = mountians;
         }
         cachedGraphics.drawImage(
             currentTile, x * TILE_WIDTH, (y + 1) * TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, this);
       }
     } else if (x == boardWidth - 1) {
       for (int y = 0; y < boardHeight; y++) {
         currentTile = lowlands;
         if (b.isMountainSpace(b.new Coordinates(x, y))) {
           currentTile = mountians;
         }
         cachedGraphics.drawImage(
             currentTile,
             (x + 2) * TILE_WIDTH,
             (y + 1) * TILE_HEIGHT,
             TILE_WIDTH,
             TILE_HEIGHT,
             this);
       }
     } else {
       currentTile = lowlands;
       if (b.isMountainSpace(b.new Coordinates(x, 0))) {
         currentTile = mountians;
       }
       cachedGraphics.drawImage(
           currentTile, (x + 1) * TILE_WIDTH, 0, TILE_WIDTH, TILE_HEIGHT, this);
       currentTile = lowlands;
       if (b.isMountainSpace(b.new Coordinates(x, boardHeight - 1))) {
         currentTile = mountians;
       }
       cachedGraphics.drawImage(
           currentTile,
           (x + 1) * TILE_WIDTH,
           (boardHeight + 1) * TILE_HEIGHT,
           TILE_WIDTH,
           TILE_HEIGHT,
           this);
     }
     Image northwest = lowlands;
     if (b.isMountainSpace(b.new Coordinates(0, 0))) {
       northwest = mountians;
     }
     cachedGraphics.drawImage(northwest, TILE_WIDTH, 0, TILE_WIDTH, TILE_HEIGHT, this);
     cachedGraphics.drawImage(northwest, 0, TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, this);
     cachedGraphics.drawImage(northwest, 0, 0, TILE_WIDTH, TILE_HEIGHT, this);
     Image northeast = lowlands;
     if (b.isMountainSpace(b.new Coordinates(boardWidth - 1, 0))) {
       northeast = mountians;
     }
     cachedGraphics.drawImage(
         northeast, TILE_WIDTH * (boardWidth), 0, TILE_WIDTH, TILE_HEIGHT, this);
     cachedGraphics.drawImage(
         northeast, TILE_WIDTH * (boardWidth + 1), TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, this);
     cachedGraphics.drawImage(
         northeast, TILE_WIDTH * (boardWidth + 1), 0, TILE_WIDTH, TILE_HEIGHT, this);
     Image southeast = lowlands;
     if (b.isMountainSpace(b.new Coordinates(0, boardHeight - 1))) {
       southeast = mountians;
     }
     cachedGraphics.drawImage(
         southeast, TILE_WIDTH, TILE_HEIGHT * (boardHeight + 1), TILE_WIDTH, TILE_HEIGHT, this);
     cachedGraphics.drawImage(
         southeast, 0, TILE_HEIGHT * (boardHeight), TILE_WIDTH, TILE_HEIGHT, this);
     cachedGraphics.drawImage(
         southeast, 0, TILE_HEIGHT * (boardHeight + 1), TILE_WIDTH, TILE_HEIGHT, this);
     Image southwest = lowlands;
     if (b.isMountainSpace(b.new Coordinates(boardWidth - 1, boardHeight + 1))) {
       southwest = mountians;
     }
     cachedGraphics.drawImage(
         southwest,
         TILE_WIDTH * (boardWidth + 1),
         TILE_HEIGHT * (boardHeight + 1),
         TILE_WIDTH,
         TILE_HEIGHT,
         this);
     cachedGraphics.drawImage(
         southwest,
         TILE_WIDTH * (boardWidth + 1),
         TILE_HEIGHT * (boardHeight),
         TILE_WIDTH,
         TILE_HEIGHT,
         this);
     cachedGraphics.drawImage(
         southwest,
         TILE_WIDTH * (boardWidth),
         TILE_HEIGHT * (boardHeight + 1),
         TILE_WIDTH,
         TILE_HEIGHT,
         this);
   }
   ArrayList<Space> alreadyRendered = new ArrayList<Space>();
   renderFullBoardRecursive(cachedGraphics, alreadyRendered, origin, 0, 0, b);
 }