Пример #1
0
  public void addEnemyNPCArmor(int level) {

    if (this.itemList.isEmpty()) {
      Items[] basic = new Items[6];
      Random rand = new Random();

      // Assigning basic Items
      basic[0] = new Items(2, this.classID, -1, level);
      basic[1] = new Items(3, this.classID, -1, level);
      basic[2] = new Items(4, this.classID, -1, level);
      basic[3] = new Items(5, this.classID, -1, level);
      basic[4] = new Items(6, this.classID, -1, level);

      // Check class to give correct weapon
      if (this.classID == 0) {
        basic[5] = new Items(10, this.classID, -1, level);
      } else if (this.classID == 1) {
        basic[5] = new Items(9, this.classID, -1, level);
      } else if (this.classID == 2) {
        basic[5] = new Items(12, this.classID, -1, level);
      } else if (this.classID == 3) {
        basic[5] = new Items(11, this.classID, -1, level);
      }

      for (int x = 0; x < basic.length; x++) {
        addItem(basic[x]);
        equipItem(basic[x].getID());
      }

      // Necklaces
      int willHaveItem = rand.nextInt(80);
      if (willHaveItem > 40 && willHaveItem < 60) {
        Items necklace = new Items(8, this.classID, -1, level);
        addItem(necklace);
        equipItem(necklace.getID());
      }
      // Ring
      willHaveItem = rand.nextInt(100);
      if (willHaveItem > 20 && willHaveItem < 40) {
        Items ring = new Items(7, this.classID, -1, level);
        addItem(ring);
        equipItem(ring.getID());
      }
      // Adds monies
      this.money = ((rand.nextInt(level + 3) + 1) * (rand.nextInt(3) + 1));

      // Extra inventory items
      Items[] extra = new Items[3];
      int itemCount = rand.nextInt(4);

      for (int x = 0; x < itemCount; x++) {
        extra[x] = new Items(rand.nextInt(level) + 1);
        this.addItem(extra[x]);
      }
    }
  }
Пример #2
0
  private void calculateAttackAndDefence() {
    // Setting to base
    this.playerOverallAttack = this.baseAttack;
    this.playerOverallDefence = this.baseDefence;

    for (Items item : this.itemList) {

      if (item.getID() == this.playerHelmet) {
        this.playerOverallAttack += item.getAttackPower();
        this.playerOverallDefence += item.getDefencePower();
      } else if (item.getID() == this.playerBody) {
        this.playerOverallAttack += item.getAttackPower();
        this.playerOverallDefence += item.getDefencePower();
      } else if (item.getID() == this.playerPants) {
        this.playerOverallAttack += item.getAttackPower();
        this.playerOverallDefence += item.getDefencePower();
      } else if (item.getID() == this.playerGloves) {
        this.playerOverallAttack += item.getAttackPower();
        this.playerOverallDefence += item.getDefencePower();
      } else if (item.getID() == this.playerWeapon) {
        this.playerOverallAttack += item.getAttackPower();
        this.playerOverallDefence += item.getDefencePower();
      } else if (item.getID() == this.playerBoots) {
        this.playerOverallAttack += item.getAttackPower();
        this.playerOverallDefence += item.getDefencePower();
      } else if (item.getID() == this.playerRing) {
        this.playerOverallAttack += item.getAttackPower();
        this.playerOverallDefence += item.getDefencePower();
      } else if (item.getID() == this.playerNecklaces) {
        this.playerOverallAttack += item.getAttackPower();
        this.playerOverallDefence += item.getDefencePower();
      }
    }
  }
Пример #3
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;
        }
      }
    }
  }
Пример #4
0
 // Returns null if not found
 public Items getItemByID(int ID) {
   for (Items item : this.itemList) {
     if (item.getID() == ID) {
       return item;
     }
   }
   return null;
 }
Пример #5
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();
    }
  }