refactor(TIBoxComp): 重构天赋文本渲染逻辑
1. 拆分天赋文本构建为精准渲染和详情组装两个方法 2. 改用天赋配置对象直接替换占位符,移除对getTalentDisplayText的依赖 3. 更新注释说明和导入依赖,修正文档中遗漏的TalentConfig配置项 4. 修复Lv0等级的天赋预览逻辑,改为按1级数值展示引导
This commit is contained in:
@@ -13,14 +13,14 @@
|
||||
* oops.gui.open(UIID.TIBox, { uuid: 9001 });
|
||||
*
|
||||
* 依赖:
|
||||
* - TalentSet(配置与校验:isTalentTierUnlocked/isTalentPrereqMet/getTalentUpgradeCost/getTalentDisplayText)
|
||||
* - TalentSet(TalentConfig 配置与校验:isTalentTierUnlocked/isTalentPrereqMet/getTalentUpgradeCost)
|
||||
* - smc —— 天赋等级表 / 点数 / upgradeTalent / 图标图集
|
||||
* - outlineRich —— RichText 条幅描边
|
||||
*/
|
||||
import { _decorator, EventTouch, Label, Node, NodeEventType, RichText, Sprite, SpriteFrame } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { TalentSet, getTalentDisplayText, getTalentUpgradeCost, isTalentPrereqMet, isTalentTierUnlocked } from "../common/config/TalentSet";
|
||||
import { TalentSet, TalentConfig, getTalentUpgradeCost, isTalentPrereqMet, isTalentTierUnlocked } from "../common/config/TalentSet";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { HRoleName } from "../common/config/heroSet";
|
||||
import { outlineRich } from "../common/RichOutline";
|
||||
@@ -139,17 +139,33 @@ export class TIBoxComp extends CCComp {
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建天赋详情条幅文本:当前生效数值 + 下一级预览 + 满级提示
|
||||
* 按等级精准渲染天赋 info 模板({value}/{value2} 占位替换为实际数值)。
|
||||
* Lv0 时按 1 级数值预览(引导加点)。
|
||||
* @param cfg 天赋配置
|
||||
* @param lv 当前等级
|
||||
* @returns 替换占位后的完整描述文本
|
||||
*/
|
||||
private buildPreciseText(cfg: TalentConfig, lv: number): string {
|
||||
const mult = lv > 0 ? lv : 1;
|
||||
const v1 = cfg.bonuses[0]?.per_lv ?? cfg.t_num_reduce_per_lv ?? cfg.extra_trigger_chance_per_lv ?? 0;
|
||||
const v2 = cfg.bonuses[1]?.per_lv ?? 0;
|
||||
return cfg.info
|
||||
.replace("{value}", `${v1 * mult}`)
|
||||
.replace("{value2}", `${v2 * mult}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建天赋详情条幅文本:精准描述 + 下一级预览 + 满级提示
|
||||
* @param cfg 天赋配置
|
||||
* @param lv 当前等级
|
||||
*/
|
||||
private buildDetailText(cfg: typeof TalentSet[number], lv: number): string {
|
||||
private buildDetailText(cfg: TalentConfig, lv: number): string {
|
||||
const lines: string[] = [];
|
||||
// 当前已生效数值(Lv0 显示每级引导)
|
||||
lines.push(getTalentDisplayText(cfg, lv));
|
||||
// 精准效果描述:使用 cfg.info 模板按当前等级替换数值占位
|
||||
lines.push(this.buildPreciseText(cfg, lv));
|
||||
// 未满级:追加下一级预览
|
||||
if (lv < cfg.max_lv) {
|
||||
lines.push(`<color=#E0A93D>下一级:${getTalentDisplayText(cfg, lv + 1)}</color>`);
|
||||
lines.push(`<color=#E0A93D>下一级:${this.buildPreciseText(cfg, lv + 1)}</color>`);
|
||||
} else {
|
||||
lines.push(`<color=#FFD700>已满级</color>`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user