Пример #1
0
  public void setValues(String unitName, int health, int maxHealth) {
    name.setImage(Character.getImageComponent(unitName));
    name.setLocation(9 + (60 - name.getWidth()) / 2, 3);

    this.healthCap = maxHealth;

    setValues(health);
  }
Пример #2
0
  public PanelHealth() {
    background = new ImageComponent("resources/gui/window/healthDisplayBlue.png");
    healthBar1 = new ImageComponent("resources/gui/window/healthDisplayBar.png");
    healthBar2 = new ImageComponent("resources/gui/window/healthDisplayBar.png");

    healthBarMaxWidth = healthBar1.getWidth();

    healthBar1.setLocation(27 + 1, 19);
    healthBar2.setLocation(27, 19 + 1);

    name = Character.getImageComponent("Lyn");
    name.setLocation(9 + (60 - name.getWidth()) / 2, 3);

    healthNumber = SmallNumber.getImageComponent("16");
    healthNumber.setLocation(23 - healthNumber.getWidth(), 16);

    add(name);
    add(healthNumber);
    add(healthBar1);
    add(healthBar2);
    add(background);

    setLayout(null);
    setOpaque(false);
    setVisible(true);

    setSize(background.getWidth(), background.getHeight());
    setPreferredSize(getSize());
  }
Пример #3
0
  public void setValues(int health) {
    this.health = health;

    healthNumber.setImage(SmallNumber.getImageComponent(String.valueOf(health)));
    healthNumber.setLocation(23 - healthNumber.getWidth(), 16);

    int healthBarWidth = healthBarMaxWidth * health / healthCap;

    healthBar1.setSize(healthBarWidth, healthBar1.getHeight());
    healthBar2.setSize(healthBarWidth, healthBar2.getHeight());

    repaint();
  }
Пример #4
0
 public void setFaction(Faction faction) {
   background.setImage("resources/gui/window/healthDisplay" + faction.name + ".png");
 }