added iTile life

This commit is contained in:
2025-12-08 05:09:21 +01:00
parent 285b18b4cc
commit 9916fa8b25
3 changed files with 23 additions and 11 deletions

View File

@@ -220,10 +220,12 @@ public class Player extends Entity {
} }
} }
public void interactTile(int index) { public void interactTile(int index) {
if(index == 999 || !panel.iTile[index].destructible) return; if(index == 999 || !panel.iTile[index].destructible || panel.iTile[index].invincible) return;
if(!panel.iTile[index].meetItemReq(this)) return; if(!panel.iTile[index].meetItemReq(this)) return;
panel.iTile[index].playSE(); panel.iTile[index].playSE();
panel.iTile[index] = panel.iTile[index].getDestroyedForm(); panel.iTile[index].life--;
panel.iTile[index].invincible = true;
if(panel.iTile[index].life == 0) panel.iTile[index] = panel.iTile[index].getDestroyedForm();
} }
public void interactNPC(int index) { public void interactNPC(int index) {

View File

@@ -16,16 +16,18 @@ public class DryTreeTI extends InteractiveTile{
down1 = initEntitySprites("/interactive_tiles/drytree"); down1 = initEntitySprites("/interactive_tiles/drytree");
destructible = true; destructible = true;
life = 3;
} }
public boolean meetItemReq(Entity entity) { // PRE_CONFIGURED
return entity.currentWeapon.weaponType == EntityType.WeaponType.AXE;
}
public void playSE() { public void playSE() {
panel.playSE(11); panel.playSE(11);
} }
// GETTERS
public boolean meetItemReq(Entity entity) {
return entity.currentWeapon.weaponType == EntityType.WeaponType.AXE;
}
public InteractiveTile getDestroyedForm() { public InteractiveTile getDestroyedForm() {
return new TrunkIT(panel, worldX/panel.tileSize, worldY/panel.tileSize); return new TrunkIT(panel, worldX/panel.tileSize, worldY/panel.tileSize);
} }

View File

@@ -13,17 +13,25 @@ public class InteractiveTile extends Entity {
this.panel = panel; this.panel = panel;
} }
// GENERAL
public void update() { public void update() {
// INVINCIBLE COUNTER
if(!invincible) return;
invincibleCount++;
if(invincibleCount > 20) {
invincible = false;
invincibleCount = 0;
}
} }
// PRE-CONFIGURED
public void playSE() {} public void playSE() {}
public InteractiveTile getDestroyedForm() { // UTILITY
return null;
}
public boolean meetItemReq(Entity entity) { public boolean meetItemReq(Entity entity) {
return false; return false;
} }
public InteractiveTile getDestroyedForm() {
return null;
}
} }