fix: enemy fall out of map
This commit is contained in:
parent
7478f4bb1f
commit
1726ba3653
|
@ -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});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
(<Sprite>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;
|
||||
}
|
||||
|
||||
(<Sprite>this.owner).invertX = this.parent.direction === 1 ? true : false ;
|
||||
super.update(deltaT);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user