fixed statsheet
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user