From 42a2f5937713c317ab25abe130dcb137930e7006 Mon Sep 17 00:00:00 2001 From: panw Date: Thu, 12 Mar 2026 22:07:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=8B=B1=E9=9B=84=E5=B1=9E=E6=80=A7):=20?= =?UTF-8?q?=E6=8A=A4=E7=9B=BE=E5=80=BC=E5=8F=98=E6=9B=B4=E6=97=B6=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E6=9B=B4=E6=96=B0=E6=9C=80=E5=A4=A7=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 处理护盾属性变更时,确保当前值和最大值同时更新,避免护盾最大值未同步导致显示或计算异常。同时添加护盾值非负校验。 --- assets/script/game/hero/HeroAttrsComp.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index cda1ca7e..b74a79cd 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -202,6 +202,16 @@ export class HeroAttrsComp extends ecs.Comp { finalValue = -value; } + // 护盾特殊处理:同时修改当前值和最大值 + if (attr === Attrs.shield && type === BType.VALUE) { + this.shield += finalValue; + this.shield_max += finalValue; + this.shield = Math.max(0, this.shield); + this.shield_max = Math.max(0, this.shield_max); + this.dirty_shield = true; + return; + } + // 处理百分比 // 注意:百分比通常是基于基础值计算,这里简化为直接修改当前值 // 如果需要严格的基础值+百分比,需要维护 baseAttrs 和 bonusAttrs