fix(map): 调整英雄站位坐标并新增CD标签显示
1. 修正MissionHeroComp中的6个英雄占位坐标 2. 在HInfoComp中新增CD标签缓存引用并实现技能CD显示逻辑 3. 更新hnode.prefab的UI布局尺寸与元素位置适配新需求
This commit is contained in:
@@ -104,6 +104,8 @@ export class HInfoComp extends CCComp {
|
||||
private hpLabel: Label | null = null;
|
||||
/** HP 加成标签缓存引用 */
|
||||
private hpPlusLabel: Label | null = null;
|
||||
/** CD 标签缓存引用 */
|
||||
private cdLabel: Label | null = null;
|
||||
/** 图标视觉令牌(异步加载竞态保护) */
|
||||
private iconVisualToken: number = 0;
|
||||
/** 当前显示的英雄 UUID(避免相同 UUID 重复加载动画) */
|
||||
@@ -184,6 +186,12 @@ export class HInfoComp extends CCComp {
|
||||
if (this.infoLabel) {
|
||||
this.infoLabel.string = buildSkillDesc(hero);
|
||||
}
|
||||
|
||||
if (this.cdLabel) {
|
||||
const skillKeys = hero.skills ? Object.keys(hero.skills) : [];
|
||||
const displaySkill = skillKeys.length > 1 ? hero.skills[skillKeys[1]] : (skillKeys.length > 0 ? hero.skills[skillKeys[0]] : null);
|
||||
this.cdLabel.string = displaySkill?.cd ? `${displaySkill.cd.toFixed(1)}s` : "0s";
|
||||
}
|
||||
}
|
||||
|
||||
/** 是否正在关闭中,防止重复调用 remove */
|
||||
@@ -317,6 +325,17 @@ export class HInfoComp extends CCComp {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.cdLabel) {
|
||||
const skillIds = this.model.getSkillIds();
|
||||
const displaySkillId = skillIds[1] ?? skillIds[0] ?? 0;
|
||||
if (displaySkillId) {
|
||||
const effectiveCd = this.model.getEffectiveSkillCd(displaySkillId);
|
||||
this.cdLabel.string = effectiveCd > 0 ? `${effectiveCd.toFixed(1)}s` : "0s";
|
||||
} else {
|
||||
this.cdLabel.string = "0s";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -354,6 +373,9 @@ export class HInfoComp extends CCComp {
|
||||
this.hpLabel = this.hp_node.getChildByName("val")?.getComponent(Label) || null;
|
||||
this.hpPlusLabel = this.hp_node.getChildByName("plus")?.getComponent(Label) || null;
|
||||
}
|
||||
if (!this.cdLabel && this.cd_node) {
|
||||
this.cdLabel = this.cd_node.getChildByName("val")?.getComponent(Label) || null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user