fix: destroy uis after enemy died
This commit is contained in:
parent
845dcb8132
commit
858a8bbfd4
|
@ -150,8 +150,23 @@ export default class EnemyAI extends StateMachineGoapAI implements BattlerAI {
|
||||||
this.owner.setAIActive(false, {});
|
this.owner.setAIActive(false, {});
|
||||||
this.owner.isCollidable = false;
|
this.owner.isCollidable = false;
|
||||||
this.owner.visible = false;
|
this.owner.visible = false;
|
||||||
this.healthBar.destroy();
|
if (this.healthBar) {
|
||||||
|
this.healthBar.destroy();
|
||||||
|
this.healthBar = undefined;
|
||||||
|
}
|
||||||
|
if (this.poisonStat) {
|
||||||
|
this.poisonStat.destroy();
|
||||||
|
this.poisonStat = undefined;
|
||||||
|
}
|
||||||
|
if (this.burnStat) {
|
||||||
|
this.burnStat.destroy();
|
||||||
|
this.burnStat = undefined;
|
||||||
|
}
|
||||||
|
if (this.bleedStat) {
|
||||||
|
this.bleedStat.destroy();
|
||||||
|
this.bleedStat = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
this.emitter.fireEvent(Player_Events.ENEMY_KILLED, {owner: this.owner.id, ai:this});
|
this.emitter.fireEvent(Player_Events.ENEMY_KILLED, {owner: this.owner.id, ai:this});
|
||||||
|
|
||||||
|
|
||||||
|
@ -281,23 +296,31 @@ export default class EnemyAI extends StateMachineGoapAI implements BattlerAI {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.healthBar.position = this.owner.collisionShape.center.clone().add(new Vec2(0, -((<AABB>this.owner.collisionShape).hh+5)));
|
if (this.healthBar) {
|
||||||
this.healthBar.fillWidth = this.CURRENT_HP/this.maxHealth * this.owner.collisionShape.hw * 3;
|
this.healthBar.position = this.owner.collisionShape.center.clone().add(new Vec2(0, -((<AABB>this.owner.collisionShape).hh+5)));
|
||||||
if (this.CURRENT_HP/this.maxHealth >= 2/3) {
|
this.healthBar.fillWidth = this.CURRENT_HP/this.maxHealth * this.owner.collisionShape.hw * 3;
|
||||||
this.healthBar.color = Color.GREEN;
|
if (this.CURRENT_HP/this.maxHealth >= 2/3) {
|
||||||
|
this.healthBar.color = Color.GREEN;
|
||||||
|
}
|
||||||
|
else if (this.CURRENT_HP/this.maxHealth >= 1/3) {
|
||||||
|
this.healthBar.color = Color.YELLOW;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.healthBar.color = Color.RED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (this.CURRENT_HP/this.maxHealth >= 1/3) {
|
if (this.poisonStat) {
|
||||||
this.healthBar.color = Color.YELLOW;
|
this.poisonStat.position = this.owner.collisionShape.center.clone().add(new Vec2(-((<AABB>this.owner.collisionShape).hw)*1.5+10, -((<AABB>this.owner.collisionShape).hh+15)));
|
||||||
|
this.poisonStat.visible = this.poisonCounter > 0;
|
||||||
}
|
}
|
||||||
else {
|
if (this.burnStat) {
|
||||||
this.healthBar.color = Color.RED;
|
this.burnStat.position = this.poisonStat.position.clone().add(new Vec2(15, 0));
|
||||||
|
this.burnStat.visible = this.burnCounter > 0;
|
||||||
}
|
}
|
||||||
this.poisonStat.position = this.owner.collisionShape.center.clone().add(new Vec2(-((<AABB>this.owner.collisionShape).hw)*1.5+10, -((<AABB>this.owner.collisionShape).hh+15)));
|
if (this.bleedStat) {
|
||||||
this.burnStat.position = this.poisonStat.position.clone().add(new Vec2(15, 0));
|
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.poisonStat.visible = this.poisonCounter > 0;
|
}
|
||||||
this.burnStat.visible = this.burnCounter > 0;
|
|
||||||
this.bleedStat.visible = this.bleedCounter > 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user