From 7520d85c67e277f58585c0f3b0808f5359dd83dd Mon Sep 17 00:00:00 2001 From: ntr Date: Tue, 11 Dec 2018 16:53:25 +1100 Subject: [PATCH] select cryp names --- client/src/scenes/combat.skills.js | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/client/src/scenes/combat.skills.js b/client/src/scenes/combat.skills.js index 528ff7a2..00cf6013 100644 --- a/client/src/scenes/combat.skills.js +++ b/client/src/scenes/combat.skills.js @@ -44,6 +44,18 @@ class CrypName extends Phaser.GameObjects.Text { constructor(scene, x, y, cryp) { super(scene, x, y, cryp.name, TEXT.HEADER); } + + select() { + this.setTint(0x00ff00); + } + + activate() { + this.setTint(0xff0000); + } + + deselect() { + this.clearTint(); + } } class CrypSkill extends Phaser.GameObjects.Text { @@ -152,7 +164,8 @@ class CombatSkills extends Phaser.Scene { const namePos = skillTextPosition(i, 0); // Draw the cryp name - this.add.existing(new CrypName(this, namePos[0], namePos[1], cryp)); + const crypName = new CrypName(this, namePos[0], namePos[1], cryp); + this.add.existing(crypName); // return early if KOd if (cryp.hp.base === 0) return true; @@ -160,7 +173,7 @@ class CombatSkills extends Phaser.Scene { // draw the skills const skillButtons = cryp.skills.map((skill, j) => addSkill(i, j, skill, cryp)); - const bindCrypKeys = () => this.mapSkillKeys(skillButtons, game.id, cryp.id, team.id, enemyTeam.id, i); + const bindCrypKeys = () => this.mapSkillKeys(skillButtons, crypName, game.id, cryp.id, team.id, enemyTeam.id, i); // reset everything keyboard.on('keydown_ESC', bindCrypKeys, this); @@ -173,7 +186,7 @@ class CombatSkills extends Phaser.Scene { return true; } - mapSkillKeys(skillButtons, gameId, crypId, alliesId, enemyId, i) { + mapSkillKeys(skillButtons, crypName, gameId, crypId, alliesId, enemyId, i) { const { keyboard } = this.input; // deselect any currently active button @@ -181,6 +194,10 @@ class CombatSkills extends Phaser.Scene { this.activeSkill.deselect(); } + if (this.activeName) { + this.activeName.deselect(); + } + keyboard.removeListener(CRYP_KEY_MAP[i]); keyboard.on(CRYP_KEY_MAP[i], () => { @@ -189,8 +206,13 @@ class CombatSkills extends Phaser.Scene { // deselect any currently active button if (this.activeSkill) { this.activeSkill.deselect(); + this.activeName.deselect(); } + crypName.select(); + console.log(crypName); + this.activeName = crypName; + skillButtons.forEach((button, j) => { keyboard.on(SKILL_KEY_MAP[j], () => { this.activeSkill = button;