const Phaser = require('phaser'); const { TEXT, COLOURS, } = require('../constants'); function FindColour(item) { // Future add skills and use a constants lookup file ?? switch (item) { case 'Green': return 0x396E26; case 'Red': return 0x622433; case 'Blue': return 0x223158; // case 'Green': return 0x043003; // case 'Red': return 0x5C0202; // case 'Blue': return 0x040345; default: return 0x222222; } } class Item extends Phaser.GameObjects.Container { constructor(scene, item, index, x, y, width, height) { super(scene, x, y); this.scene = scene; this.item = item; this.index = index; this.origX = x; this.origY = y; this.width = width; this.height = height; this.colour = FindColour(item); this.box = scene.add .rectangle(0, 0, width, height, this.colour); this.text = scene.add // .text(0, 0, `${action} x${count}`, TEXT.NORMAL) .text(0, 0, `${item}`, TEXT.NORMAL) .setOrigin(0.5, 0.5); this.add(this.box); this.add(this.text); this.setSize(width, height); this.setInteractive(); } changeOrigin(x, y) { this.origX = x + this.width / 2; this.origY = y + this.height / 2; } } module.exports = Item;