public boolean activate() { // if true continue to execute if (Inventory.getCount(Essence) >= 11 && (InAltar.contains(Players.getMyPlayer().getLocation()))) { return true; } return false; }
public void render() { Graphics g = screen.getGraphics(); // Drawing Things! sky.render(g); level.render( g, (int) sX, (int) sY, (pixel.width / Tile.tileSize) + 2, (pixel.height / Tile.tileSize) + 2); character.render(g); inventory.render(g); health.render(g); for (int i = 0; i < mob.toArray().length; i++) { mob.get(i).render(g); } g = getGraphics(); g.drawImage(screen, 0, 0, size.width, size.height, 0, 0, pixel.width, pixel.height, null); g.dispose(); }
public void addInventory(Inventory inv) { add(inv); inv.setBounds(x, y, 47, 42); if (last != count) { x += 50; last += 1; } else { x = 2; y += 50; last = 0; } setPreferredSize(new Dimension(82 * count, y + 30)); }
public void useItem(int y, int x) { // uses an item Item temp = inventory.itemAt(x, y); if (temp == null) return; else if (temp.itemID < 5) { // equips equipnent inventory.setItem(x, y, equipment.itemAt(0, temp.itemID)); equipment.setItem(0, temp.itemID, temp); calculateStats(); // recalculates player stats } else if (temp.itemID == 5) { // uses health potion inventory.setItem(x, y, null); healHealth((int) (80 + maxHealth * 0.2)); } else if (temp.itemID == 6) { // uses mana potion inventory.setItem(x, y, null); healMana((int) (80 + maxMana * 0.2)); } }
public void calculateStats() { // calculates stats based on equipped items if (equipment.itemAt(0, 0) != null) atk.damage = equipment.itemAt(0, 0).value1; if (equipment.itemAt(0, 1) != null) atkSpd = ((double) equipment.itemAt(0, 1).value1 / 100.0 + 1) * 0.8; if (equipment.itemAt(0, 2) != null) { armor = equipment.itemAt(0, 2).value1; maxHealth = 100 + equipment.itemAt(0, 2).value2; } if (equipment.itemAt(0, 3) != null) { armor += equipment.itemAt(0, 3).value1; maxMana = 100 + equipment.itemAt(0, 3).value2; } if (equipment.itemAt(0, 4) != null) { maxHealth += equipment.itemAt(0, 4).value1; atk.damage += equipment.itemAt(0, 4).value2; } }
// Handles all the buttons and crap public void actionPerformed(ActionEvent e) { for (int i = 0; i < pages.length; i++) { if (e.getSource() == pages[i]) { page = i + 1; } } if (e.getSource() == pockets[0]) { page = 1; changeSelection(Item.Pocket.ITEM); } if (e.getSource() == pockets[1]) { page = 1; changeSelection(Item.Pocket.MEDICINE); } if (e.getSource() == pockets[2]) { page = 1; changeSelection(Item.Pocket.POKEBALL); } if (e.getSource() == pockets[3]) { page = 1; changeSelection(Item.Pocket.TMHM); } if (e.getSource() == pockets[4]) { page = 1; changeSelection(Item.Pocket.BATTLE); } if (e.getSource() == closeButton) { closeWindow(); } if (e.getSource() == information) { infoB = !infoB; } if (e.getSource() == buySellButton) { if (state == State.BUY) { state = State.SELL; buySellButton.setText("Selling"); changeSelection(Item.Pocket.ITEM); } else { state = State.BUY; buySellButton.setText("Buying"); changeSelection(Item.Pocket.ITEM); } } int num = (page - 1) * 10; for (int i = 0; i < display.length; i++) { if (e.getSource() == display[i] && !itemSelected) { itemSelected = true; selectedItemId = num + i; } else if (e.getSource() == display[i]) { totalAmount.setText("Enter Amount"); itemSelected = false; buyButton.setEnabled(false); sellButton.setEnabled(false); } } if (e.getSource() == amountField && itemSelected) { try { amount = Integer.parseInt(amountField.getText()); amount *= currentDisplay.get(selectedItemId).storeCost; if (amount < 0 || (state == State.SELL && amount / currentDisplay.get(selectedItemId).storeCost > currentDisplay.get(selectedItemId).amount) && (state != State.SELL && !currentDisplay.get(selectedItemId).reUsable)) { totalAmount.setText("Error"); } else if (state == State.SELL && Inventory.getItemInfo(currentDisplay.get(selectedItemId)).amount < amount / currentDisplay.get(selectedItemId).storeCost) { totalAmount.setText("Error"); } else { if (state == State.BUY) totalAmount.setText("Total of $" + amount); else totalAmount.setText("Total of $" + amount / 2); } updateBuyButton(); updateSellButton(); } catch (Exception ee) { totalAmount.setText("Error"); } } if (e.getSource() == buyButton) { Inventory.money -= amount; if (currentDisplay.get(selectedItemId).type != Item.Type.TM || currentDisplay.get(selectedItemId).type != Item.Type.HM) Inventory.addItem( new Item( currentDisplay.get(selectedItemId).type, amount / currentDisplay.get(selectedItemId).storeCost)); else Inventory.addItem( new Item( currentDisplay.get(selectedItemId).type, amount / currentDisplay.get(selectedItemId).storeCost, currentDisplay.get(selectedItemId).mNo)); itemSelected = false; totalAmount.setText("Enter Amount"); buyButton.setEnabled(false); } if (e.getSource() == sellButton) { updateSellButton(); if (!sellButton.isEnabled()) return; Inventory.money += amount / 2; amount = amount / currentDisplay.get(selectedItemId).storeCost; while (amount > 0) { Inventory.decrementItem(currentDisplay.get(selectedItemId), true); amount--; } totalAmount.setText("Enter Amount"); sellButton.setEnabled(false); itemSelected = false; changeSelection(pocket); } updateGui(); }