fix: enemy fall out of map
This commit is contained in:
parent
7478f4bb1f
commit
1726ba3653
|
@ -254,6 +254,11 @@ export default class EnemyAI extends StateMachineAI implements BattlerAI {
|
||||||
this.bleedStat.position = this.poisonStat.position.clone().add(new Vec2(30, 0));
|
this.bleedStat.position = this.poisonStat.position.clone().add(new Vec2(30, 0));
|
||||||
this.bleedStat.visible = this.bleedCounter > 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 {
|
update(deltaT: number): void {
|
||||||
if(!this.canWalk()){
|
|
||||||
this.parent.direction *= -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
let position = this.parent.getPlayerPosition();
|
let position = this.parent.getPlayerPosition();
|
||||||
if (position) {
|
if (position) {
|
||||||
this.parent.velocity.x = this.parent.maxSpeed * Math.sign(position.x - this.owner.position.x);
|
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.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);
|
super.update(deltaT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user