コード例 #1
0
  @Override
  public void draw(Graphics g) {
    Color colorOriginal = ResourceManager.getInstance().getColor("COLOR_MAIN");
    Color color = new Color(colorOriginal.r, colorOriginal.g, colorOriginal.b, (float) 0.2);
    if (isMouseOver()) {

      if (isBuyable()) {
        if (equals(builder.getSelected())) {
          backgroundHover.draw(getX(), getY(), getWidth(), getHeight(), colorOriginal);
        } else {
          backgroundHover.draw(getX(), getY(), getWidth(), getHeight());
        }
        unit.getImgAvatar()
            .draw(
                getX() + UnitShortcut.BORDER,
                getY() + UnitShortcut.BORDER,
                getWidth() - UnitShortcut.BORDER * 2,
                getHeight() - UnitShortcut.BORDER * 2,
                unit.getPlayer().getColor());
      } else {
        background.draw(getX(), getY(), getWidth(), getHeight());
        unit.getImgAvatar()
            .draw(
                getX() + UnitShortcut.BORDER,
                getY() + UnitShortcut.BORDER,
                getWidth() - UnitShortcut.BORDER * 2,
                getHeight() - UnitShortcut.BORDER * 2,
                clrNotAvailable);
      }
      if (equals(builder.getSelected())) {
        g.setColor(color);
        g.drawRoundRect(getX(), getY(), getWidth(), getHeight(), 3);
      }
    } else {
      if (equals(builder.getSelected())) {
        backgroundHover.draw(getX(), getY(), getWidth(), getHeight(), colorOriginal);
      } else {
        background.draw(getX(), getY(), getWidth(), getHeight());
      }
      if (isBuyable()) {
        unit.getImgAvatar()
            .draw(
                getX() + UnitShortcut.BORDER,
                getY() + UnitShortcut.BORDER,
                getWidth() - UnitShortcut.BORDER * 2,
                getHeight() - UnitShortcut.BORDER * 2,
                unit.getPlayer().getColor());
      } else {
        unit.getImgAvatar()
            .draw(
                getX() + UnitShortcut.BORDER,
                getY() + UnitShortcut.BORDER,
                getWidth() - UnitShortcut.BORDER * 2,
                getHeight() - UnitShortcut.BORDER * 2,
                clrNotAvailable);
      }
      if (equals(builder.getSelected())) {
        g.setColor(color);
        g.drawRoundRect(getX(), getY(), getWidth(), getHeight(), 3);
      }
    }
  }
コード例 #2
0
 public boolean isBuyable() {
   return unit.getPlayer().getMoney().getRealCredits() >= credits;
 }