diff --git a/src/shattered_sword/AI/EnemyAI.ts b/src/shattered_sword/AI/EnemyAI.ts index 0c69eca..f5abf37 100644 --- a/src/shattered_sword/AI/EnemyAI.ts +++ b/src/shattered_sword/AI/EnemyAI.ts @@ -253,7 +253,12 @@ export default class EnemyAI extends StateMachineAI implements BattlerAI { if (this.bleedStat) { this.bleedStat.position = this.poisonStat.position.clone().add(new Vec2(30, 0)); this.bleedStat.visible = this.bleedCounter > 0; - } + } + + if (this.owner.position.y > this.tilemap.getDimensions().y * this.tilemap.getTileSize().y) { + this.CURRENT_HP = -1; + this.emitter.fireEvent(Player_Events.ENEMY_KILLED, {owner: this.owner.id, ai:this}); + } } } diff --git a/src/shattered_sword/AI/EnemyStates/Alert.ts b/src/shattered_sword/AI/EnemyStates/Alert.ts index d51876d..1266c4e 100644 --- a/src/shattered_sword/AI/EnemyStates/Alert.ts +++ b/src/shattered_sword/AI/EnemyStates/Alert.ts @@ -9,10 +9,6 @@ export default class Alert extends EnemyState { } update(deltaT: number): void { - if(!this.canWalk()){ - this.parent.direction *= -1; - } - let position = this.parent.getPlayerPosition(); if (position) { this.parent.velocity.x = this.parent.maxSpeed * Math.sign(position.x - this.owner.position.x); @@ -22,7 +18,12 @@ export default class Alert extends EnemyState { this.finished(EnemyStates.PATROL); } - (this.owner).invertX = this.parent.velocity.x > 0 ? true : false ; + this.parent.direction = this.parent.velocity.x >= 0 ? 1 : -1; + if (!this.canWalk()) { + this.parent.velocity.x = 0; + } + + (this.owner).invertX = this.parent.direction === 1 ? true : false ; super.update(deltaT); }