Exemplo n.º 1
0
 public void renderPalaceRecursive(
     Graphics g, int layers, double x, double y, double width, double height) {
   if (layers > 0) {
     g.drawImage(palace, (int) x, (int) y, (int) width, (int) height, this);
     renderPalaceRecursive(g, layers - 1, x + width * 0.1, y, width * 0.8, height * 0.7);
   }
 }
Exemplo n.º 2
0
  protected void renderSpace(Graphics g, Tile t, int height, int inx, int iny) {
    int x = inx + 1;
    int y = iny + 1;

    Image tileFace = dirt;

    if (t != null) {
      if (t.getType() == TileType.RICE) {
        tileFace = rice;
      }
      if (t.getType() == TileType.VILLAGE) {
        tileFace = village;
      }
    }

    g.setColor(Color.white);
    g.drawImage(tileFace, x * TILE_WIDTH, y * TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, this);

    int givenHeight = height;

    if (t != null) {
      g.setColor(Color.black);
      if (t.getJoined(Grid.TOP) == null) {
        g.drawLine(
            (x) * TILE_WIDTH, (y) * TILE_HEIGHT, (x + 1) * TILE_WIDTH - 1, (y) * TILE_HEIGHT);
        g.drawLine(
            (x) * TILE_WIDTH,
            (y) * TILE_HEIGHT + 1,
            (x + 1) * TILE_WIDTH - 1,
            (y) * TILE_HEIGHT + 1);
      }
      if (t.getJoined(Grid.BOTTOM) == null) {
        g.drawLine(
            (x) * TILE_WIDTH,
            (y + 1) * TILE_HEIGHT - 1,
            (x + 1) * TILE_WIDTH - 1,
            (y + 1) * TILE_HEIGHT - 1);
        g.drawLine(
            (x) * TILE_WIDTH,
            (y + 1) * TILE_HEIGHT - 2,
            (x + 1) * TILE_WIDTH - 1,
            (y + 1) * TILE_HEIGHT - 2);
      }
      if (t.getJoined(Grid.LEFT) == null) {
        g.drawLine(
            (x) * TILE_WIDTH, (y) * TILE_HEIGHT, (x) * TILE_WIDTH, (y + 1) * TILE_HEIGHT - 1);
        g.drawLine(
            (x) * TILE_WIDTH + 1,
            (y) * TILE_HEIGHT,
            (x) * TILE_WIDTH + 1,
            (y + 1) * TILE_HEIGHT - 1);
      }
      if (t.getJoined(Grid.RIGHT) == null) {
        g.drawLine(
            (x + 1) * TILE_WIDTH - 1,
            (y) * TILE_HEIGHT,
            (x + 1) * TILE_WIDTH - 1,
            (y + 1) * TILE_HEIGHT - 1);
        g.drawLine(
            (x + 1) * TILE_WIDTH - 2,
            (y) * TILE_HEIGHT,
            (x + 1) * TILE_WIDTH - 2,
            (y + 1) * TILE_HEIGHT - 1);
      }
    }

    if (height > 0 && t.getType() == TileType.PALACE) {
      givenHeight = ((PalaceTile) t).getLevel();
      renderPalaceRecursive(
          g, givenHeight / 2, x * TILE_WIDTH, y * TILE_WIDTH, TILE_WIDTH, TILE_HEIGHT);
      if (!((PalaceTile) t).isHeadsUp()) {
        g.setColor(new Color(0, 0, 0, 0.5f));
        g.fillRect(x * TILE_WIDTH, y * TILE_WIDTH, TILE_WIDTH, TILE_HEIGHT);
      }
    }
  }