示例#1
0
  @Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    this.imageLoader = mainWindow.getImageLoader();

    if (mainWindow.getModel().getEpisode() == null) return;
    if (floor == null) return;

    // NO ROOM SELECTED
    if (currentRoom == null) {
      drawIfRoomNull(g);
    }

    // DRAW ROOM INCLUDING NEIGHBORS
    for (int x = -2; x < roomWidth + 2; x++) {
      for (int y = -2; y < roomHeight + 2; y++) {
        int fieldRoomX = roomX;
        int fieldRoomY = roomY;
        int fieldX = x;
        int fieldY = y;
        boolean outside = false;
        if (x < 0) {
          fieldRoomX--;
          fieldX += roomWidth;
          outside = true;
        } else if (x >= roomWidth) {
          fieldRoomX++;
          fieldX -= roomWidth;
          outside = true;
        }
        if (y < 0) {
          fieldRoomY--;
          fieldY += roomHeight;
          outside = true;
        } else if (y >= roomHeight) {
          fieldRoomY++;
          fieldY -= roomHeight;
          outside = true;
        }

        Room roomOfThisField = floor.getRoom(fieldRoomX, fieldRoomY);
        drawFieldWithAllLayers(g, roomOfThisField, fieldX, fieldY, x, y);

        if (outside) {
          g.setColor(new Color(128, 128, 128, 128));
          g.fillRect((x + 2) * fieldSize, (y + 2) * fieldSize, fieldSize, fieldSize);
        }
      }
    }

    // DRAW GRID
    if (drawGrid) drawGrid(g);

    // DRAW FRAME
    drawFrame(g);
  }
示例#2
0
 public void setRoom(Floor floor, int x, int y) {
   Room room = floor.getRoom(x, y);
   this.floor = floor;
   this.roomX = x;
   this.roomY = y;
   this.currentRoom = room;
   if (room != null) {
     this.roomWidth = room.getWidth();
     this.roomHeight = room.getHeight();
     this.currentLayer = room.getLayers().get(0);
   }
   repaint();
 }