diff --git a/assets/resources/game/heros/top.prefab b/assets/resources/game/heros/top.prefab index dfa79343..cf475089 100644 --- a/assets/resources/game/heros/top.prefab +++ b/assets/resources/game/heros/top.prefab @@ -4577,6 +4577,9 @@ "hpBarSprite": { "__id__": 30 }, + "cdProgressBar": { + "__id__": 23 + }, "_id": "" }, { diff --git a/assets/script/game/hero/HeroTopBarComp.ts b/assets/script/game/hero/HeroTopBarComp.ts index f36968cf..f09ec21a 100644 --- a/assets/script/game/hero/HeroTopBarComp.ts +++ b/assets/script/game/hero/HeroTopBarComp.ts @@ -34,6 +34,9 @@ export class HeroTopBarComp extends CCComp { @property({ type: Sprite, tooltip: "血条填充 Sprite(用于设置阵营颜色)" }) private hpBarSprite: Sprite = null!; + @property({ type: ProgressBar, tooltip: "能量条(top 下的 cd 节点,反映 skills[1] 技能 CD)" }) + private cdProgressBar: ProgressBar = null!; + // ==================== 内部引用 ==================== private topOpacity: UIOpacity = null!; private basePos: Vec3 = v3(); @@ -47,7 +50,8 @@ export class HeroTopBarComp extends CCComp { private boss_hp_height: number = 160; // ==================== 透明度 ==================== - private readonly barIdleOpacity: number = 153; + /** 闲置透明度:取消默认半透明,顶栏常驻全不透明 */ + private readonly barIdleOpacity: number = 255; private readonly barActiveOpacity: number = 255; private readonly idleOpacityDelay: number = 0.25; @@ -89,10 +93,15 @@ export class HeroTopBarComp extends CCComp { // 重置显示状态 this.node.getChildByName("hp")!.active = true; - this.node.getChildByName("cd")!.active = false; this.node.getChildByName("lv")!.active = false; this.node.active = true; + // 能量条:仅当英雄拥有第二技能(skills[1])时显示 + if (this.cdProgressBar) { + this.cdProgressBar.node.active = this._model.getSkillIds().length > 1; + } + this.cdShow(); + // debuff 图标容器(无该节点的旧 prefab 容错为 null) this.debuffNode = this.node.getChildByName("debuff")!; this.activeDebuffNames.clear(); @@ -135,6 +144,22 @@ export class HeroTopBarComp extends CCComp { this.shieldProgressBar.node.active = shield > 0; } + /** + * 更新能量条进度(= skills[1] 的 CD 充能比例,充满即技能就绪)。 + * 由 SCastSystem 每帧 updateCD 后经 HeroViewComp.cd_show 驱动。 + */ + public cdShow(): void { + if (!this._model || !this.cdProgressBar) return; + const skillIds = this._model.getSkillIds(); + // 无第二技能时隐藏能量条 + if (skillIds.length <= 1) { + this.cdProgressBar.node.active = false; + return; + } + this.cdProgressBar.node.active = true; + this.cdProgressBar.progress = clamp(this._model.getSkillCdProgress(skillIds[1]), 0, 1); + } + /** * 刷新 debuff 图标显隐:按 BuffComp 中当前生效的 debuff 种类点亮对应图标。 * 由 HeroViewComp 在 dirty_buffs 脏标记时调用;与上次状态做 diff,避免重复 set active。 diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index 97425073..726a7da7 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -150,8 +150,9 @@ export class HeroViewComp extends CCComp { } } + /** 技能 CD 显示:由 SCastSystem 每帧 updateCD 后调用,刷新能量条进度 */ public cd_show() { - return; + this.topBar.cdShow(); } /** 升级特效 */