From 4c184106fd81f4ffeb0b319d40351bcf10794be2 Mon Sep 17 00:00:00 2001 From: Mashy Date: Thu, 29 Nov 2018 17:29:04 +1000 Subject: [PATCH] testing scene swaps --- client/src/events.js | 3 ++- client/src/scenes/combat.js | 4 ++-- .../src/scenes/combat.render.resolutions.js | 3 +-- client/src/scenes/cryp.list.js | 15 ++++---------- client/src/scenes/cryps.js | 1 - client/src/scenes/menu.js | 2 +- client/src/scenes/passives.js | 9 ++++++++- client/src/scenes/player.js | 20 +++++++++++++++++++ 8 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 client/src/scenes/player.js diff --git a/client/src/events.js b/client/src/events.js index 2405adaa..91a48343 100644 --- a/client/src/events.js +++ b/client/src/events.js @@ -43,7 +43,8 @@ function registerEvents(registry, events) { const activeSkill = registry.get('activeSkill'); const game = registry.get('game'); if (activeSkill) { - if (activeSkill.cryp.account !== cryp.account) { + const target = activeSkill.cryp.account === cryp.account; + if (!target) { const ws = registry.get('ws'); if (game.phase === 'Skill') { ws.sendGameSkill(game.id, activeSkill.cryp.id, cryp.account, activeSkill.skill.skill); diff --git a/client/src/scenes/combat.js b/client/src/scenes/combat.js index 3528de41..c111d08a 100644 --- a/client/src/scenes/combat.js +++ b/client/src/scenes/combat.js @@ -16,7 +16,7 @@ class Combat extends Phaser.Scene { preload() { // Textures already loaded can do proper check in future when theres more textures - if (!(this.textures.getTextureKeys().length > 0)) { + if (!(this.textures.getTextureKeys().length > 2)) { this.textures.addBase64('alk', `data:image/png;base64,${new Buffer.from(fs.readFileSync('./assets/alakazam-f.png')).toString('base64')}`); this.textures.addBase64('magmar', `data:image/png;base64,${new Buffer.from(fs.readFileSync('./assets/magmar.png')).toString('base64')}`); this.load.image('proj', 'http://labs.phaser.io/assets/sprites/bullet.png'); @@ -43,6 +43,7 @@ class Combat extends Phaser.Scene { } }); + this.combatCryps = null; this.registry.set('gameAnimating', false); this.account = this.registry.get('account'); this.log = this.add.text(COMBAT.LOG.x(), COMBAT.LOG.y(), '', TEXT.NORMAL); @@ -56,7 +57,6 @@ class Combat extends Phaser.Scene { } return false; }, 1000); - return true; } diff --git a/client/src/scenes/combat.render.resolutions.js b/client/src/scenes/combat.render.resolutions.js index 4cadbac5..c62b9a78 100644 --- a/client/src/scenes/combat.render.resolutions.js +++ b/client/src/scenes/combat.render.resolutions.js @@ -76,8 +76,7 @@ function animatePhase(scene, group, game, resolution, cb) { // all done scene.time.delayedCall(MOVE_CREEP, () => { - animations.cleanup(); - animations.destroy(); + animations.destroy(true); return cb(); }); }); diff --git a/client/src/scenes/cryp.list.js b/client/src/scenes/cryp.list.js index ad51fd3a..29fe53d7 100644 --- a/client/src/scenes/cryp.list.js +++ b/client/src/scenes/cryp.list.js @@ -1,8 +1,8 @@ const Phaser = require('phaser'); const CrypRows = require('./cryp.row'); -const CrypPage = require('./cryp.page'); const GameList = require('./game.list'); +const Player = require('./player'); class CrypList extends Phaser.Scene { constructor() { @@ -38,12 +38,6 @@ class CrypList extends Phaser.Scene { this.CrypRows.destroy(true); } this.CrypRows = new CrypRows(this, cryps); - - // selected cryp - if (this.CrypPage) { - const cryp = cryps.find(c => c.id === this.CrypPage.id); - this.displaySkills(cryp); - } } renderGameList() { @@ -61,10 +55,9 @@ class CrypList extends Phaser.Scene { displaySkills(cryp) { if (cryp) { - if (this.CrypPage) { - this.CrypPage.destroy(true); - } - this.CrypPage = new CrypPage(this, cryp); + this.scene.add('Player', Player); + this.scene.run('Player', { x: 400, y: 300 }); + this.scene.sleep(); } return true; } diff --git a/client/src/scenes/cryps.js b/client/src/scenes/cryps.js index c57350f0..187757d6 100644 --- a/client/src/scenes/cryps.js +++ b/client/src/scenes/cryps.js @@ -3,7 +3,6 @@ const Phaser = require('phaser'); const CrypList = require('./cryp.list'); const Menu = require('./menu'); const Combat = require('./combat'); -// const Passives = require('./passives'); function renderCryps() { const config = { diff --git a/client/src/scenes/menu.js b/client/src/scenes/menu.js index 97e97a2e..122d11ce 100644 --- a/client/src/scenes/menu.js +++ b/client/src/scenes/menu.js @@ -9,7 +9,7 @@ class Menu extends Phaser.Scene { create() { this.add.text(0, 0, 'cryps.gg', TEXT.HEADER); - this.scene.sleep('Passives'); + // this.scene.sleep('Passives'); this.input.keyboard.on('keydown_F', () => { this.scene.wake('Passives'); }, 0, this); diff --git a/client/src/scenes/passives.js b/client/src/scenes/passives.js index 442b0b99..e79de19f 100644 --- a/client/src/scenes/passives.js +++ b/client/src/scenes/passives.js @@ -3,13 +3,16 @@ const PassiveNode = require('./passive.node'); const passiveDataNode = require('./passive.data.node'); const passiveDataEdge = require('./passive.data.edge'); +const { POSITIONS: { COMBAT } } = require('./constants'); + // Passive tree generator - proof of concept visuals need work // Mouse click hold to move, Q + E to zoom in and out // Press 'A' to reset allocated passive nodes class PhaserPassives extends Phaser.Scene { constructor() { - super({ key: 'Passives', active: true }); + super({ key: 'Passives' }); + // this.input = props.input; } preload() { @@ -20,6 +23,10 @@ class PhaserPassives extends Phaser.Scene { this.graphics = this.add.graphics(); this.passiveNodeData = passiveDataNode; this.passiveEdgeData = passiveDataEdge; + this.cameras.main.setViewport(COMBAT.width() * 0.5, COMBAT.height() * 0.3, + COMBAT.width() * 0.5, COMBAT.height() * 0.7); + this.cameras.main.scrollX = 500; + this.cameras.main.scrollY = 500; this.addPassiveNodes(); this.addCameraControl(); this.addEvents(); diff --git a/client/src/scenes/player.js b/client/src/scenes/player.js new file mode 100644 index 00000000..0097bcba --- /dev/null +++ b/client/src/scenes/player.js @@ -0,0 +1,20 @@ +const Phaser = require('phaser'); +const Passives = require('./passives'); + +class Player extends Phaser.Scene { + constructor() { + super({ key: 'Player' }); + } + + create(data) { + console.log(data); + this.scene.add('Passives', Passives, true); + this.input.keyboard.on('keydown_ONE', () => { + this.scene.run('CrypList'); + this.scene.remove('Passives'); + this.scene.remove(); + }, 0, this); + } +} + +module.exports = Player;