Skip to content

Commit

Permalink
Fixed enemy explosion
Browse files Browse the repository at this point in the history
  • Loading branch information
neki-dev committed Oct 30, 2023
1 parent f423dff commit a2f71de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,23 @@ export class EnemyExplosive extends Enemy {
},
});

this.scene.sound.play(EffectAudio.EXPLOSION);

if (this.scene.game.isSettingEnabled(GameSettings.EFFECTS)) {
new Effect(this.scene, {
texture: EffectTexture.EXPLOSION,
position: this.body.center,
depth: this.depth + 1,
});
}

let targets: IEnemyTarget[] = [this.scene.player];

targets = targets.concat(this.scene.getEntities<IEnemy>(EntityType.ENEMY));
targets = targets.concat(this.scene.getEntities<IBuilding>(EntityType.BUILDING));

targets.forEach((target) => {
if (target !== this) {
if (target.active && target !== this) {
const distance = getIsometricDistance(position, target.getBottomFace());

if (distance <= EXPLOSION_RADIUS) {
Expand All @@ -66,15 +76,5 @@ export class EnemyExplosive extends Enemy {
}
}
});

this.scene.sound.play(EffectAudio.EXPLOSION);

if (this.scene.game.isSettingEnabled(GameSettings.EFFECTS)) {
new Effect(this.scene, {
texture: EffectTexture.EXPLOSION,
position: this.body.center,
depth: this.depth + 1,
});
}
}
}
1 change: 1 addition & 0 deletions src/types/world/entities/npc/enemy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface IEnemyFactory {

export interface IEnemyTarget {
readonly live: ILive
active: boolean
getBottomFace(): PositionAtWorld
}

Expand Down

0 comments on commit a2f71de

Please sign in to comment.