added item chests, audio and deployment
Signed-off-by: Pascal Syma <pascal@syma.dev>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user