Reduce armour and spellshield bars during combat
This commit is contained in:
parent
2d918af744
commit
6b4662dd2f
@ -84,7 +84,7 @@ class CrypImage extends Phaser.GameObjects.Image {
|
|||||||
// Add cryp name
|
// Add cryp name
|
||||||
scene.add.text(nameX, nameY, cryp.name, TEXT.NORMAL).setOrigin(team, 0);
|
scene.add.text(nameX, nameY, cryp.name, TEXT.NORMAL).setOrigin(team, 0);
|
||||||
// Add cryp stat bars
|
// Add cryp stat bars
|
||||||
this.healthBar = scene.add.existing(new StatBar(scene, this, 'HP'));
|
this.health = scene.add.existing(new StatBar(scene, this, 'HP'));
|
||||||
this.armour = scene.add.existing(new StatBar(scene, this, 'Armour'));
|
this.armour = scene.add.existing(new StatBar(scene, this, 'Armour'));
|
||||||
this.evasion = scene.add.existing(new StatBar(scene, this, 'Evasion'));
|
this.evasion = scene.add.existing(new StatBar(scene, this, 'Evasion'));
|
||||||
this.spellShield = scene.add.existing(new StatBar(scene, this, 'Spell Shield'));
|
this.spellShield = scene.add.existing(new StatBar(scene, this, 'Spell Shield'));
|
||||||
@ -114,10 +114,27 @@ class CrypImage extends Phaser.GameObjects.Image {
|
|||||||
this.statusText.text = '';
|
this.statusText.text = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
takeDamage(damage) {
|
reduceDefense(amount, type) {
|
||||||
if (damage > 0) this.setTint(0xff0000);
|
if (type === 'PhysDmg') {
|
||||||
else this.setTint(0x00bb00);
|
this.armour.takeDamage(amount);
|
||||||
this.healthBar.takeDamage(damage);
|
} else if (type === 'SpellDmg') {
|
||||||
|
this.spellShield.takeDamage(amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
takeDamage(props) {
|
||||||
|
const { amount, mitigation, category } = props;
|
||||||
|
if (mitigation) this.reduceDefense(mitigation, category);
|
||||||
|
this.setTint(0xff0000);
|
||||||
|
this.health.takeDamage(amount);
|
||||||
|
this.scene.time.delayedCall(DELAYS.DAMAGE_TICK, () => {
|
||||||
|
if (this.state !== 'ko') this.clearTint();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
takeHealing(amount) {
|
||||||
|
this.setTint(0x00bb00);
|
||||||
|
this.health.takeDamage(amount * -1);
|
||||||
this.scene.time.delayedCall(DELAYS.DAMAGE_TICK, () => {
|
this.scene.time.delayedCall(DELAYS.DAMAGE_TICK, () => {
|
||||||
if (this.state !== 'ko') this.clearTint();
|
if (this.state !== 'ko') this.clearTint();
|
||||||
});
|
});
|
||||||
@ -171,8 +188,8 @@ 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.healthBar.hp = cryp.hp.base;
|
crypObj.health.hp = cryp.hp.base;
|
||||||
crypObj.healthBar.drawStatBar();
|
crypObj.health.drawStatBar();
|
||||||
crypObj.effects.update(cryp.effects);
|
crypObj.effects.update(cryp.effects);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -88,12 +88,12 @@ function animatePhase(scene, game, resolution, cb) {
|
|||||||
|
|
||||||
const [resultType, values] = result;
|
const [resultType, values] = result;
|
||||||
if (resultType === 'Damage') {
|
if (resultType === 'Damage') {
|
||||||
targetSpawn.takeDamage(values.amount);
|
targetSpawn.takeDamage(values);
|
||||||
scene.registry.set('gameLog', scene.registry.get('gameLog') + 1);
|
scene.registry.set('gameLog', scene.registry.get('gameLog') + 1);
|
||||||
return setTimeout(tickCb, DAMAGE_TICK);
|
return setTimeout(tickCb, DAMAGE_TICK);
|
||||||
}
|
}
|
||||||
if (resultType === 'Healing') {
|
if (resultType === 'Healing') {
|
||||||
targetSpawn.takeDamage(values.amount * -1);
|
targetSpawn.takeHealing(values.amount);
|
||||||
scene.registry.set('gameLog', scene.registry.get('gameLog') + 1);
|
scene.registry.set('gameLog', scene.registry.get('gameLog') + 1);
|
||||||
return setTimeout(tickCb, DAMAGE_TICK);
|
return setTimeout(tickCb, DAMAGE_TICK);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,7 +78,7 @@ class StatBar extends Phaser.GameObjects.Graphics {
|
|||||||
} else {
|
} else {
|
||||||
this.val = (this.val - value > this.max) ? this.max : this.val -= value;
|
this.val = (this.val - value > this.max) ? this.max : this.val -= value;
|
||||||
}
|
}
|
||||||
if (this.val === 0) this.crypObj.setKo();
|
if (this.val === 0 && this.type === 'HP') this.crypObj.setKo();
|
||||||
this.drawStatBar();
|
this.drawStatBar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ const Y = ITEM_LIST.y();
|
|||||||
const WIDTH = ITEM_LIST.width();
|
const WIDTH = ITEM_LIST.width();
|
||||||
const HEIGHT = ITEM_LIST.height();
|
const HEIGHT = ITEM_LIST.height();
|
||||||
const ITEM_WIDTH = WIDTH * 0.4;
|
const ITEM_WIDTH = WIDTH * 0.4;
|
||||||
const ITEM_HEIGHT = HEIGHT * 0.1;
|
const ITEM_HEIGHT = HEIGHT * 0.08;
|
||||||
|
|
||||||
const itemCheckHitbox = (scenePlugin, pointer) => {
|
const itemCheckHitbox = (scenePlugin, pointer) => {
|
||||||
const { list } = scenePlugin.get('MenuCrypList').children;
|
const { list } = scenePlugin.get('MenuCrypList').children;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user