fix(英雄属性): 护盾值变更时同步更新最大值
处理护盾属性变更时,确保当前值和最大值同时更新,避免护盾最大值未同步导致显示或计算异常。同时添加护盾值非负校验。
This commit is contained in:
@@ -202,6 +202,16 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
finalValue = -value;
|
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
|
// 如果需要严格的基础值+百分比,需要维护 baseAttrs 和 bonusAttrs
|
||||||
|
|||||||
Reference in New Issue
Block a user