added item chests, audio and deployment

Signed-off-by: Pascal Syma <pascal@syma.dev>
This commit is contained in:
2020-07-16 20:51:24 +02:00
parent 0004849110
commit 7559a3f40a
27 changed files with 237 additions and 36 deletions
+4 -3
View File
@@ -17,7 +17,7 @@ export default class Entity extends Phaser.GameObjects.Sprite {
}
hit(dmg) {
if (dmg <= 0)
if (dmg === 0)
return;
if (this.hitCooldown)
@@ -25,8 +25,8 @@ export default class Entity extends Phaser.GameObjects.Sprite {
this.hitCooldown = true;
this.setData('hp', this.getData('hp') - dmg);
console.log(this, this.getData('hp'));
const newHp = this.getData('hp') - dmg;
this.setData('hp', newHp < 0 ? 0 : newHp);
// play hit animation
const shouldDie = this.getData('hp') <= 0;
@@ -38,6 +38,7 @@ export default class Entity extends Phaser.GameObjects.Sprite {
}
if (this.hitAnimation !== null) {
// TODO: bug, not working, no clue why not
this.anims.stop();
this.play(this.hitAnimation)
.once('animationcomplete', () => {