Moved skills and they disappear when animation starts
This commit is contained in:
parent
879110435f
commit
0e9a2a4ee6
@ -43,8 +43,9 @@ class CrypImage extends Phaser.GameObjects.Image {
|
|||||||
super(scene, crypAvatarX, crypAvatarY, avatar);
|
super(scene, crypAvatarX, crypAvatarY, avatar);
|
||||||
this.scene = scene;
|
this.scene = scene;
|
||||||
this.cryp = cryp;
|
this.cryp = cryp;
|
||||||
this.iter = iter;
|
|
||||||
this.healthbar = healthbar;
|
this.healthbar = healthbar;
|
||||||
|
this.iter = iter;
|
||||||
|
this.team = team;
|
||||||
}
|
}
|
||||||
|
|
||||||
clickHandler() {
|
clickHandler() {
|
||||||
@ -113,8 +114,6 @@ class HealthBar extends Phaser.GameObjects.Graphics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const CRYP_KEY_MAP = ['keydown_ONE', 'keydown_TWO', 'keydown_THREE'];
|
|
||||||
|
|
||||||
class CombatCryps extends Phaser.Scene {
|
class CombatCryps extends Phaser.Scene {
|
||||||
constructor() {
|
constructor() {
|
||||||
super({ key: 'CombatCryps' });
|
super({ key: 'CombatCryps' });
|
||||||
|
|||||||
@ -92,12 +92,14 @@ class Combat extends Phaser.Scene {
|
|||||||
const cantAnimate = this.registry.get('gameAnimating') || !this.registry.get('crypLoaded');
|
const cantAnimate = this.registry.get('gameAnimating') || !this.registry.get('crypLoaded');
|
||||||
if (cantAnimate) return false;
|
if (cantAnimate) return false;
|
||||||
if (game.resolved.length !== this.renderedResolves) {
|
if (game.resolved.length !== this.renderedResolves) {
|
||||||
|
this.registry.set('gamePhase', 'animating');
|
||||||
this.registry.set('gameLog', this.registry.get('gameLog') + 1);
|
this.registry.set('gameLog', this.registry.get('gameLog') + 1);
|
||||||
const newResolutions = game.resolved.slice(this.renderedResolves);
|
const newResolutions = game.resolved.slice(this.renderedResolves);
|
||||||
renderResolutions(this, game, newResolutions);
|
renderResolutions(this, game, newResolutions);
|
||||||
this.renderedResolves = game.resolved.length;
|
this.renderedResolves = game.resolved.length;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
this.registry.set('gamePhase', game.phase);
|
||||||
if (this.registry.get('gameLog') !== game.log.length) {
|
if (this.registry.get('gameLog') !== game.log.length) {
|
||||||
this.registry.set('gameLog', game.log.length);
|
this.registry.set('gameLog', game.log.length);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,6 +22,13 @@ const skillTextPosition = (crypIter, skillIter) => {
|
|||||||
return [skillTextX, skillTextY];
|
return [skillTextX, skillTextY];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const targetTextPosition = (crypIter, teamIter) => {
|
||||||
|
const { CRYP_MARGIN, TEAM_MARGIN, Y_PADDING } = calcMargin();
|
||||||
|
const skillTextX = COMBAT.width() / 5 + 0.7 * TEAM_MARGIN * teamIter;
|
||||||
|
const skillTextY = Y_PADDING * 1.25 + CRYP_MARGIN * crypIter;
|
||||||
|
return [ skillTextX, skillTextY ];
|
||||||
|
};
|
||||||
|
|
||||||
class CrypName extends Phaser.GameObjects.Text {
|
class CrypName extends Phaser.GameObjects.Text {
|
||||||
constructor(scene, x, y, cryp) {
|
constructor(scene, x, y, cryp) {
|
||||||
super(scene, x, y, cryp.name, TEXT.HEADER);
|
super(scene, x, y, cryp.name, TEXT.HEADER);
|
||||||
@ -70,17 +77,23 @@ class CombatSkills extends Phaser.Scene {
|
|||||||
this.registry.events.on('changedata', this.updateData, this);
|
this.registry.events.on('changedata', this.updateData, this);
|
||||||
this.account = this.registry.get('account');
|
this.account = this.registry.get('account');
|
||||||
|
|
||||||
|
this.input.on('pointerup', (pointer, obj) => {
|
||||||
|
if (obj[0] instanceof CrypSkill) {
|
||||||
|
obj[0].clickHandler();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// can't set this.game cause of phaser class named the same
|
// can't set this.game cause of phaser class named the same
|
||||||
const game = this.registry.get('game');
|
const game = this.registry.get('game');
|
||||||
this.phase = game.phase;
|
this.phase = this.registry.get('gamePhase');
|
||||||
this.renderSkills(game);
|
this.renderSkills(game);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateData(parent, key, data) {
|
updateData(parent, key, data) {
|
||||||
if (key === 'game' && data) {
|
if (key === 'gamePhase' && data) {
|
||||||
const shouldUpdate = data.phase !== this.phase;
|
const shouldUpdate = data !== this.phase;
|
||||||
if (shouldUpdate) return this.scene.restart();
|
if (shouldUpdate) return this.scene.restart();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -88,14 +101,14 @@ class CombatSkills extends Phaser.Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderSkills(game) {
|
renderSkills(game) {
|
||||||
if (game.phase === 'Skill') return this.renderSkillPhase(game);
|
if (this.phase === 'Skill') return this.renderSkillPhase(game);
|
||||||
if (game.phase === 'Target') return this.renderTargetPhase(game);
|
if (this.phase === 'Target') return this.renderTargetPhase(game);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderSkillPhase(game) {
|
renderSkillPhase(game) {
|
||||||
const { account, scene } = this;
|
const { account } = this;
|
||||||
const { keyboard } = this.input;
|
const { keyboard } = this.input;
|
||||||
const { events } = this.game;
|
const { events } = this.game;
|
||||||
|
|
||||||
@ -180,7 +193,7 @@ class CombatSkills extends Phaser.Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderTargetPhase(game) {
|
renderTargetPhase(game) {
|
||||||
const { account, scene } = this;
|
const { account } = this;
|
||||||
const { keyboard } = this.input;
|
const { keyboard } = this.input;
|
||||||
|
|
||||||
const skills = game.stack.filter(skill => skill.target_team_id === account.id);
|
const skills = game.stack.filter(skill => skill.target_team_id === account.id);
|
||||||
@ -191,10 +204,12 @@ class CombatSkills extends Phaser.Scene {
|
|||||||
const cryp = crypTeam.cryps.find(c => c.id === skill.source_cryp_id);
|
const cryp = crypTeam.cryps.find(c => c.id === skill.source_cryp_id);
|
||||||
|
|
||||||
// Draw the cryp name
|
// Draw the cryp name
|
||||||
const namePos = skillTextPosition(i, 0);
|
// const namePos = skillTextPosition(i, 0);
|
||||||
this.add.existing(new CrypName(this, namePos[0], namePos[1], cryp));
|
// this.add.existing(new CrypName(this, namePos[0], namePos[1], cryp));
|
||||||
|
const sourceCryp = this.scene.get('CombatCryps').cryps.children.entries
|
||||||
|
.find(c => c.cryp.id === cryp.id);
|
||||||
|
|
||||||
const skillPos = skillTextPosition(i, 2);
|
const skillPos = targetTextPosition(sourceCryp.iter, sourceCryp.team);
|
||||||
const skillObj = new CrypSkill(this, skillPos[0], skillPos[1], skill, cryp);
|
const skillObj = new CrypSkill(this, skillPos[0], skillPos[1], skill, cryp);
|
||||||
this.add.existing(skillObj);
|
this.add.existing(skillObj);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user