testing scene swaps

This commit is contained in:
Mashy 2018-11-29 17:29:04 +10:00
parent 0dd96ae961
commit 4c184106fd
8 changed files with 38 additions and 19 deletions

View File

@ -43,7 +43,8 @@ function registerEvents(registry, events) {
const activeSkill = registry.get('activeSkill'); const activeSkill = registry.get('activeSkill');
const game = registry.get('game'); const game = registry.get('game');
if (activeSkill) { if (activeSkill) {
if (activeSkill.cryp.account !== cryp.account) { const target = activeSkill.cryp.account === cryp.account;
if (!target) {
const ws = registry.get('ws'); const ws = registry.get('ws');
if (game.phase === 'Skill') { if (game.phase === 'Skill') {
ws.sendGameSkill(game.id, activeSkill.cryp.id, cryp.account, activeSkill.skill.skill); ws.sendGameSkill(game.id, activeSkill.cryp.id, cryp.account, activeSkill.skill.skill);

View File

@ -16,7 +16,7 @@ class Combat extends Phaser.Scene {
preload() { preload() {
// Textures already loaded can do proper check in future when theres more textures // 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('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.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'); 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.registry.set('gameAnimating', false);
this.account = this.registry.get('account'); this.account = this.registry.get('account');
this.log = this.add.text(COMBAT.LOG.x(), COMBAT.LOG.y(), '', TEXT.NORMAL); this.log = this.add.text(COMBAT.LOG.x(), COMBAT.LOG.y(), '', TEXT.NORMAL);
@ -56,7 +57,6 @@ class Combat extends Phaser.Scene {
} }
return false; return false;
}, 1000); }, 1000);
return true; return true;
} }

View File

@ -76,8 +76,7 @@ function animatePhase(scene, group, game, resolution, cb) {
// all done // all done
scene.time.delayedCall(MOVE_CREEP, () => { scene.time.delayedCall(MOVE_CREEP, () => {
animations.cleanup(); animations.destroy(true);
animations.destroy();
return cb(); return cb();
}); });
}); });

View File

@ -1,8 +1,8 @@
const Phaser = require('phaser'); const Phaser = require('phaser');
const CrypRows = require('./cryp.row'); const CrypRows = require('./cryp.row');
const CrypPage = require('./cryp.page');
const GameList = require('./game.list'); const GameList = require('./game.list');
const Player = require('./player');
class CrypList extends Phaser.Scene { class CrypList extends Phaser.Scene {
constructor() { constructor() {
@ -38,12 +38,6 @@ class CrypList extends Phaser.Scene {
this.CrypRows.destroy(true); this.CrypRows.destroy(true);
} }
this.CrypRows = new CrypRows(this, cryps); 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() { renderGameList() {
@ -61,10 +55,9 @@ class CrypList extends Phaser.Scene {
displaySkills(cryp) { displaySkills(cryp) {
if (cryp) { if (cryp) {
if (this.CrypPage) { this.scene.add('Player', Player);
this.CrypPage.destroy(true); this.scene.run('Player', { x: 400, y: 300 });
} this.scene.sleep();
this.CrypPage = new CrypPage(this, cryp);
} }
return true; return true;
} }

View File

@ -3,7 +3,6 @@ const Phaser = require('phaser');
const CrypList = require('./cryp.list'); const CrypList = require('./cryp.list');
const Menu = require('./menu'); const Menu = require('./menu');
const Combat = require('./combat'); const Combat = require('./combat');
// const Passives = require('./passives');
function renderCryps() { function renderCryps() {
const config = { const config = {

View File

@ -9,7 +9,7 @@ class Menu extends Phaser.Scene {
create() { create() {
this.add.text(0, 0, 'cryps.gg', TEXT.HEADER); this.add.text(0, 0, 'cryps.gg', TEXT.HEADER);
this.scene.sleep('Passives'); // this.scene.sleep('Passives');
this.input.keyboard.on('keydown_F', () => { this.input.keyboard.on('keydown_F', () => {
this.scene.wake('Passives'); this.scene.wake('Passives');
}, 0, this); }, 0, this);

View File

@ -3,13 +3,16 @@ const PassiveNode = require('./passive.node');
const passiveDataNode = require('./passive.data.node'); const passiveDataNode = require('./passive.data.node');
const passiveDataEdge = require('./passive.data.edge'); const passiveDataEdge = require('./passive.data.edge');
const { POSITIONS: { COMBAT } } = require('./constants');
// Passive tree generator - proof of concept visuals need work // Passive tree generator - proof of concept visuals need work
// Mouse click hold to move, Q + E to zoom in and out // Mouse click hold to move, Q + E to zoom in and out
// Press 'A' to reset allocated passive nodes // Press 'A' to reset allocated passive nodes
class PhaserPassives extends Phaser.Scene { class PhaserPassives extends Phaser.Scene {
constructor() { constructor() {
super({ key: 'Passives', active: true }); super({ key: 'Passives' });
// this.input = props.input;
} }
preload() { preload() {
@ -20,6 +23,10 @@ class PhaserPassives extends Phaser.Scene {
this.graphics = this.add.graphics(); this.graphics = this.add.graphics();
this.passiveNodeData = passiveDataNode; this.passiveNodeData = passiveDataNode;
this.passiveEdgeData = passiveDataEdge; 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.addPassiveNodes();
this.addCameraControl(); this.addCameraControl();
this.addEvents(); this.addEvents();

View File

@ -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;