Hide retreated battle units
This commit is contained in:
@@ -3506,7 +3506,7 @@ export class BattleScene extends Phaser.Scene {
|
||||
|
||||
this.setUnitBasePosition(view, this.tileCenterX(unit.x), this.tileCenterY(unit.y));
|
||||
view.label.setPosition(view.baseX, view.baseY + this.layout.tileSize * 0.52);
|
||||
const visible = this.isTileVisible(unit.x, unit.y);
|
||||
const visible = unit.hp > 0 && this.isTileVisible(unit.x, unit.y);
|
||||
view.sprite.setVisible(visible);
|
||||
view.label.setVisible(visible);
|
||||
this.syncUnitMotion(unit, view);
|
||||
@@ -3522,14 +3522,16 @@ export class BattleScene extends Phaser.Scene {
|
||||
return;
|
||||
}
|
||||
|
||||
const visible = this.isTileVisible(unit.x, unit.y);
|
||||
if (unit.hp <= 0) {
|
||||
this.applyDefeatedStyle(unit, view);
|
||||
return;
|
||||
}
|
||||
|
||||
const visible = this.isTileVisible(unit.x, unit.y);
|
||||
view.sprite.postFX.clear();
|
||||
view.sprite.clearTint();
|
||||
view.sprite.setAlpha(1);
|
||||
view.sprite.setVisible(visible);
|
||||
|
||||
view.label.setVisible(visible);
|
||||
view.label.setAlpha(1);
|
||||
@@ -9920,8 +9922,7 @@ export class BattleScene extends Phaser.Scene {
|
||||
this.applyUnitLegibilityStyle(unit, view);
|
||||
}
|
||||
|
||||
private applyDefeatedStyle(unit: UnitData) {
|
||||
const view = this.unitViews.get(unit.id);
|
||||
private applyDefeatedStyle(unit: UnitData, view = this.unitViews.get(unit.id)) {
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
@@ -9929,10 +9930,11 @@ export class BattleScene extends Phaser.Scene {
|
||||
view.sprite.stop();
|
||||
view.sprite.disableInteractive();
|
||||
view.sprite.postFX.clear();
|
||||
view.sprite.postFX.addColorMatrix().grayscale(1);
|
||||
view.sprite.setAlpha(1);
|
||||
view.sprite.setTint(0x6f6f6f);
|
||||
view.label.setAlpha(1);
|
||||
view.sprite.clearTint();
|
||||
view.sprite.setAlpha(0);
|
||||
view.sprite.setVisible(false);
|
||||
view.label.setAlpha(0);
|
||||
view.label.setVisible(false);
|
||||
view.label.setColor('#b6b6b6');
|
||||
view.label.setBackgroundColor('');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user