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