Colour items

This commit is contained in:
Mashy 2019-02-21 11:03:50 +10:00
parent 21c657a1a2
commit 168cdd4104

View File

@ -5,6 +5,16 @@ const {
COLOURS, COLOURS,
} = require('../constants'); } = require('../constants');
function FindColour(item) {
// Future add skills and use a constants lookup file ??
switch (item) {
case 'Green': return 0x61B329;
case 'Red': return 0xCC3333;
case 'Blue': return 0x6633FF;
default: return 0x222222;
}
}
class Item extends Phaser.GameObjects.Container { class Item extends Phaser.GameObjects.Container {
constructor(scene, item, index, x, y, width, height) { constructor(scene, item, index, x, y, width, height) {
super(scene, x, y); super(scene, x, y);
@ -18,8 +28,9 @@ class Item extends Phaser.GameObjects.Container {
this.width = width; this.width = width;
this.height = height; this.height = height;
this.colour = FindColour(item);
this.box = scene.add this.box = scene.add
.rectangle(0, 0, width, height, 0x222222); .rectangle(0, 0, width, height, this.colour);
this.text = scene.add this.text = scene.add
// .text(0, 0, `${action} x${count}`, TEXT.NORMAL) // .text(0, 0, `${action} x${count}`, TEXT.NORMAL)
@ -49,7 +60,7 @@ class Item extends Phaser.GameObjects.Container {
this.scene.children.list.forEach((item) => { this.scene.children.list.forEach((item) => {
if (item.state === 'select') item.deselect(); if (item.state === 'select') item.deselect();
}); });
this.box.setFillStyle(COLOURS.SELECT); // this.box.setFillStyle(COLOURS.SELECT);
this.state = 'select'; this.state = 'select';
} }
@ -57,12 +68,12 @@ class Item extends Phaser.GameObjects.Container {
this.scene.children.list.forEach((item) => { this.scene.children.list.forEach((item) => {
if (item.state === 'select') item.deselect(); if (item.state === 'select') item.deselect();
}); });
this.box.setFillStyle(0xff0000); this.box.setFillStyle(0x222222);
this.state = 'activate'; this.state = 'activate';
} }
deselect() { deselect() {
this.box.setFillStyle(0x222222); this.box.setFillStyle(this.colour);
this.state = 'deselect'; this.state = 'deselect';
} }
} }