refactor(map): 重构局内经济系统,统一封装金币操作逻辑

新建MissionEconomy类作为局内经济统一管理入口,整合原分散在HInfoComp、MissionComp、CardComp、MissionCardComp中的金币计算、消费、收益统计逻辑,移除各组件中重复的getMissionCoin、setMissionCoin、getRefreshCost等工具方法,统一维护评分系统的金币统计,提升代码可维护性。
This commit is contained in:
panw
2026-05-21 09:51:32 +08:00
parent 5cdb50b760
commit bbd3e01ae5
6 changed files with 164 additions and 103 deletions

View File

@@ -35,6 +35,7 @@ import { mLogger } from "../common/Logger";
import { MissionHeroCompComp } from "./MissionHeroComp";
import { MoveComp } from "../hero/MoveComp";
import { FacSet } from "../common/config/GameSet";
import { MissionEconomy } from "./MissionEconomy";
const {property, ccclass } = _decorator;
@@ -311,19 +312,8 @@ export class HInfoComp extends CCComp {
});
if (!removed) return;
// 卖出英雄金币收益
const baseSellGold = 1; // 基础卖出金币
const goldBoost = HeroAttrsComp.getFieldSkillTotalValue(FieldSkillType.SellGold);
let totalSellGold = baseSellGold + goldBoost;
// 应用天赋 SellBonus (增加数值)
const bonusGold = HeroAttrsComp.getTalentValue(TalentType.SellBonus);
if (bonusGold > 0) {
totalSellGold += bonusGold;
}
totalSellGold = Math.floor(totalSellGold);
oops.message.dispatchEvent(GameEvent.CoinAdd, { delta: totalSellGold });
// 使用统一经济管理入口出售英雄
MissionEconomy.executeSellHero();
oops.gui.remove(UIID.IBox);
}