player can now choose between different shields and weapons. added consumable items (healing potion)
This commit is contained in:
22
src/de/miaurizius/jgame2d/entity/item/AxeObj.java
Normal file
22
src/de/miaurizius/jgame2d/entity/item/AxeObj.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package de.miaurizius.jgame2d.entity.item;
|
||||
|
||||
import de.miaurizius.jgame2d.core.GamePanel;
|
||||
import de.miaurizius.jgame2d.core.enums.EntityType;
|
||||
import de.miaurizius.jgame2d.entity.Entity;
|
||||
|
||||
public class AxeObj extends Entity {
|
||||
|
||||
public AxeObj(GamePanel panel) {
|
||||
super(panel);
|
||||
name = "Woodcutter's Axe";
|
||||
description = "[" + name + "]\nA bit rusty but still can \ncut some trees.";
|
||||
type = EntityType.WEAPON;
|
||||
weaponType = EntityType.WeaponType.AXE;
|
||||
down1 = initEntitySprites("/objects/axe");
|
||||
|
||||
attackValue = 2;
|
||||
attackArea.width = 30;
|
||||
attackArea.height = 30;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@ public class BootsObj extends Entity {
|
||||
|
||||
public BootsObj(GamePanel panel) {
|
||||
super(panel);
|
||||
name = "boots";
|
||||
name = "Boots";
|
||||
type = EntityType.ITEM;
|
||||
down1 = initEntitySprites("objects/boots.png");
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ public class HeartObj extends Entity {
|
||||
|
||||
public HeartObj(GamePanel panel) {
|
||||
super(panel);
|
||||
name = "heart";
|
||||
name = "Heart Container";
|
||||
type = EntityType.ITEM;
|
||||
image = initEntitySprites("objects/heart_full");
|
||||
image2 = initEntitySprites("objects/heart_half");
|
||||
|
||||
19
src/de/miaurizius/jgame2d/entity/item/IronShieldObj.java
Normal file
19
src/de/miaurizius/jgame2d/entity/item/IronShieldObj.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package de.miaurizius.jgame2d.entity.item;
|
||||
|
||||
import de.miaurizius.jgame2d.core.GamePanel;
|
||||
import de.miaurizius.jgame2d.core.enums.EntityType;
|
||||
import de.miaurizius.jgame2d.entity.Entity;
|
||||
|
||||
public class IronShieldObj extends Entity {
|
||||
|
||||
public IronShieldObj(GamePanel panel) {
|
||||
super(panel);
|
||||
|
||||
name = "Iron Shield";
|
||||
description = "[" + name + "]\nAn iron shield. It's very\nheavy.";
|
||||
type = EntityType.SHIELD;
|
||||
down1 = initEntitySprites("objects/shield_blue");
|
||||
defenseValue = 2;
|
||||
}
|
||||
|
||||
}
|
||||
33
src/de/miaurizius/jgame2d/entity/item/PotionObj.java
Normal file
33
src/de/miaurizius/jgame2d/entity/item/PotionObj.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package de.miaurizius.jgame2d.entity.item;
|
||||
|
||||
import de.miaurizius.jgame2d.core.GamePanel;
|
||||
import de.miaurizius.jgame2d.core.enums.EntityType;
|
||||
import de.miaurizius.jgame2d.core.enums.GameState;
|
||||
import de.miaurizius.jgame2d.entity.Entity;
|
||||
|
||||
public class PotionObj extends Entity {
|
||||
|
||||
GamePanel panel;
|
||||
int value = 2;
|
||||
|
||||
public PotionObj(GamePanel panel) {
|
||||
super(panel);
|
||||
this.panel = panel;
|
||||
|
||||
type = EntityType.ITEM;
|
||||
consumable = true;
|
||||
name = "Red Potion";
|
||||
down1 = initEntitySprites("objects/potion_red");
|
||||
description = "[" + name + "]\nHeals your life by " + value + ".";
|
||||
}
|
||||
|
||||
public void use(Entity entity) {
|
||||
panel.gameState = GameState.DIALOGUE;
|
||||
panel.ui.currentDialogue = "You drank a " + name + "!\n" +
|
||||
"Your life has been recovered by " + value + ".";
|
||||
entity.life += value;
|
||||
if(panel.player.life > panel.player.maxLife) panel.player.life = panel.player.maxLife;
|
||||
panel.playSE(2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ public class ShieldWoodObj extends Entity {
|
||||
super(panel);
|
||||
name = "Wooden Shield";
|
||||
description = "[" + name + "]\nAn old shield. It's not\nthat strong but its okay.";
|
||||
type = EntityType.ITEM;
|
||||
type = EntityType.SHIELD;
|
||||
down1 = initEntitySprites("objects/shield_wood");
|
||||
defenseValue = 1;
|
||||
}
|
||||
|
||||
@@ -11,9 +11,13 @@ public class SwordNormalObj extends Entity {
|
||||
|
||||
name = "Normal Sword";
|
||||
description = "[" + name + "]\nAn old sword.";
|
||||
type = EntityType.ITEM;
|
||||
type = EntityType.WEAPON;
|
||||
weaponType = EntityType.WeaponType.SWORD;
|
||||
down1 = initEntitySprites("objects/sword_normal");
|
||||
|
||||
attackValue = 1;
|
||||
attackArea.width = 36;
|
||||
attackArea.height = 36;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user