feat(天赋系统): 实现天赋效果并应用至相关游戏系统
- 在 MissionCardComp 中应用 RefreshDiscount 天赋以减少刷新消耗 - 在 CardComp 中应用 BuyDiscount 天赋以减少英雄购买消耗 - 在 HInfoComp 中应用 SellBonus 天赋以增加英雄出售收益 - 统一 TalentType 枚举类型,增强类型安全性 - 更新 SingletonModuleComp 中 talents 数据结构以支持类型化 - 修改 HeroAttrsComp.getTalentValue 方法参数类型为 TalentType
This commit is contained in:
@@ -30,6 +30,8 @@ import { GameEvent } from "../common/config/GameEvent";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { UIID } from "../common/config/GameUIConfig";
|
||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||
import { TalentType } from "../common/config/TalentSet";
|
||||
|
||||
|
||||
|
||||
@@ -272,7 +274,14 @@ export class CardComp extends CCComp {
|
||||
this.cardData = data;
|
||||
this.card_uuid = data.uuid;
|
||||
this.card_type = data.type;
|
||||
this.card_cost = data.cost;
|
||||
|
||||
let baseCost = data.cost ?? 0;
|
||||
if (this.card_type === CardType.Hero) {
|
||||
const discount = HeroAttrsComp.getTalentValue(TalentType.BuyDiscount);
|
||||
baseCost = Math.max(0, baseCost - discount);
|
||||
}
|
||||
this.card_cost = Math.floor(baseCost);
|
||||
|
||||
this.node.active = true;
|
||||
this.isEnlarged = false;
|
||||
this.applyCardUI();
|
||||
@@ -300,7 +309,7 @@ export class CardComp extends CCComp {
|
||||
*/
|
||||
useCard(): CardConfig | null {
|
||||
if (!this.cardData || this.isUsing) return null;
|
||||
const cardCost = Math.max(0, Math.floor(this.cardData.cost ?? 0));
|
||||
const cardCost = this.card_cost;
|
||||
const currentCoin = this.getMissionCoin();
|
||||
// 金币不足 → 提示并回弹
|
||||
if (currentCoin < cardCost) {
|
||||
|
||||
@@ -24,6 +24,8 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { HeroInfo } from "../common/config/heroSet";
|
||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { TalentType } from "../common/config/TalentSet";
|
||||
import { Hero } from "../hero/Hero";
|
||||
import { FieldSkillType } from "../common/config/SkillSet";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
@@ -267,7 +269,15 @@ export class HInfoComp extends CCComp {
|
||||
// 卖出英雄金币收益
|
||||
const baseSellGold = 1; // 基础卖出金币
|
||||
const goldBoost = HeroAttrsComp.getFieldSkillTotalValue(FieldSkillType.SellGold);
|
||||
const totalSellGold = baseSellGold + goldBoost;
|
||||
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 });
|
||||
|
||||
oops.gui.remove(UIID.IBox);
|
||||
|
||||
@@ -48,6 +48,7 @@ import { HeroViewComp } from "../hero/HeroViewComp";
|
||||
import { FacSet, FightSet } from "../common/config/GameSet";
|
||||
import { MoveComp } from "../hero/MoveComp";
|
||||
import { MissionHeroCompComp } from "./MissionHeroComp";
|
||||
import { TalentType } from "../common/config/TalentSet";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -840,7 +841,10 @@ export class MissionCardComp extends CCComp {
|
||||
}
|
||||
|
||||
private getRefreshCost(): number {
|
||||
return Math.max(0, Math.floor(this.refreshCost));
|
||||
let cost = this.refreshCost;
|
||||
const discount = HeroAttrsComp.getTalentValue(TalentType.RefreshDiscount);
|
||||
cost = Math.max(0, cost - discount);
|
||||
return Math.floor(cost);
|
||||
}
|
||||
|
||||
private ensureHeroInfoPanel(eid: number, model: HeroAttrsComp) {
|
||||
|
||||
@@ -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