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
+41
View File
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2020. Antonio Martinez Casadesus and Pascal Syma.
* All rights reserved.
*/
import Interactable from "./Interactable";
import Item from "./Item";
export default class Chest extends Interactable {
constructor(scene, item) {
super(scene, item.x, item.y, 'chest');
this.setFrame(4);
this.body.setAllowGravity(false);
this.setOrigin(0.5, 1);
this.setData('opened', false);
}
canInteract() {
return !this.getData('opened');
}
interact() {
super.interact();
this.setData('opened', true);
this.play('chest_open');
const options = [/*"slow", "speed", "storm", */"heal"];
let item = new Item(this.scene, {
x: this.x,
y: this.y - this.height
}, options[Math.floor(Math.random() * options.length)])
this.scene.interactables.add(item);
}
}