feat(hero-info): 实现自动生成英雄技能描述文本

新增HeroSkillDesc工具类动态生成技能描述字符串
修正heroSet.ts中的技能触发器描述文本
优化HInfoComp组件替换硬编码的英雄信息
完善hnode预制体的info标签配置与样式
This commit is contained in:
panw
2026-05-25 17:01:04 +08:00
parent 3386ccc68c
commit e846e6408c
5 changed files with 164 additions and 25 deletions

View File

@@ -28,6 +28,7 @@ import { smc } from "../common/SingletonModuleComp";
import { TalentType } from "../common/config/TalentSet";
import { Hero } from "../hero/Hero";
import { FieldSkillType } from "../common/config/SkillSet";
import { buildSkillDesc } from "../common/config/HeroSkillDesc";
import { GameEvent } from "../common/config/GameEvent";
import { oops } from "db://oops-framework/core/Oops";
import { UIID } from "../common/config/GameUIConfig";
@@ -176,6 +177,10 @@ export class HInfoComp extends CCComp {
this.hpLabel.string = `${hp}`;
if (this.hpPlusLabel) this.hpPlusLabel.node.active = false;
}
if (this.infoLabel) {
this.infoLabel.string = buildSkillDesc(hero);
}
}
/** 是否正在关闭中,防止重复调用 remove */
@@ -277,7 +282,7 @@ export class HInfoComp extends CCComp {
// ---- 技能信息标签 ----
if (this.infoLabel) {
const heroData = HeroInfo[heroUuid];
this.infoLabel.string = heroData?.info ?? "";
this.infoLabel.string = heroData ? buildSkillDesc(heroData) : "";
}
// ---- 数值标签 ----
@@ -327,7 +332,16 @@ export class HInfoComp extends CCComp {
this.nameLabel = this.Name_node.getComponent(Label) || this.Name_node.getComponentInChildren(Label);
}
if (!this.infoLabel && this.info_node) {
this.infoLabel = this.info_node.getComponent(Label) || this.info_node.getComponentInChildren(Label);
this.infoLabel = this.info_node.getComponentInChildren(Label);
if (!this.infoLabel) {
const child = this.info_node.children[0] || this.info_node;
this.infoLabel = child.getComponent(Label) || child.addComponent(Label);
this.infoLabel.fontSize = 20;
this.infoLabel.lineHeight = 28;
this.infoLabel.overflow = Label.Overflow.SHRINK;
this.infoLabel.horizontalAlign = Label.HorizontalAlign.LEFT;
this.infoLabel.verticalAlign = Label.VerticalAlign.TOP;
}
}
if (!this.apLabel && this.ap_node) {
this.apLabel = this.ap_node.getChildByName("val")?.getComponent(Label) || null;