feat(talent): 重构天赋系统配置并添加图标显示
- 将天赋配置从 TalentsComp.ts 提取到独立的 TalentSet.ts 文件
- 为每个天赋添加图标支持,在天赋名称前显示对应图标
- 改进天赋描述,使用动态数值替换模板中的 {value} 占位符
- 更新天赋项预制件以支持新的配置结构
- 修改 UI 图片资源并调整预制件的视觉样式
This commit is contained in:
@@ -24,37 +24,10 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
|
||||
import { mLogger } from "../common/Logger";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { TalentConfig, TalentInfo } from "../common/config/TalentSet";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**
|
||||
* 天赋系统配置数据
|
||||
*/
|
||||
export const TalentConfig = {
|
||||
// 升级所需经验配置
|
||||
expRequirements: [
|
||||
{ maxLevel: 10, expPerLevel: 100 },
|
||||
{ maxLevel: 20, expPerLevel: 150 },
|
||||
{ maxLevel: 30, expPerLevel: 200 }
|
||||
],
|
||||
// 天赋升级消耗点数
|
||||
costPerLevel: [1, 1, 2, 2, 3], // 第1到第5级消耗
|
||||
|
||||
// 天赋列表
|
||||
talents: [
|
||||
{ id: 1, name: "攻击强化", desc: "所有英雄 ATK +3%", maxLevel: 5 },
|
||||
{ id: 2, name: "生命强化", desc: "所有英雄 HP +5%", maxLevel: 5 },
|
||||
{ id: 3, name: "暴击强化", desc: "所有英雄暴击率 +2%", maxLevel: 5 },
|
||||
{ id: 4, name: "风怒强化", desc: "所有英雄风怒率 +2%", maxLevel: 5 },
|
||||
{ id: 5, name: "冰冻强化", desc: "所有英雄冰冻率 +2%", maxLevel: 5 },
|
||||
{ id: 6, name: "穿刺强化", desc: "所有英雄穿刺 +0.2", maxLevel: 5 },
|
||||
{ id: 7, name: "护盾强化", desc: "所有护盾效果 +5%", maxLevel: 5 },
|
||||
{ id: 8, name: "采购优惠", desc: "购买英雄 -1金", maxLevel: 5 },
|
||||
{ id: 9, name: "刷新优惠", desc: "刷新重抽 -0.5金", maxLevel: 5 },
|
||||
{ id: 10, name: "出售补贴", desc: "出售英雄返还 +10%金币", maxLevel: 5 }
|
||||
]
|
||||
};
|
||||
|
||||
/**
|
||||
* TalentsComp —— 天赋系统界面组件
|
||||
*
|
||||
@@ -186,7 +159,7 @@ export class TalentsComp extends CCComp {
|
||||
}
|
||||
|
||||
/** 更新单个天赋项的显示 */
|
||||
private updateTalentItem(itemNode: Node, talentInfo: any, currentLevel: number) {
|
||||
private updateTalentItem(itemNode: Node, talentInfo: TalentInfo, currentLevel: number) {
|
||||
let lblName = itemNode.getChildByName("lbl_name")?.getComponent(Label);
|
||||
let lblDesc = itemNode.getChildByName("lbl_desc")?.getComponent(Label);
|
||||
let lblLevel = itemNode.getChildByName("lbl_level")?.getComponent(Label);
|
||||
@@ -194,8 +167,15 @@ export class TalentsComp extends CCComp {
|
||||
let btnUpgradeNode = itemNode.getChildByName("btn_upgrade");
|
||||
let btnUpgrade = btnUpgradeNode?.getComponent(Button);
|
||||
|
||||
if (lblName) lblName.string = talentInfo.name;
|
||||
if (lblDesc) lblDesc.string = talentInfo.desc;
|
||||
if (lblName) {
|
||||
lblName.string = (talentInfo.icon ? `${talentInfo.icon} ` : '') + talentInfo.name;
|
||||
}
|
||||
|
||||
if (lblDesc) {
|
||||
let currentVal = talentInfo.getValue(currentLevel);
|
||||
lblDesc.string = talentInfo.desc.replace('{value}', currentVal.toString());
|
||||
}
|
||||
|
||||
if (lblLevel) lblLevel.string = `Lv.${currentLevel}`;
|
||||
|
||||
let isMax = currentLevel >= talentInfo.maxLevel;
|
||||
|
||||
Reference in New Issue
Block a user