示例#1
0
  public void renderShopStock(Graphics g, int[] inventory) {

    int x = 240, y = 464;
    g.setColor(Color.black);

    int inventoryCounter = 0;

    for (Items item : this.itemList) {

      if (!item.isEquipped()) {
        if (inventoryCounter <= 20) {
          g.setColor(item.getItemRarityColor());
          g.fillRect(x, y, 32, 32);
          item.drawImageItem(x, y);
          inventory[inventoryCounter++] = item.getID();
        }

        x += 64;
        if (x > 496) {
          x = 112;
          y += 64;
        }
      }
    }
  }
示例#2
0
  public void renderInventory(Graphics g, int[] equipped, int[] inventory) {

    int x = 112, y = 464;
    g.setColor(Color.black);

    int inventoryCounter = 0;

    for (Items item : this.itemList) {

      if (item.getID() == this.playerHelmet) {
        g.setColor(item.getItemRarityColor());
        g.fillRect(112, 80, 32, 32);
        item.drawImageItem(112, 80);
        equipped[0] = this.playerHelmet;
      } else if (item.getID() == this.playerBody) {
        g.setColor(item.getItemRarityColor());
        g.fillRect(112, 144, 32, 32);
        item.drawImageItem(112, 144);
        equipped[1] = this.playerBody;
      } else if (item.getID() == this.playerPants) {
        g.setColor(item.getItemRarityColor());
        g.fillRect(112, 208, 32, 32);
        item.drawImageItem(112, 208);
        equipped[2] = this.playerPants;
      } else if (item.getID() == this.playerGloves) {
        g.setColor(item.getItemRarityColor());
        g.fillRect(48, 144, 32, 32);
        item.drawImageItem(48, 144);
        equipped[4] = this.playerGloves;
      } else if (item.getID() == this.playerWeapon) {
        g.setColor(item.getItemRarityColor());
        g.fillRect(176, 144, 32, 32);
        item.drawImageItem(176, 144);
        equipped[5] = this.playerWeapon;
      } else if (item.getID() == this.playerBoots) {
        g.setColor(item.getItemRarityColor());
        g.fillRect(112, 272, 32, 32);
        item.drawImageItem(112, 272);
        equipped[3] = this.playerBoots;
      } else if (item.getID() == this.playerRing) {
        g.setColor(item.getItemRarityColor());
        g.fillRect(208, 48, 32, 32);
        item.drawImageItem(208, 48);
        equipped[6] = this.playerRing;
      } else if (item.getID() == this.playerNecklaces) {
        g.setColor(item.getItemRarityColor());
        g.fillRect(272, 48, 32, 32);
        item.drawImageItem(272, 48);
        equipped[7] = this.playerNecklaces;
      } else if (item.getItemID() == 0 || item.getItemID() == 1) {

      } else {
        g.setColor(item.getItemRarityColor());
        g.fillRect(x, y, 32, 32);
        item.drawImageItem(x, y);
        inventory[inventoryCounter++] = item.getID();

        x += 64;
        if (x > 496) {
          x = 112;
          y += 64;
        }
      }
    }

    try {
      g.setColor(Color.black);
      Image healthPotion = new Image("NewEra-Beta/res/items/health.png");
      healthPotion.draw(431, 368);
      g.drawString("" + this.healthPotions, 460, 360);

      Image staminaPotion = new Image("NewEra-Beta/res/items/stamina.png");
      staminaPotion.draw(496, 368);
      g.drawString("" + this.staminaPotions, 525, 360);
    } catch (SlickException e) {
      e.printStackTrace();
    }
  }