added stackable functionality to items and improved inventory management
This commit is contained in:
@@ -199,6 +199,24 @@ public class UI {
|
||||
graphics2d.fillRoundRect(slotX, slotY, panel.tileSize, panel.tileSize, 10, 10);
|
||||
}
|
||||
graphics2d.drawImage(entity.inventory.get(i).down1, slotX, slotY, null);
|
||||
|
||||
// AMOUNT
|
||||
if(entity == panel.player && entity.inventory.get(i).amt > 1) {
|
||||
graphics2d.setFont(graphics2d.getFont().deriveFont(32F));
|
||||
int amtX;
|
||||
int amtY;
|
||||
String amtS = String.valueOf(entity.inventory.get(i).amt);
|
||||
amtX = getAlignedToRightX(amtS, slotX+44);
|
||||
amtY = slotY + panel.tileSize;
|
||||
|
||||
// SHADOW
|
||||
graphics2d.setColor(new Color(60, 60, 60));
|
||||
graphics2d.drawString(amtS, amtX, amtY);
|
||||
// NUMBER
|
||||
graphics2d.setColor(Color.white);
|
||||
graphics2d.drawString(amtS, amtX-3, amtY-3);
|
||||
}
|
||||
|
||||
slotX += slotSize;
|
||||
if (i == 4 || i == 9 || i == 14) {
|
||||
slotX = slotXStart;
|
||||
@@ -450,15 +468,14 @@ public class UI {
|
||||
drawDialogueScreen();
|
||||
return;
|
||||
}
|
||||
if(panel.player.inventory.size() == panel.player.maxInvSize) {
|
||||
tradeState = TradeState.SELECT;
|
||||
panel.gameState = GameState.DIALOGUE;
|
||||
currentDialogue = "Your inventory is full!";
|
||||
drawDialogueScreen();
|
||||
if(panel.player.canObtainItem(tradingNPC.inventory.get(itemIndex))) {
|
||||
panel.player.coins -= tradingNPC.inventory.get(itemIndex).price;
|
||||
return;
|
||||
}
|
||||
panel.player.coins -= tradingNPC.inventory.get(itemIndex).price;
|
||||
panel.player.inventory.add(tradingNPC.inventory.get(itemIndex));
|
||||
tradeState = TradeState.SELECT;
|
||||
panel.gameState = GameState.DIALOGUE;
|
||||
currentDialogue = "Your inventory is full!";
|
||||
drawDialogueScreen();
|
||||
}
|
||||
}
|
||||
private void tradeSell() {
|
||||
@@ -499,7 +516,8 @@ public class UI {
|
||||
currentDialogue = "You cannot sell an equipped item!";
|
||||
return;
|
||||
}
|
||||
panel.player.inventory.remove(itemIndex);
|
||||
if(panel.player.inventory.get(itemIndex).amt <= 1) panel.player.inventory.remove(itemIndex);
|
||||
else panel.player.inventory.get(itemIndex).amt--;
|
||||
panel.player.coins += Integer.parseInt(price);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,21 @@ public class AssetSetter {
|
||||
panel.obj[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*30;
|
||||
panel.obj[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*28;
|
||||
i++;
|
||||
|
||||
panel.obj[Map.OVERWORLD.getIndex()][i] = new PotionObj(panel);
|
||||
panel.obj[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*21;
|
||||
panel.obj[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*20;
|
||||
i++;
|
||||
|
||||
panel.obj[Map.OVERWORLD.getIndex()][i] = new PotionObj(panel);
|
||||
panel.obj[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*20;
|
||||
panel.obj[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*20;
|
||||
i++;
|
||||
|
||||
panel.obj[Map.OVERWORLD.getIndex()][i] = new PotionObj(panel);
|
||||
panel.obj[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*17;
|
||||
panel.obj[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*21;
|
||||
i++;
|
||||
}
|
||||
|
||||
public void setNPC() {
|
||||
@@ -88,6 +103,16 @@ public class AssetSetter {
|
||||
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,32,12);i++;
|
||||
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,33,12);i++;
|
||||
|
||||
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,29,21);i++;
|
||||
|
||||
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,25,27);i++;
|
||||
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,26,27);i++;
|
||||
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,27,27);i++;
|
||||
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,27,28);i++;
|
||||
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,27,29);i++;
|
||||
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,28,29);i++;
|
||||
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,29,29);i++;
|
||||
|
||||
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,18,40);i++;
|
||||
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,17,40);i++;
|
||||
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,16,40);i++;
|
||||
|
||||
Reference in New Issue
Block a user