feat(hero): add hero upgrade function
1. 新增英雄升级相关UI控件与事件流程 2. 实现升级消耗计算与统一扣费逻辑 3. 添加升级预览确认弹窗与属性成长展示 4. 开放tryUpgradeHeroByEid与applyHeroLevel为公共方法
This commit is contained in:
@@ -109,6 +109,24 @@ export class MissionEconomy {
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算英雄升级金币消耗(按当前等级线性缩放:Lv×5)
|
||||
* @param heroLevel 当前英雄等级(升级前)
|
||||
*/
|
||||
static getUpgradeCost(heroLevel: number = 1): number {
|
||||
const lv = Math.max(1, Math.floor(heroLevel));
|
||||
return lv * 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行英雄升级扣费
|
||||
* @param heroLevel 当前英雄等级(升级前)
|
||||
* @returns true = 扣费成功(金币足够)
|
||||
*/
|
||||
static executeUpgradeCost(heroLevel: number = 1): boolean {
|
||||
return this.spendCoin(this.getUpgradeCost(heroLevel));
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算英雄出售金币(按英雄等级缩放)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user