From d6e8cb48287376360057bb2ce7ac36797549d59e Mon Sep 17 00:00:00 2001 From: pan Date: Wed, 19 Aug 2026 16:05:58 +0800 Subject: [PATCH] =?UTF-8?q?feat(hero):=20=E6=B7=BB=E5=8A=A0=E6=8A=80?= =?UTF-8?q?=E8=83=BDCD=E8=BF=9B=E5=BA=A6=E6=9D=A1=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 为英雄顶栏组件新增CD进度条属性与显示逻辑 2. 重构HeroViewComp的cd_show方法,转发调用顶栏CD更新逻辑 3. 调整顶栏默认透明度为全不透明,优化显示体验 4. 根据英雄是否拥有第二技能动态显示CD进度条 --- assets/resources/game/heros/top.prefab | 3 +++ assets/script/game/hero/HeroTopBarComp.ts | 29 +++++++++++++++++++++-- assets/script/game/hero/HeroViewComp.ts | 3 ++- 3 files changed, 32 insertions(+), 3 deletions(-) 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(); } /** 升级特效 */