feat(hero): 添加技能CD进度条显示功能
1. 为英雄顶栏组件新增CD进度条属性与显示逻辑 2. 重构HeroViewComp的cd_show方法,转发调用顶栏CD更新逻辑 3. 调整顶栏默认透明度为全不透明,优化显示体验 4. 根据英雄是否拥有第二技能动态显示CD进度条
This commit is contained in:
@@ -4577,6 +4577,9 @@
|
|||||||
"hpBarSprite": {
|
"hpBarSprite": {
|
||||||
"__id__": 30
|
"__id__": 30
|
||||||
},
|
},
|
||||||
|
"cdProgressBar": {
|
||||||
|
"__id__": 23
|
||||||
|
},
|
||||||
"_id": ""
|
"_id": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ export class HeroTopBarComp extends CCComp {
|
|||||||
@property({ type: Sprite, tooltip: "血条填充 Sprite(用于设置阵营颜色)" })
|
@property({ type: Sprite, tooltip: "血条填充 Sprite(用于设置阵营颜色)" })
|
||||||
private hpBarSprite: Sprite = null!;
|
private hpBarSprite: Sprite = null!;
|
||||||
|
|
||||||
|
@property({ type: ProgressBar, tooltip: "能量条(top 下的 cd 节点,反映 skills[1] 技能 CD)" })
|
||||||
|
private cdProgressBar: ProgressBar = null!;
|
||||||
|
|
||||||
// ==================== 内部引用 ====================
|
// ==================== 内部引用 ====================
|
||||||
private topOpacity: UIOpacity = null!;
|
private topOpacity: UIOpacity = null!;
|
||||||
private basePos: Vec3 = v3();
|
private basePos: Vec3 = v3();
|
||||||
@@ -47,7 +50,8 @@ export class HeroTopBarComp extends CCComp {
|
|||||||
private boss_hp_height: number = 160;
|
private boss_hp_height: number = 160;
|
||||||
|
|
||||||
// ==================== 透明度 ====================
|
// ==================== 透明度 ====================
|
||||||
private readonly barIdleOpacity: number = 153;
|
/** 闲置透明度:取消默认半透明,顶栏常驻全不透明 */
|
||||||
|
private readonly barIdleOpacity: number = 255;
|
||||||
private readonly barActiveOpacity: number = 255;
|
private readonly barActiveOpacity: number = 255;
|
||||||
private readonly idleOpacityDelay: number = 0.25;
|
private readonly idleOpacityDelay: number = 0.25;
|
||||||
|
|
||||||
@@ -89,10 +93,15 @@ export class HeroTopBarComp extends CCComp {
|
|||||||
|
|
||||||
// 重置显示状态
|
// 重置显示状态
|
||||||
this.node.getChildByName("hp")!.active = true;
|
this.node.getChildByName("hp")!.active = true;
|
||||||
this.node.getChildByName("cd")!.active = false;
|
|
||||||
this.node.getChildByName("lv")!.active = false;
|
this.node.getChildByName("lv")!.active = false;
|
||||||
this.node.active = true;
|
this.node.active = true;
|
||||||
|
|
||||||
|
// 能量条:仅当英雄拥有第二技能(skills[1])时显示
|
||||||
|
if (this.cdProgressBar) {
|
||||||
|
this.cdProgressBar.node.active = this._model.getSkillIds().length > 1;
|
||||||
|
}
|
||||||
|
this.cdShow();
|
||||||
|
|
||||||
// debuff 图标容器(无该节点的旧 prefab 容错为 null)
|
// debuff 图标容器(无该节点的旧 prefab 容错为 null)
|
||||||
this.debuffNode = this.node.getChildByName("debuff")!;
|
this.debuffNode = this.node.getChildByName("debuff")!;
|
||||||
this.activeDebuffNames.clear();
|
this.activeDebuffNames.clear();
|
||||||
@@ -135,6 +144,22 @@ export class HeroTopBarComp extends CCComp {
|
|||||||
this.shieldProgressBar.node.active = shield > 0;
|
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 种类点亮对应图标。
|
* 刷新 debuff 图标显隐:按 BuffComp 中当前生效的 debuff 种类点亮对应图标。
|
||||||
* 由 HeroViewComp 在 dirty_buffs 脏标记时调用;与上次状态做 diff,避免重复 set active。
|
* 由 HeroViewComp 在 dirty_buffs 脏标记时调用;与上次状态做 diff,避免重复 set active。
|
||||||
|
|||||||
@@ -150,8 +150,9 @@ export class HeroViewComp extends CCComp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 技能 CD 显示:由 SCastSystem 每帧 updateCD 后调用,刷新能量条进度 */
|
||||||
public cd_show() {
|
public cd_show() {
|
||||||
return;
|
this.topBar.cdShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 升级特效 */
|
/** 升级特效 */
|
||||||
|
|||||||
Reference in New Issue
Block a user