/* * 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 = [/*"storm", "slow", */"jump", "speed", "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); } }