fixed statsheet
This commit is contained in:
parent
24060accab
commit
b36559ae9f
@ -20,6 +20,7 @@ function registerEvents(registry, events, tutorial) {
|
|||||||
|
|
||||||
function setAccount(account) {
|
function setAccount(account) {
|
||||||
registry.set('account', account);
|
registry.set('account', account);
|
||||||
|
registry.set('menu', true);
|
||||||
events.emit('ACCOUNT', account);
|
events.emit('ACCOUNT', account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -112,8 +112,9 @@ class Combat extends Phaser.Scene {
|
|||||||
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);
|
||||||
|
|
||||||
this.registry.set('game', null);
|
|
||||||
this.registry.set('inGame', null);
|
this.registry.set('inGame', null);
|
||||||
|
this.registry.set('menu', true);
|
||||||
|
this.registry.set('game', null);
|
||||||
|
|
||||||
this.scene.get('CombatLog').cleanUp();
|
this.scene.get('CombatLog').cleanUp();
|
||||||
this.scene.get('CombatCryps').cleanUp();
|
this.scene.get('CombatCryps').cleanUp();
|
||||||
|
|||||||
@ -21,7 +21,6 @@ function renderCryps() {
|
|||||||
},
|
},
|
||||||
scene: [
|
scene: [
|
||||||
Header,
|
Header,
|
||||||
Menu,
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -29,11 +28,13 @@ function renderCryps() {
|
|||||||
|
|
||||||
function changeData(parent, key, data) {
|
function changeData(parent, key, data) {
|
||||||
console.log(key, data);
|
console.log(key, data);
|
||||||
if (key === 'game') {
|
|
||||||
if (!data) return game.scene.add('Menu', Menu, true);
|
|
||||||
|
|
||||||
console.log(game.registry.get('inGame'));
|
if (key === 'menu') {
|
||||||
if (game.registry.get('inGame')) return false;
|
if (data) return game.scene.add('Menu', Menu, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key === 'game') {
|
||||||
|
if (!data || game.registry.get('inGame')) return false;
|
||||||
return game.scene.add('Combat', Combat, true);
|
return game.scene.add('Combat', Combat, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,14 +34,14 @@ class Menu extends Phaser.Scene {
|
|||||||
// Scene switch to statsheet called by MenuCrypRows scene
|
// Scene switch to statsheet called by MenuCrypRows scene
|
||||||
displaySkills(cryp) {
|
displaySkills(cryp) {
|
||||||
if (cryp) {
|
if (cryp) {
|
||||||
this.scene.add('StatSheet', StatSheet);
|
this.scene.manager.add('StatSheet', StatSheet, true, cryp);
|
||||||
this.scene.run('StatSheet', cryp);
|
this.cleanUp();
|
||||||
this.scene.sleep();
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanUp() {
|
cleanUp() {
|
||||||
|
console.log('rip menu');
|
||||||
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);
|
||||||
|
|
||||||
|
|||||||
@ -140,6 +140,13 @@ class PhaserPassives extends Phaser.Scene {
|
|||||||
update(delta) {
|
update(delta) {
|
||||||
this.controls.update(delta);
|
this.controls.update(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanUp() {
|
||||||
|
this.registry.events.off('changedata', this.updateData, this);
|
||||||
|
this.registry.events.off('setdata', this.updateData, this);
|
||||||
|
this.scene.remove();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = PhaserPassives;
|
module.exports = PhaserPassives;
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
const Phaser = require('phaser');
|
const Phaser = require('phaser');
|
||||||
|
|
||||||
|
const { POSITIONS: { STATS } } = require('./constants');
|
||||||
|
|
||||||
const Passives = require('./passives');
|
const Passives = require('./passives');
|
||||||
const Stats = require('./statsheet.stats');
|
const Stats = require('./statsheet.stats');
|
||||||
const Skills = require('./statsheet.skills');
|
const Skills = require('./statsheet.skills');
|
||||||
const { POSITIONS: { STATS } } = require('./constants');
|
|
||||||
const addButton = require('./statsheet.button');
|
const addButton = require('./statsheet.button');
|
||||||
|
|
||||||
const menuOrig = STATS.height() * 0.5;
|
const menuOrig = STATS.height() * 0.5;
|
||||||
@ -16,22 +17,26 @@ class StatSheet extends Phaser.Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
create(cryp) {
|
create(cryp) {
|
||||||
console.log(cryp);
|
|
||||||
this.cryp = cryp;
|
this.cryp = cryp;
|
||||||
this.stats = new Stats(this, cryp);
|
this.stats = new Stats(this, cryp);
|
||||||
this.addControls(cryp);
|
this.addControls(cryp);
|
||||||
this.addSkills(cryp);
|
this.addSkills(cryp);
|
||||||
this.skills = true;
|
this.skills = true;
|
||||||
|
this.registry.events.on('changedata', this.updateData, this);
|
||||||
|
this.registry.events.on('setdata', this.updateData, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateData(parent, key, data) {
|
||||||
|
if (key === 'menu') {
|
||||||
|
if (data) return this.cleanUp();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
addControls(cryp) {
|
addControls(cryp) {
|
||||||
const menuCback = () => {
|
const menuCback = () => {
|
||||||
this.registry.events.off('changedata', this.updateData, this);
|
this.registry.set('menu', true);
|
||||||
this.registry.set('game', null);
|
|
||||||
this.scene.switch('Menu'); // Switch back to menu
|
|
||||||
this.scene.remove('Skills');
|
|
||||||
this.scene.remove('Passives');
|
|
||||||
this.scene.remove();
|
|
||||||
};
|
};
|
||||||
const passiveCback = () => {
|
const passiveCback = () => {
|
||||||
if (this.passives) return false;
|
if (this.passives) return false;
|
||||||
@ -60,28 +65,34 @@ class StatSheet extends Phaser.Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addSkills(cryp) {
|
addSkills(cryp) {
|
||||||
this.scene.add('Skills', Skills);
|
this.scene.manager.add('Skills', Skills, true, cryp);
|
||||||
this.scene.run('Skills', cryp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addPassives(cryp) {
|
addPassives(cryp) {
|
||||||
this.scene.add('Passives', Passives);
|
this.scene.manager.add('Passives', Skills, true, cryp);
|
||||||
this.scene.run('Passives', cryp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removePassives() {
|
removePassives() {
|
||||||
if (!this.passives) return false;
|
if (!this.passives) return false;
|
||||||
this.scene.remove('Passives');
|
this.scene.get('Passives').cleanUp();
|
||||||
this.passives = false;
|
this.passives = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeSkills() {
|
removeSkills() {
|
||||||
if (!this.skills) return false;
|
if (!this.skills) return false;
|
||||||
this.scene.remove('Skills');
|
this.scene.get('Skills').cleanUp();
|
||||||
this.skills = false;
|
this.skills = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanUp() {
|
||||||
|
this.registry.events.off('changedata', this.updateData, this);
|
||||||
|
this.registry.events.off('setdata', this.updateData, this);
|
||||||
|
this.removePassives();
|
||||||
|
this.removeSkills();
|
||||||
|
this.scene.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = StatSheet;
|
module.exports = StatSheet;
|
||||||
|
|||||||
@ -24,7 +24,6 @@ class Skills extends Phaser.Scene {
|
|||||||
this.cryp = cryp;
|
this.cryp = cryp;
|
||||||
this.forget = false;
|
this.forget = false;
|
||||||
// Destroy the old registry event if it exists
|
// Destroy the old registry event if it exists
|
||||||
this.registry.events.off('changedata', this.updateData, this);
|
|
||||||
this.registry.events.on('changedata', this.updateData, this);
|
this.registry.events.on('changedata', this.updateData, this);
|
||||||
this.add.text(X_ORIG_KNOWN, Y_ORIG, 'Skills', TEXT.HEADER);
|
this.add.text(X_ORIG_KNOWN, Y_ORIG, 'Skills', TEXT.HEADER);
|
||||||
this.addKnownSkills(cryp);
|
this.addKnownSkills(cryp);
|
||||||
@ -96,6 +95,11 @@ class Skills extends Phaser.Scene {
|
|||||||
this.addKnownSkills(cryp);
|
this.addKnownSkills(cryp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanUp() {
|
||||||
|
this.registry.events.off('changedata', this.updateData, this);
|
||||||
|
this.scene.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Skills;
|
module.exports = Skills;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user