feat(skill&shield): 实现护盾持续时间功能,调整魔法盾冷却

1.  为护盾技能添加duration配置,支持永久/限时护盾
2.  新增护盾倒计时逻辑,到期自动清空护盾
3.  调整英雄6301魔法盾的冷却时间为10秒,新增7秒持续时长配置
4.  重构HeroAttrsComp,新增护盾持续时间字段与清空护盾方法
This commit is contained in:
panFD
2026-09-13 14:04:00 +08:00
parent 4f749c9a81
commit ed9232cf0b
5 changed files with 46 additions and 10 deletions

View File

@@ -42,6 +42,8 @@ export class HeroAttrsComp extends ecs.Comp {
shield: number = 0; // 当前护盾
/** 护盾获得时的快照值,作为护盾进度条分母(护盾为覆盖语义,分母不能随扣盾变化) */
shield_max: number = 0;
/** 护盾剩余持续时间(秒),<=0 表示永久护盾;由 BuffSystem 定时递减,归零时清空护盾 */
shield_duration: number = 0;
defense: number = 0; // 防御(除法递减模型减伤,见 getFinalDefense)
// ==================== 攻击属性 (补充) ====================
@@ -168,13 +170,27 @@ export class HeroAttrsComp extends ecs.Comp {
*
* Why 覆盖而非累加:新护盾直接替换旧护盾,避免多源护盾无限叠加导致数值膨胀。
* @param value 新的护盾值(<=0 时视为清空护盾)
* @param duration 护盾持续时间(秒),<=0 或不传表示永久护盾;到期由 BuffSystem 清空
*/
add_shield(value: number) {
add_shield(value: number, duration: number = 0) {
this.shield = Math.max(0, Math.floor(value));
// 覆盖为新护盾时刷新快照分母;清空护盾时分母归零
this.shield_max = this.shield;
this.shield_duration = Math.max(0, duration);
this.dirty_shield = true; // 标记护盾需要更新
}
/**
* 清空护盾(护盾到期或外部强制驱散时调用)。
* 直接置零并打脏标记,视图层据此隐藏护盾条与特效。
*/
clear_shield() {
if (this.shield <= 0) return;
this.shield = 0;
this.shield_max = 0;
this.shield_duration = 0;
this.dirty_shield = true;
}
add_hp_max(value: number) {
this.hp_max += value
this.hp += value
@@ -701,6 +717,7 @@ export class HeroAttrsComp extends ecs.Comp {
this.dis = 100;
this.shield = 0;
this.shield_max = 0;
this.shield_duration = 0;
this.defense = 0;
// 重置新增属性