Sync stat bars after combat turn

This commit is contained in:
Mashy 2019-03-26 13:24:27 +10:00
parent 2b22b85acb
commit 62b673ed1d
3 changed files with 14 additions and 5 deletions

View File

@ -27,7 +27,7 @@ class CombatSkills extends Phaser.GameObjects.Group {
} }
getSkill(type, isAlly, castLocation) { getSkill(type, isAlly, castLocation) {
const genericHeal = ['Heal', 'Triage', 'TriageTick']; const genericHeal = ['Heal', 'Triage', 'TriageTick', 'DecayTick'];
const genericBlock = ['Block', 'Parry', 'Evasion', 'Shield']; const genericBlock = ['Block', 'Parry', 'Evasion', 'Shield'];
if (genericHeal.includes(type)) { if (genericHeal.includes(type)) {

View File

@ -158,14 +158,17 @@ class CombatCryps extends Phaser.Scene {
updateData(parent, key, data) { updateData(parent, key, data) {
if (key === 'game' && data) { if (key === 'game' && data) {
const isAnimating = this.phase === 'animating'; const isAnimating = this.phase === 'animating';
this.game = data;
if (isAnimating) return false; if (isAnimating) return false;
this.drawCryps(data);
} }
if (key === 'gamePhase' && data) { if (key === 'gamePhase' && data) {
const shouldUpdate = data !== this.phase; const shouldUpdate = data !== this.phase;
this.phase = data; this.phase = data;
if (shouldUpdate) this.cryps.children.entries.forEach(c => c.clearStatus()); if (shouldUpdate) {
this.cryps.children.entries.forEach(c => c.clearStatus());
this.drawCryps(this.game);
}
} }
if (key === 'crypStatusUpdate' && data) { if (key === 'crypStatusUpdate' && data) {
@ -188,8 +191,13 @@ class CombatCryps extends Phaser.Scene {
const crypObj = this.cryps.children.entries const crypObj = this.cryps.children.entries
.find(c => c.cryp.id === cryp.id) .find(c => c.cryp.id === cryp.id)
|| renderCryp(cryp, iter, team); || renderCryp(cryp, iter, team);
crypObj.health.hp = cryp.hp.value; crypObj.health.val = cryp.hp.value;
crypObj.red_shield.val = cryp.red_shield.value;
crypObj.blue_shield.val = cryp.red_shield.value;
crypObj.health.drawStatBar(); crypObj.health.drawStatBar();
crypObj.red_shield.drawStatBar();
crypObj.blue_shield.drawStatBar();
crypObj.effects.update(cryp.effects); crypObj.effects.update(cryp.effects);
}; };

View File

@ -47,7 +47,7 @@ function calculateTweenParams(sourceSpawn, targetSpawn, account) {
function animatePhase(scene, game, resolution, cb) { function animatePhase(scene, game, resolution, cb) {
// return early for disabled skills // return early for disabled skills
if (resolution.length === 0) return cb(); if (resolution.length === 0) return cb();
if (resolution.event[0] === 'Disable') return cb(); if (resolution.event[0] === 'Disable' || resolution.event[0] === 'TargetKo') return cb();
const group = scene.scene.get('CombatCryps').cryps; const group = scene.scene.get('CombatCryps').cryps;
const animations = new CombatAnimations(scene); const animations = new CombatAnimations(scene);
@ -76,6 +76,7 @@ function animatePhase(scene, game, resolution, cb) {
animations.getSkill(resolution.skill, isAlly, castLocation); animations.getSkill(resolution.skill, isAlly, castLocation);
// Target cryp takes damage // Target cryp takes damage
scene.time.delayedCall(ANIMATION_DURATION, () => { scene.time.delayedCall(ANIMATION_DURATION, () => {
console.log(resolution);
if (resolution.event[0] === 'Damage') { if (resolution.event[0] === 'Damage') {
targetSpawn.takeDamage(resolution.event[1]); targetSpawn.takeDamage(resolution.event[1]);
scene.registry.set('gameLog', scene.registry.get('gameLog') + 1); scene.registry.set('gameLog', scene.registry.get('gameLog') + 1);