Added skill scene and some info / forget / learn handlers
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
const Phaser = require('phaser');
|
||||
const Passives = require('./passives');
|
||||
const Stats = require('./statsheet.stats');
|
||||
const { SkillsKnown, SkillsLearn } = require('./statsheet.skills');
|
||||
const Skills = require('./statsheet.skills');
|
||||
const { TEXT, POSITIONS: { STATS } } = require('./constants');
|
||||
|
||||
const menuOrig = STATS.height() * 0.5;
|
||||
@@ -19,18 +19,6 @@ class StatSheet extends Phaser.Scene {
|
||||
this.cryp = cryp;
|
||||
this.stats = new Stats(this, cryp);
|
||||
this.addControls(cryp);
|
||||
this.registry.events.on('changedata', this.updateData, this);
|
||||
}
|
||||
|
||||
updateData(parent, key, data) {
|
||||
if (key === 'cryps') {
|
||||
const cryp = data.find(c => c.id === this.cryp.id);
|
||||
if (this.skillsKnown) this.skillsKnown.destroy(true);
|
||||
if (this.skillsLearn) this.skillsLearn.destroy(true);
|
||||
this.stats.destroy(true);
|
||||
this.stats = new Stats(this, cryp);
|
||||
this.addSkills(cryp);
|
||||
}
|
||||
}
|
||||
|
||||
addControls(cryp) {
|
||||
@@ -40,8 +28,9 @@ class StatSheet extends Phaser.Scene {
|
||||
.setOrigin(0)
|
||||
.on('pointerdown', () => {
|
||||
// Registry events won't get auto cleaned
|
||||
this.registry.events.off('changedata', this.updateData);
|
||||
this.registry.events.off('changedata', this.updateData, this);
|
||||
this.scene.run('CrypList');
|
||||
this.scene.remove('Skills');
|
||||
this.scene.remove('Passives');
|
||||
this.scene.remove();
|
||||
});
|
||||
@@ -92,8 +81,8 @@ class StatSheet extends Phaser.Scene {
|
||||
}
|
||||
|
||||
addSkills(cryp) {
|
||||
this.skillsKnown = new SkillsKnown(this, cryp);
|
||||
this.skillsLearn = new SkillsLearn(this, cryp);
|
||||
this.scene.add('Skills', Skills);
|
||||
this.scene.run('Skills', cryp);
|
||||
}
|
||||
|
||||
addPassives(cryp) {
|
||||
@@ -110,8 +99,7 @@ class StatSheet extends Phaser.Scene {
|
||||
|
||||
removeSkills() {
|
||||
if (!this.skills) return false;
|
||||
this.skillsKnown.destroy(true);
|
||||
this.skillsLearn.destroy(true);
|
||||
this.scene.remove('Skills');
|
||||
this.skills = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user