made projectile usage available for monsters

This commit is contained in:
2025-12-07 00:23:41 +01:00
parent 5da7c43edf
commit ce8a97c0cc
4 changed files with 68 additions and 18 deletions

View File

@@ -87,15 +87,7 @@ public class Entity {
panel.collisionH.checkEntity(this, panel.monster);
boolean contactPlayer = panel.collisionH.checkPlayer(this);
if(this.type == EntityType.MONSTER && contactPlayer) {
if(panel.player.invincible) return;
panel.playSE(6);
int damage = attack - panel.player.defense;
panel.player.life -= Math.max(damage, 0);
panel.player.invincible = true;
}
if(this.type == EntityType.MONSTER && contactPlayer) damagePlayer(attack);
if(!collisionOn) {
switch (direction) {
@@ -168,6 +160,15 @@ public class Entity {
// INTERACTION
public void setAction() {}
public void damageReaction() {}
public void damagePlayer(int attack) {
if(panel.player.invincible) return;
panel.playSE(6);
int damage = attack - panel.player.defense;
panel.player.life -= Math.max(damage, 0);
panel.player.invincible = true;
}
public void speak() {
if(dialogue[dialogueIndex] == null) dialogueIndex = 0;
panel.ui.currentDialogue = dialogue[dialogueIndex];