added item pickup to inventory
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package de.miaurizius.jgame2d.core.handlers;
|
package de.miaurizius.jgame2d.core.handlers;
|
||||||
|
|
||||||
import de.miaurizius.jgame2d.core.GamePanel;
|
import de.miaurizius.jgame2d.core.GamePanel;
|
||||||
|
import de.miaurizius.jgame2d.entity.item.KeyObj;
|
||||||
import de.miaurizius.jgame2d.entity.npc.OldManNPC;
|
import de.miaurizius.jgame2d.entity.npc.OldManNPC;
|
||||||
import de.miaurizius.jgame2d.entity.monster.GreenSlimeMON;
|
import de.miaurizius.jgame2d.entity.monster.GreenSlimeMON;
|
||||||
|
|
||||||
@@ -13,7 +14,21 @@ public class AssetSetter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setObject() {
|
public void setObject() {
|
||||||
|
int i = 0;
|
||||||
|
panel.obj[i] = new KeyObj(panel);
|
||||||
|
panel.obj[i].worldX = panel.tileSize*25;
|
||||||
|
panel.obj[i].worldY = panel.tileSize*23;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
panel.obj[i] = new KeyObj(panel);
|
||||||
|
panel.obj[i].worldX = panel.tileSize*21;
|
||||||
|
panel.obj[i].worldY = panel.tileSize*19;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
panel.obj[i] = new KeyObj(panel);
|
||||||
|
panel.obj[i].worldX = panel.tileSize*26;
|
||||||
|
panel.obj[i].worldY = panel.tileSize*21;
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNPC() {
|
public void setNPC() {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public class Player extends Entity {
|
|||||||
// STATE
|
// STATE
|
||||||
public boolean attackCancel;
|
public boolean attackCancel;
|
||||||
public ArrayList<Entity> inventory = new ArrayList<>();
|
public ArrayList<Entity> inventory = new ArrayList<>();
|
||||||
|
public final int maxInvSize = 20;
|
||||||
|
|
||||||
public Player(GamePanel panel, KeyHandler keyH) {
|
public Player(GamePanel panel, KeyHandler keyH) {
|
||||||
super(panel);
|
super(panel);
|
||||||
@@ -121,6 +122,14 @@ public class Player extends Entity {
|
|||||||
// INTERACTION
|
// INTERACTION
|
||||||
public void pickObject(int index) {
|
public void pickObject(int index) {
|
||||||
if(index == 999) return;
|
if(index == 999) return;
|
||||||
|
if(inventory.size() == maxInvSize) {
|
||||||
|
panel.ui.addMessage("Your inventory is full!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
inventory.add(panel.obj[index]);
|
||||||
|
panel.playSE(1);
|
||||||
|
panel.ui.addMessage("Picked up " + panel.obj[index].name);
|
||||||
|
panel.obj[index] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void interactMonster(int index) {
|
public void interactMonster(int index) {
|
||||||
|
|||||||
Reference in New Issue
Block a user