add dialogue setup and improve item handling in inventory
This commit is contained in:
@@ -12,6 +12,7 @@ import de.miaurizius.jgame2d.entity.projectile.FireballObj;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class Player extends Entity {
|
||||
|
||||
@@ -281,6 +282,7 @@ public class Player extends Entity {
|
||||
attack = getAttack();
|
||||
defense = getDefense();
|
||||
panel.playSE(8);
|
||||
setDialogue();
|
||||
startDialogue(this,0);
|
||||
}
|
||||
public void selectItem() {
|
||||
@@ -433,18 +435,22 @@ public class Player extends Entity {
|
||||
}
|
||||
public boolean canObtainItem(Entity item) {
|
||||
int i = searchItemInInventory(item.name);
|
||||
try {
|
||||
if(item.stackable) {
|
||||
if(i != 999) {
|
||||
inventory.get(i).amt++;
|
||||
return true;
|
||||
} else if(inventory.size() != maxInvSize) {
|
||||
inventory.add(item);
|
||||
inventory.add((Entity) Class.forName(item.getClass().getName()).getDeclaredConstructor(GamePanel.class).newInstance(panel));
|
||||
return true;
|
||||
}
|
||||
} else if(inventory.size() != maxInvSize) {
|
||||
inventory.add(item);
|
||||
inventory.add((Entity) Class.forName(item.getClass().getName()).getDeclaredConstructor(GamePanel.class).newInstance(panel));
|
||||
return true;
|
||||
}
|
||||
} catch(ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user