Exemple #1
0
  /** Empty constructor for externalization. */
  public PlayerOptions() {
    waveCounter = new GenericTexture();
    waveCounter.setVisible(false);
    waveCounter.setDrawAlphaChannel(true);
    waveCounter.setUrl("http://i.imgur.com/fWiJl.png");
    waveCounter.setWidth(125);
    waveCounter.setHeight(125);
    waveCounter.setAnchor(WidgetAnchor.TOP_RIGHT);
    waveCounter.shiftXPos(-85);
    waveCounter.shiftYPos(-35);
    waveCounter.setPriority(RenderPriority.High);

    waveCounterWave = new GenericLabel("Wave: 0");
    waveCounterWave.setVisible(false);
    waveCounterWave.setAnchor(WidgetAnchor.TOP_RIGHT);
    waveCounterWave.setAlign(WidgetAnchor.CENTER_CENTER);
    waveCounterWave.shiftXPos(-35);
    waveCounterWave.shiftYPos(37);
    waveCounterWave.setTextColor(new Color(150, 0, 10));
    waveCounterWave.setHeight(10);
    waveCounterWave.setWidth(10);

    waveCounterZombies = new GenericLabel("0");
    waveCounterZombies.setVisible(false);
    waveCounterZombies.setAnchor(WidgetAnchor.TOP_RIGHT);
    waveCounterZombies.setAlign(WidgetAnchor.CENTER_CENTER);
    waveCounterZombies.shiftXPos(-40);
    waveCounterZombies.shiftYPos(18);
    waveCounterZombies.setTextColor(new Color(150, 0, 10));
    waveCounterZombies.setScale(2);
    waveCounterZombies.setHeight(20);
    waveCounterZombies.setWidth(20);
  }
Exemple #2
0
  public void openTabScreen() {
    tabHeader = new GenericTexture("http://i.imgur.com/t8CPF.png");
    tabHeader.setDrawAlphaChannel(true);
    tabHeader.setAnchor(WidgetAnchor.CENTER_CENTER);
    tabHeader.setWidth(212);
    tabHeader.setHeight(8);
    tabHeader.shiftYPos(-100);
    tabHeader.shiftXPos(tabHeader.getWidth() / -2 + 20);

    @SuppressWarnings({"unchecked", "rawtypes"})
    List<PlayerStats> sortedStats =
        new ArrayList(ZArena.getInstance().getGameHandler().getPlayerStats().values());
    Collections.sort(sortedStats);

    int index = 0;
    for (PlayerStats stats : sortedStats) {
      GenericTexture part = new GenericTexture("http://i.imgur.com/qvrX8.png");
      part.setDrawAlphaChannel(true);
      part.setAnchor(WidgetAnchor.CENTER_CENTER);
      part.setWidth(255);
      part.setHeight(15);
      part.shiftYPos(-90 + index * 15);
      part.shiftXPos(part.getWidth() / -2);
      part.setPriority(RenderPriority.Low);
      tabMain.add(part);

      Player player = stats.getPlayer();

      GenericLabel name = new GenericLabel(player.getName());
      name.setAnchor(WidgetAnchor.CENTER_CENTER);
      name.setAlign(WidgetAnchor.TOP_CENTER);
      name.setHeight(11);
      name.setWidth(10);
      name.shiftYPos(-86 + index * 15);
      name.shiftXPos(-75);

      GenericLabel kills = new GenericLabel(stats.getKills() + "");
      kills.setAnchor(WidgetAnchor.CENTER_CENTER);
      kills.setAlign(WidgetAnchor.TOP_CENTER);
      kills.setHeight(11);
      kills.setWidth(10);
      kills.shiftYPos(-86 + index * 15);

      GenericLabel money = new GenericLabel("$" + stats.getMoney());
      money.setAnchor(WidgetAnchor.CENTER_CENTER);
      money.setAlign(WidgetAnchor.TOP_CENTER);
      money.setHeight(11);
      money.setWidth(10);
      money.shiftYPos(-86 + index * 15);
      money.shiftXPos(50);

      GenericLabel health = new GenericLabel((stats.isAlive()) ? player.getHealth() + "" : "DEAD");
      health.setTextColor(
          (!stats.isAlive())
              ? new Color(150, 0, 0)
              : (player.getHealth() > 15)
                  ? new Color(0, 200, 0)
                  : (player.getHealth() > 10)
                      ? new Color(255, 255, 0)
                      : (player.getHealth() > 5) ? new Color(255, 140, 0) : new Color(200, 0, 0));
      health.setAnchor(WidgetAnchor.CENTER_CENTER);
      health.setAlign(WidgetAnchor.TOP_CENTER);
      health.setHeight(11);
      health.setWidth(10);
      health.shiftYPos(-86 + index * 15);
      health.shiftXPos(100);

      tabText.add(name);
      tabText.add(money);
      tabText.add(kills);
      tabText.add(health);

      index++;
    }

    ((SpoutPlayer) Bukkit.getPlayer(player))
        .getMainScreen()
        .attachWidget(ZArena.getInstance(), tabHeader);
    for (GenericTexture part : tabMain) {
      ((SpoutPlayer) Bukkit.getPlayer(player))
          .getMainScreen()
          .attachWidget(ZArena.getInstance(), part);
    }
    for (GenericLabel text : tabText) {
      ((SpoutPlayer) Bukkit.getPlayer(player))
          .getMainScreen()
          .attachWidget(ZArena.getInstance(), text);
    }
  }