feat(天赋系统): 实现天赋效果并应用至相关游戏系统
- 在 MissionCardComp 中应用 RefreshDiscount 天赋以减少刷新消耗 - 在 CardComp 中应用 BuyDiscount 天赋以减少英雄购买消耗 - 在 HInfoComp 中应用 SellBonus 天赋以增加英雄出售收益 - 统一 TalentType 枚举类型,增强类型安全性 - 更新 SingletonModuleComp 中 talents 数据结构以支持类型化 - 修改 HeroAttrsComp.getTalentValue 方法参数类型为 TalentType
This commit is contained in:
@@ -24,7 +24,7 @@ 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";
|
||||
import { TalentConfig, TalentInfo, TalentType } from "../common/config/TalentSet";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -145,14 +145,14 @@ export class TalentsComp extends CCComp {
|
||||
TalentConfig.talents.forEach(talentInfo => {
|
||||
let itemNode = instantiate(this.prefab_talent_item);
|
||||
this.talents_content.addChild(itemNode);
|
||||
this.updateTalentItem(itemNode, talentInfo, collection.talents[talentInfo.id] || 0);
|
||||
this.updateTalentItem(itemNode, talentInfo, collection.talents[talentInfo.id as TalentType] || 0);
|
||||
});
|
||||
} else {
|
||||
// 否则直接更新现有节点
|
||||
TalentConfig.talents.forEach((talentInfo, index) => {
|
||||
let itemNode = this.talents_content.children[index];
|
||||
if (itemNode) {
|
||||
this.updateTalentItem(itemNode, talentInfo, collection.talents[talentInfo.id] || 0);
|
||||
this.updateTalentItem(itemNode, talentInfo, collection.talents[talentInfo.id as TalentType] || 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -197,7 +197,7 @@ export class TalentsComp extends CCComp {
|
||||
}
|
||||
|
||||
/** 点击升级按钮 */
|
||||
private onUpgradeClicked(talentId: number, currentLevel: number, cost: number) {
|
||||
private onUpgradeClicked(talentId: TalentType, currentLevel: number, cost: number) {
|
||||
const collection = smc.collection;
|
||||
let points = collection.talent_points || 0;
|
||||
|
||||
@@ -228,8 +228,9 @@ export class TalentsComp extends CCComp {
|
||||
// 计算已消耗的天赋点总和
|
||||
let refundedPoints = 0;
|
||||
for (let id in collection.talents) {
|
||||
let level = collection.talents[id];
|
||||
let talentInfo = TalentConfig.talents.find(t => t.id === Number(id));
|
||||
let talentId = Number(id) as TalentType;
|
||||
let level = collection.talents[talentId] || 0;
|
||||
let talentInfo = TalentConfig.talents.find(t => t.id === talentId);
|
||||
if (talentInfo) {
|
||||
for (let i = 0; i < level; i++) {
|
||||
refundedPoints += talentInfo.costs[i];
|
||||
|
||||
Reference in New Issue
Block a user