Moved menu context switching out of main cryps
This commit is contained in:
parent
31f48c0663
commit
a9dd2e76cc
@ -52,21 +52,17 @@ function registerEvents(registry, events, tutorial) {
|
|||||||
|
|
||||||
events.on('CRYP_ACTIVE', function crypActiveCb(cryp) {
|
events.on('CRYP_ACTIVE', function crypActiveCb(cryp) {
|
||||||
const cryps = registry.get('cryps');
|
const cryps = registry.get('cryps');
|
||||||
|
for (let i = 0; i < cryps.length; i += 1) {
|
||||||
cryps.forEach((c) => {
|
if (cryps[i].id === cryp.id) cryps[i].active = !cryps[i].active;
|
||||||
if (c.id === cryp.id) {
|
}
|
||||||
if (c.active) return c.active = false;
|
|
||||||
return c.active = true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
return setCryps(cryps);
|
return setCryps(cryps);
|
||||||
});
|
});
|
||||||
|
|
||||||
const errMessages = {
|
const errMessages = {
|
||||||
select_cryps: 'Select your cryps before battle using the numbered buttons next to the cryp avatar',
|
select_cryps: 'Select your cryps before battle using the numbered buttons next to the cryp avatar',
|
||||||
complete_nodes: 'You need to complete the previously connected nodes first',
|
complete_nodes: 'You need to complete the previously connected nodes first',
|
||||||
|
max_skills: 'Your cryp can only learn a maximum of 4 skills',
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function errorPrompt(type) {
|
function errorPrompt(type) {
|
||||||
|
|||||||
@ -3,12 +3,7 @@ const Phaser = require('phaser');
|
|||||||
const Header = require('./header');
|
const Header = require('./header');
|
||||||
const Menu = require('./menu');
|
const Menu = require('./menu');
|
||||||
const Combat = require('./combat');
|
const Combat = require('./combat');
|
||||||
const Zones = require('./zones');
|
|
||||||
const Background = require('./background');
|
const Background = require('./background');
|
||||||
const GameList = require('./game.list');
|
|
||||||
const StatSheet = require('./statsheet');
|
|
||||||
const SpecSheet = require('./specsheet');
|
|
||||||
|
|
||||||
|
|
||||||
function renderCryps() {
|
function renderCryps() {
|
||||||
const config = {
|
const config = {
|
||||||
@ -33,22 +28,6 @@ function renderCryps() {
|
|||||||
|
|
||||||
const game = new Phaser.Game(config);
|
const game = new Phaser.Game(config);
|
||||||
|
|
||||||
function newMainScene(key, scene, data) {
|
|
||||||
let addScene = true;
|
|
||||||
const ACTIVE_MAIN_SCENES = ['GameList', 'Zones', 'StatSheet', 'SpecSheet'];
|
|
||||||
ACTIVE_MAIN_SCENES.forEach((sKey) => {
|
|
||||||
if (game.scene.keys[sKey]) {
|
|
||||||
if (key === sKey) {
|
|
||||||
game.scene.keys[sKey].scene.restart(data);
|
|
||||||
addScene = false;
|
|
||||||
} else {
|
|
||||||
game.scene.keys[sKey].cleanUp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (addScene) game.scene.add(key, scene, true, data);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeData(parent, key, data) {
|
function changeData(parent, key, data) {
|
||||||
// Don't load other scenes if you're not logged in
|
// Don't load other scenes if you're not logged in
|
||||||
@ -63,23 +42,6 @@ function renderCryps() {
|
|||||||
return game.scene.add('Combat', Combat, true);
|
return game.scene.add('Combat', Combat, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key === 'zone') {
|
|
||||||
newMainScene('Zones', Zones, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key === 'gameList') {
|
|
||||||
newMainScene('GameList', GameList, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key === 'crypStats') {
|
|
||||||
newMainScene('StatSheet', StatSheet, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key === 'crypSpec') {
|
|
||||||
newMainScene('SpecSheet', SpecSheet, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,10 @@ const Phaser = require('phaser');
|
|||||||
const MenuCrypList = require('./menu.cryps.list');
|
const MenuCrypList = require('./menu.cryps.list');
|
||||||
const MenuNavigation = require('./menu.navigation');
|
const MenuNavigation = require('./menu.navigation');
|
||||||
const ItemList = require('./item.list');
|
const ItemList = require('./item.list');
|
||||||
|
const Zones = require('./zones');
|
||||||
|
const GameList = require('./game.list');
|
||||||
|
const StatSheet = require('./statsheet');
|
||||||
|
const SpecSheet = require('./specsheet');
|
||||||
|
|
||||||
class Menu extends Phaser.Scene {
|
class Menu extends Phaser.Scene {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -29,9 +33,41 @@ class Menu extends Phaser.Scene {
|
|||||||
if (data) return this.cleanUp();
|
if (data) return this.cleanUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (key === 'zone') {
|
||||||
|
this.newMainScene('Zones', Zones, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key === 'gameList') {
|
||||||
|
this.newMainScene('GameList', GameList, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key === 'crypStats') {
|
||||||
|
this.newMainScene('StatSheet', StatSheet, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key === 'crypSpec') {
|
||||||
|
this.newMainScene('SpecSheet', SpecSheet, data);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newMainScene(key, scene, data) {
|
||||||
|
let addScene = true;
|
||||||
|
const ACTIVE_MAIN_SCENES = ['GameList', 'Zones', 'StatSheet', 'SpecSheet'];
|
||||||
|
ACTIVE_MAIN_SCENES.forEach((sKey) => {
|
||||||
|
if (this.scene.manager.keys[sKey]) {
|
||||||
|
if (key === sKey) {
|
||||||
|
this.scene.manager.keys[sKey].scene.restart(data);
|
||||||
|
addScene = false;
|
||||||
|
} else {
|
||||||
|
this.scene.manager.keys[sKey].cleanUp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (addScene) this.scene.manager.add(key, scene, true, data);
|
||||||
|
}
|
||||||
|
|
||||||
cleanUp() {
|
cleanUp() {
|
||||||
this.registry.events.off('changedata', this.updateData, this);
|
this.registry.events.off('changedata', this.updateData, this);
|
||||||
this.registry.events.off('setdata', this.updateData, this);
|
this.registry.events.off('setdata', this.updateData, this);
|
||||||
|
|||||||
@ -10,7 +10,7 @@ const TEXT_MARGIN = 24;
|
|||||||
const menuX = WIDTH / 10;
|
const menuX = WIDTH / 10;
|
||||||
const menuY = HEIGHT * 0.8;
|
const menuY = HEIGHT * 0.8;
|
||||||
const menuWidth = WIDTH / 10;
|
const menuWidth = WIDTH / 10;
|
||||||
const menuHeight = HEIGHT * 0.3;
|
const menuHeight = HEIGHT * 0.2;
|
||||||
|
|
||||||
const X_LEARN = WIDTH * 2 / 4;
|
const X_LEARN = WIDTH * 2 / 4;
|
||||||
const Y_SKILLS = HEIGHT * 0.5;
|
const Y_SKILLS = HEIGHT * 0.5;
|
||||||
|
|||||||
@ -190,6 +190,7 @@ function createSocket(events) {
|
|||||||
case 'no active zone': return sendZoneCreate();
|
case 'no active zone': return sendZoneCreate();
|
||||||
case 'no cryps selected': return events.errorPrompt('select_cryps');
|
case 'no cryps selected': return events.errorPrompt('select_cryps');
|
||||||
case 'node requirements not met': return events.errorPrompt('complete_nodes');
|
case 'node requirements not met': return events.errorPrompt('complete_nodes');
|
||||||
|
case 'cryp at max skills (4)': return events.errorPrompt('max_skills');
|
||||||
|
|
||||||
default: return errorToast(error);
|
default: return errorToast(error);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user