refactor: 重构天赋系统与技能触发逻辑
1. 重构天赋系统架构:将天赋加成与触发修正统一收敛到 HeroAttrsComp.applyTalent 2. 新增天赋触发修正字段:talent_t_num_reduce 与 talent_extra_trigger_chance 3. 重构天赋加点逻辑:统一 1 点/级,新增软前置校验 4. 优化天赋UI组件:改为编辑器静态配置驱动,重构层位展示逻辑 5. 修复技能触发判定:在 SkillTriggerHelper 中应用天赋触发修正 6. 调整天赋配置结构:改为 5 层递进解锁,新增 L4/L5 专属触发修正配置
This commit is contained in:
@@ -54,7 +54,6 @@ import { oops } from "db://oops-framework/core/Oops";
|
||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { HeroInfo, HType, resolveTriggerByLv, resolveFieldByLv, resolveSkillOverrides, calcGrowBonus, getHeroQualityCoef } from "../common/config/heroSet";
|
||||
import { applyTalentBonuses } from "../common/config/TalentSet";
|
||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||
import { FacSet, FightSet } from "../common/config/GameSet";
|
||||
import { MissionEconomy } from "./MissionEconomy";
|
||||
@@ -2094,13 +2093,16 @@ export class MissionCardComp extends CCComp {
|
||||
model.knockback_distance = 0;
|
||||
model.heal_power = 0;
|
||||
model.buff_power = 0;
|
||||
applyTalentBonuses(model, smc.getTalentLevels(), model.role);
|
||||
// 天赋触发修正归零(applyTalent 内部重算,保证升级重算幂等)
|
||||
model.talent_t_num_reduce = 0;
|
||||
model.talent_extra_trigger_chance = 0;
|
||||
model.applyTalent();
|
||||
}
|
||||
|
||||
// 血量按当前血线比例映射到新上限,保留升级前战斗状态
|
||||
model.hp = Math.max(1, Math.floor(model.hp_max * Math.max(0, Math.min(1, hpRate))));
|
||||
|
||||
// 重新解析触发技能/驻场光环/复活到运行时缓存(与 Hero.load 对齐)
|
||||
// 重新解析触发技能/驻场光环/复活到运行时缓存(在 applyTalent 之后,确保 L4/L5 触发修正已写入模型)
|
||||
model.runtime_call = resolveTriggerByLv(model.call, nextLv);
|
||||
model.runtime_dead = resolveTriggerByLv(model.dead, nextLv);
|
||||
model.runtime_fstart = resolveTriggerByLv(model.fstart, nextLv);
|
||||
|
||||
@@ -1,40 +1,45 @@
|
||||
/**
|
||||
* @file TalentItemComp.ts
|
||||
* @description 天赋迷你升级卡组件(UI 视图层)
|
||||
* @description 天赋迷你升级卡组件(UI 视图层,编辑器静态摆放)
|
||||
*
|
||||
* 职责:
|
||||
* 1. 接收 TalentsComp 下发的天赋配置 + 当前等级 + 阶位解锁态,渲染迷你点选卡。
|
||||
* 1. 通过编辑器配置的 uuid 自查询天赋配置 + 当前等级 + 层位解锁态,渲染迷你点选卡。
|
||||
* 2. 卡面自包含:图标 / 名称 / 当前已生效数值(Lv0 显示每级数值引导)/ 右下「当前/满级」角标。
|
||||
* 3. 阶位背景:普通背景节点下挂 blue / red / yellow 三个颜色子节点,按阶位激活其一(Ⅰ蓝 / Ⅱ红 / Ⅲ金)。
|
||||
* 4. 状态机:满级(MAX 金角标)/ 未激活(左上锁角标,不再做灰阶处理)。
|
||||
* 3. 层位背景:普通背景节点下挂 blue / red / yellow 三个颜色子节点,按层位映射激活其一(L1蓝 / L2红 / L3金,L4/L5 复用金)。
|
||||
* 4. 状态机:满级(MAX 金角标)/ 未激活(左上锁角标:未加点 / 层位未解锁 / 前置未满足,不做灰阶处理)。
|
||||
* 5. 点击回调上抛卡体点击,加点确认弹窗与升级校验统一由 TalentsComp 处理(单一决策点)。
|
||||
*
|
||||
* 依赖:
|
||||
* - TalentSet.TalentConfig / TalentTier / getTalentDisplayText —— 配置与卡面文案
|
||||
* - TalentSet(TalentConfig/TalentTier/getTalentDisplayText/isTalentTierUnlocked/isTalentPrereqMet)—— 配置与校验
|
||||
* - 背景三颜色子节点(blue / red / yellow,编辑器侧搭建)
|
||||
* - smc.uiconsAtlas —— 图标解析(缺省回退资源目录)
|
||||
* - smc —— 天赋等级表与图标图集(缺省回退资源目录)
|
||||
*/
|
||||
import { _decorator, Label, Node, NodeEventType, Sprite, SpriteFrame } from "cc";
|
||||
import { _decorator, CCInteger, Label, Node, NodeEventType, Sprite, SpriteFrame } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { TalentConfig, TalentTier, getTalentDisplayText } from "../common/config/TalentSet";
|
||||
import { TalentSet, TalentTier, getTalentDisplayText, isTalentPrereqMet, isTalentTierUnlocked } from "../common/config/TalentSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 阶位 → 背景节点下的颜色子节点名(Ⅰ蓝 / Ⅱ红 / Ⅲ金) */
|
||||
/** 层位 → 背景节点下的颜色子节点名(L1蓝 / L2红 / L3金;L4/L5 复用金) */
|
||||
const TIER_BG_CHILD_NAMES: Record<number, string> = {
|
||||
[TalentTier.Basic]: "blue",
|
||||
[TalentTier.Specialized]: "red",
|
||||
[TalentTier.Super]: "yellow",
|
||||
[TalentTier.L1]: "blue",
|
||||
[TalentTier.L2]: "red",
|
||||
[TalentTier.L3]: "yellow",
|
||||
[TalentTier.L4]: "yellow",
|
||||
[TalentTier.L5]: "yellow",
|
||||
};
|
||||
|
||||
/** TalentItemComp —— 天赋迷你升级卡组件 */
|
||||
/** TalentItemComp —— 天赋迷你升级卡组件(编辑器静态摆放,按 uuid 自驱动渲染) */
|
||||
@ccclass('TalentItemComp')
|
||||
@ecs.register('TalentItem', false)
|
||||
export class TalentItemComp extends CCComp {
|
||||
|
||||
@property({ type: CCInteger, tooltip: "天赋 uuid(TalentSet key,编辑器侧配置)" })
|
||||
talent_uuid: number = 0;
|
||||
|
||||
@property({ type: Label, tooltip: "天赋名称" })
|
||||
lbl_name: Label = null!;
|
||||
|
||||
@@ -47,21 +52,18 @@ export class TalentItemComp extends CCComp {
|
||||
@property({ type: Sprite, tooltip: "天赋图标" })
|
||||
icon: Sprite = null!;
|
||||
|
||||
@property({ type: Node, tooltip: "卡牌背景节点(下挂 blue / red / yellow 三颜色子节点,按阶位激活其一)" })
|
||||
@property({ type: Node, tooltip: "卡牌背景节点(下挂 blue / red / yellow 三颜色子节点,按层位激活其一)" })
|
||||
bg: Node = null!;
|
||||
|
||||
@property({ type: Node, tooltip: "MAX 满级角标" })
|
||||
node_max: Node = null!;
|
||||
|
||||
@property({ type: Node, tooltip: "未激活锁遮罩/锁图标(未加点或阶位未解锁)" })
|
||||
@property({ type: Node, tooltip: "未激活锁遮罩/锁图标(未加点、层位未解锁或前置未满足)" })
|
||||
node_lock: Node = null!;
|
||||
|
||||
/** 点击回调(卡体与 + 徽标同源上抛),由父级统一校验升级 */
|
||||
/** 点击回调(卡体点击上抛),由 TalentsComp 统一校验升级 */
|
||||
public onTalentTap: ((uuid: number) => void) | null = null;
|
||||
|
||||
/** 当前展示的天赋 uuid(回调携带) */
|
||||
private curUuid: number = 0;
|
||||
|
||||
protected onLoad(): void {
|
||||
this.node.on(NodeEventType.TOUCH_END, this.onTap, this);
|
||||
}
|
||||
@@ -70,25 +72,24 @@ export class TalentItemComp extends CCComp {
|
||||
this.node.off(NodeEventType.TOUCH_END, this.onTap, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新迷你卡展示
|
||||
* @param cfg 天赋配置(TalentSet 条目)
|
||||
* @param lv 当前等级
|
||||
* @param tierUnlocked 所属阶位是否已解锁
|
||||
*/
|
||||
public updateItem(cfg: TalentConfig, lv: number, tierUnlocked: boolean): void {
|
||||
/** 刷新迷你卡展示:按编辑器配置的 uuid 自查询配置与等级,层位/前置校验内部完成 */
|
||||
public updateItem(): void {
|
||||
const cfg = TalentSet[this.talent_uuid];
|
||||
if (!cfg) return;
|
||||
this.curUuid = cfg.uuid;
|
||||
const levels = smc.getTalentLevels();
|
||||
const lv = levels[this.talent_uuid] ?? 0;
|
||||
const tierUnlocked = isTalentTierUnlocked(levels, cfg.tier);
|
||||
const prereqMet = isTalentPrereqMet(levels, cfg);
|
||||
|
||||
if (this.lbl_name) this.lbl_name.string = cfg.name;
|
||||
// 卡面自包含:已加点显示当前生效数值,未加点显示每级数值引导
|
||||
if (this.lbl_info) this.lbl_info.string = getTalentDisplayText(cfg, lv);
|
||||
if (this.lbl_lv) this.lbl_lv.string = `${lv}/${cfg.max_lv}`;
|
||||
|
||||
// 未激活(Lv0 或阶位未解锁):仅显示 node_lock 锁遮罩,不做灰阶处理
|
||||
const inactive = lv <= 0 || !tierUnlocked;
|
||||
// 未激活(Lv0 / 层位未解锁 / 前置未满足):仅显示 node_lock 锁遮罩,不做灰阶处理
|
||||
const inactive = lv <= 0 || !tierUnlocked || !prereqMet;
|
||||
|
||||
// 阶位背景:激活对应颜色子节点(Ⅰ蓝 / Ⅱ红 / Ⅲ金)
|
||||
// 层位背景:激活对应颜色子节点(L1蓝 / L2红 / L3金)
|
||||
if (this.bg) this.applyTierBg(cfg.tier);
|
||||
|
||||
// 图标:技能图标图集(gui/ui7)优先,资源目录回退(与 SCardComp 口径一致)
|
||||
@@ -103,12 +104,12 @@ export class TalentItemComp extends CCComp {
|
||||
if (frame) this.icon.spriteFrame = frame;
|
||||
}
|
||||
|
||||
// 状态角标:满级 MAX / 未激活锁角标(未加点或阶位未解锁,置于左上角)
|
||||
// 状态角标:满级 MAX / 未激活锁角标(置于左上角)
|
||||
if (this.node_max) this.node_max.active = lv >= cfg.max_lv;
|
||||
if (this.node_lock) this.node_lock.active = inactive;
|
||||
}
|
||||
|
||||
/** 按阶位激活 bg 下对应颜色子节点,其余隐藏 */
|
||||
/** 按层位激活 bg 下对应颜色子节点,其余隐藏 */
|
||||
private applyTierBg(tier: TalentTier): void {
|
||||
const curName = TIER_BG_CHILD_NAMES[tier];
|
||||
for (const [, name] of Object.entries(TIER_BG_CHILD_NAMES)) {
|
||||
@@ -120,7 +121,7 @@ export class TalentItemComp extends CCComp {
|
||||
|
||||
/** 卡体点击上抛 uuid,加点确认与升级校验由 TalentsComp 处理 */
|
||||
private onTap(): void {
|
||||
this.onTalentTap?.(this.curUuid);
|
||||
this.onTalentTap?.(this.talent_uuid);
|
||||
}
|
||||
|
||||
/** ECS 组件移除时销毁节点(CCComp 抽象方法实现) */
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
/**
|
||||
* @file TalentsComp.ts
|
||||
* @description 天赋加点页组件(UI 视图层)
|
||||
* @description 天赋加点页组件(UI 视图层,最小容器)
|
||||
*
|
||||
* 职责:
|
||||
* 1. 三阶页签(Ⅰ 基础 / Ⅱ 专精 / Ⅲ 超强)状态机:单屏聚焦当前阶位的迷你天赋卡。
|
||||
* 2. 页签常显解锁进度(前阶投入 x/10),点击天赋卡弹出 CommonPrompt 确认加点(smc.upgradeTalent)。
|
||||
* 3. 监听 GameEvent.TALENT_UPDATE 全量重渲染(23 条卡片,无需虚拟列表)。
|
||||
* 1. 页头展示:可用天赋点 / 天赋等级(Lv.x)/ 当前等级经验进度。
|
||||
* 2. 收集子树内全部 TalentItemComp(编辑器静态摆放),TALENT_UPDATE 事件驱动全量刷新。
|
||||
* 3. 卡片点击统一校验(层位解锁 → 软前置 → 满级 → 点数),不满足走 smalltip 气泡;
|
||||
* 满足则弹出 CommonPrompt 确认加点(smc.upgradeTalent)。
|
||||
* 4. 看广告重置入口:CommonPrompt 二次确认后调 smc.resetTalents() 退还全部点数。
|
||||
*
|
||||
* 依赖:
|
||||
* - TalentSet(TalentSet/TalentTier/isTalentTierUnlocked/getTalentTierInvestedPoints)—— 配置与阶位校验
|
||||
* - TalentItemComp —— 单张迷你升级卡
|
||||
* - TalentSet(TalentTier/isTalentTierUnlocked/isTalentPrereqMet/getTalentTierInvestedPoints)—— 配置与层位校验
|
||||
* - TalentItemComp —— 单张迷你升级卡(编辑器静态摆放,按 uuid 自驱动渲染)
|
||||
* - smc —— 天赋等级表/点数/升级/重置
|
||||
*/
|
||||
import { _decorator, instantiate, Label, Node, NodeEventType, Prefab, ProgressBar, UITransform } from "cc";
|
||||
import { _decorator, Label, Node, NodeEventType, ProgressBar } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import {
|
||||
TalentSet, TalentTier,
|
||||
TalentSet,
|
||||
TALENT_TIER_UNLOCK_THRESHOLD,
|
||||
getTalentDisplayText, getTalentLevelExp, getTalentTierInvestedPoints, getTalentUpgradeCost, isTalentTierUnlocked,
|
||||
getTalentDisplayText, getTalentLevelExp, getTalentTierInvestedPoints, getTalentUpgradeCost,
|
||||
isTalentPrereqMet, isTalentTierUnlocked,
|
||||
} from "../common/config/TalentSet";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { UIID } from "../common/config/GameUIConfig";
|
||||
@@ -30,36 +32,19 @@ import { oops } from "db://oops-framework/core/Oops";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 阶位页签展示文案(lockName 用于未解锁提示) */
|
||||
const TIER_TAB_TEXT: Record<number, { title: string; lockName: string }> = {
|
||||
[TalentTier.Basic]: { title: "基础天赋", lockName: "基础天赋" },
|
||||
[TalentTier.Specialized]: { title: "专精天赋", lockName: "基础天赋" },
|
||||
[TalentTier.Super]: { title: "传说天赋", lockName: "专精天赋" },
|
||||
/** 层位序号展示文案(提示文案用) */
|
||||
const TIER_NAMES: Record<number, string> = {
|
||||
1: "第 1 层", 2: "第 2 层", 3: "第 3 层", 4: "第 4 层", 5: "第 5 层",
|
||||
};
|
||||
|
||||
/** 阶位页签选中高亮子节点名(可选,编辑器侧搭建) */
|
||||
const TAB_SELECTED_CHILD = "sp_on";
|
||||
|
||||
/** 阶位页签锁定图标子节点名(可选;阶位未解锁时显示) */
|
||||
const TAB_LOCKED_CHILD = "locked";
|
||||
|
||||
/** 阶位页签未选中态子节点名(可选;非当前选中页签时显示) */
|
||||
const TAB_INACTIVE_CHILD = "noactive";
|
||||
|
||||
/** 页签/卡片上的 smalltip 气泡节点名 */
|
||||
const SMALL_TIP_CHILD = "smalltip";
|
||||
|
||||
/** TalentsComp —— 天赋加点页组件(阶位 Tab 单屏聚焦) */
|
||||
/** TalentsComp —— 天赋加点页组件(最小容器:页头 + 编辑器静态卡片收集) */
|
||||
@ccclass('TalentsComp')
|
||||
@ecs.register('Talents', false)
|
||||
export class TalentsComp extends CCComp {
|
||||
|
||||
@property({ type: Node, tooltip: "当前阶位卡片列表容器(ScrollView content,Grid 三列)" })
|
||||
talents_content: Node = null!;
|
||||
|
||||
@property({ type: Prefab, tooltip: "迷你天赋卡预制(TalentItemComp)" })
|
||||
prefab_talent_item: Prefab = null!;
|
||||
|
||||
@property({ type: Label, tooltip: "页头可用天赋点" })
|
||||
lbl_points: Label = null!;
|
||||
|
||||
@@ -72,52 +57,16 @@ export class TalentsComp extends CCComp {
|
||||
@property({ type: Label, tooltip: "当前等级经验数值(当前经验/升级所需经验)" })
|
||||
lbl_exp: Label = null!;
|
||||
|
||||
@property({ type: Node, tooltip: "一阶页签节点" })
|
||||
tab_basic: Node = null!;
|
||||
|
||||
@property({ type: Node, tooltip: "二阶页签节点" })
|
||||
tab_special: Node = null!;
|
||||
|
||||
@property({ type: Node, tooltip: "三阶页签节点" })
|
||||
tab_super: Node = null!;
|
||||
|
||||
@property({ type: Label, tooltip: "一阶页签文案" })
|
||||
lbl_tab_basic: Label = null!;
|
||||
|
||||
@property({ type: Label, tooltip: "二阶页签文案" })
|
||||
lbl_tab_special: Label = null!;
|
||||
|
||||
@property({ type: Label, tooltip: "三阶页签文案" })
|
||||
lbl_tab_super: Label = null!;
|
||||
|
||||
@property({ type: Label, tooltip: "一阶已投入点数" })
|
||||
lbl_invest_basic: Label = null!;
|
||||
|
||||
@property({ type: Label, tooltip: "二阶已投入点数" })
|
||||
lbl_invest_special: Label = null!;
|
||||
|
||||
@property({ type: Label, tooltip: "三阶已投入点数" })
|
||||
lbl_invest_super: Label = null!;
|
||||
|
||||
@property({ type: Node, tooltip: "看广告重置按钮" })
|
||||
btn_reset: Node = null!;
|
||||
|
||||
/** 当前选中的阶位(首次进入默认为已解锁的最高阶,之后由玩家切换) */
|
||||
private curTier: TalentTier = TalentTier.Basic;
|
||||
|
||||
/** 是否已完成首次默认阶位选择 */
|
||||
private inited: boolean = false;
|
||||
|
||||
/** 阶位 → 页签节点/文案/投入点数/气泡 映射(onLoad 时装配) */
|
||||
private tabNodes: Map<TalentTier, { node: Node | null; label: Label | null; invest: Label | null; tip: SmallTipComp | null }> = new Map();
|
||||
/** 页内全部天赋卡(onLoad 时自动收集子树内所有 TalentItemComp,无需编辑器拖引) */
|
||||
private talent_items: TalentItemComp[] = [];
|
||||
|
||||
protected onLoad(): void {
|
||||
this.tabNodes.set(TalentTier.Basic, { node: this.tab_basic, label: this.lbl_tab_basic, invest: this.lbl_invest_basic, tip: this.getSmallTip(this.tab_basic) });
|
||||
this.tabNodes.set(TalentTier.Specialized, { node: this.tab_special, label: this.lbl_tab_special, invest: this.lbl_invest_special, tip: this.getSmallTip(this.tab_special) });
|
||||
this.tabNodes.set(TalentTier.Super, { node: this.tab_super, label: this.lbl_tab_super, invest: this.lbl_invest_super, tip: this.getSmallTip(this.tab_super) });
|
||||
|
||||
for (const [tier, tab] of this.tabNodes) {
|
||||
tab.node?.on(NodeEventType.TOUCH_END, () => this.selectTier(tier), this);
|
||||
this.talent_items = this.node.getComponentsInChildren(TalentItemComp);
|
||||
for (const item of this.talent_items) {
|
||||
item.onTalentTap = (uuid: number) => this.onTalentTap(uuid);
|
||||
}
|
||||
this.btn_reset?.on(NodeEventType.TOUCH_END, this.onResetTap, this);
|
||||
}
|
||||
@@ -133,30 +82,20 @@ export class TalentsComp extends CCComp {
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
for (const [, tab] of this.tabNodes) {
|
||||
tab.node?.targetOff(this);
|
||||
}
|
||||
this.btn_reset?.targetOff(this);
|
||||
}
|
||||
|
||||
/** 切换阶位页签:锁定阶允许查看(卡片呈锁定态),不弹解锁提示 */
|
||||
private selectTier(tier: TalentTier): void {
|
||||
if (tier === this.curTier) return;
|
||||
this.curTier = tier;
|
||||
this.refreshUI();
|
||||
}
|
||||
|
||||
/** 全量刷新:页头点数 + 页签解锁进度 + 当前阶位卡片列表 */
|
||||
/** 全量刷新:页头点数 + 天赋等级/经验 + 全部静态卡片 */
|
||||
public refreshUI(): void {
|
||||
if (!this.talents_content || !this.prefab_talent_item) return;
|
||||
const levels = smc.getTalentLevels();
|
||||
|
||||
if (this.lbl_points) {
|
||||
// 剩余/总点数:总点数 = 剩余 + 各阶已投入
|
||||
// 剩余/总点数:总点数 = 剩余 + 各层已投入
|
||||
const remaining = smc.getTalentPoints();
|
||||
const invested = getTalentTierInvestedPoints(levels, TalentTier.Basic)
|
||||
+ getTalentTierInvestedPoints(levels, TalentTier.Specialized)
|
||||
+ getTalentTierInvestedPoints(levels, TalentTier.Super);
|
||||
let invested = 0;
|
||||
for (let tier = 1; tier <= 5; tier++) {
|
||||
invested += getTalentTierInvestedPoints(levels, tier);
|
||||
}
|
||||
this.lbl_points.string = `${remaining}/${remaining + invested}`;
|
||||
}
|
||||
|
||||
@@ -178,66 +117,8 @@ export class TalentsComp extends CCComp {
|
||||
: `0/0`;
|
||||
}
|
||||
|
||||
// 仅首次进入时默认选中已解锁的最高阶,后续刷新保持玩家当前选择
|
||||
if (!this.inited) {
|
||||
this.inited = true;
|
||||
if (isTalentTierUnlocked(levels, TalentTier.Super)) this.curTier = TalentTier.Super;
|
||||
else if (isTalentTierUnlocked(levels, TalentTier.Specialized)) this.curTier = TalentTier.Specialized;
|
||||
}
|
||||
|
||||
this.refreshTabs(levels);
|
||||
this.refreshGrid(levels);
|
||||
}
|
||||
|
||||
/** 页签文案 + 各阶已投入点数 + 选中高亮(sp_on)+ 锁定图标(locked)+ 未选中态(noactive) */
|
||||
private refreshTabs(levels: Record<number, number>): void {
|
||||
for (const [tier, tab] of this.tabNodes) {
|
||||
const text = TIER_TAB_TEXT[tier];
|
||||
const unlocked = isTalentTierUnlocked(levels, tier);
|
||||
if (tab.label) tab.label.string = text.title;
|
||||
// 各阶已投入点数(该阶所有天赋等级之和)
|
||||
if (tab.invest) tab.invest.string = `${getTalentTierInvestedPoints(levels, tier)}`;
|
||||
// 锁定图标:该阶未解锁时显示,解锁后隐藏(一阶恒解锁,节点可缺省)
|
||||
const locked = tab.node?.getChildByName(TAB_LOCKED_CHILD);
|
||||
if (locked) locked.active = !unlocked;
|
||||
|
||||
const selected = tier === this.curTier;
|
||||
// 未选中态节点:非当前激活页签时显示(与 sp_on 选中高亮互斥)
|
||||
const inactive = tab.node?.getChildByName(TAB_INACTIVE_CHILD);
|
||||
if (inactive) inactive.active = !selected;
|
||||
|
||||
tab.node?.getChildByName(TAB_SELECTED_CHILD)?.setPosition(0, 0);
|
||||
tab.node?.getChildByName(TAB_SELECTED_CHILD) && (tab.node.getChildByName(TAB_SELECTED_CHILD)!.active = selected);
|
||||
}
|
||||
}
|
||||
|
||||
/** 重建当前阶位的卡片列表(每阶 ≤10 条,直接全量实例化) */
|
||||
private refreshGrid(levels: Record<number, number>): void {
|
||||
this.talents_content.removeAllChildren();
|
||||
const unlocked = isTalentTierUnlocked(levels, this.curTier);
|
||||
const cfgs = Object.values(TalentSet)
|
||||
.filter(cfg => cfg.tier === this.curTier)
|
||||
.sort((a, b) => a.uuid - b.uuid);
|
||||
|
||||
let cardHeight = 0;
|
||||
for (const cfg of cfgs) {
|
||||
const lv = levels[cfg.uuid] ?? 0;
|
||||
|
||||
const itemNode = instantiate(this.prefab_talent_item);
|
||||
this.talents_content.addChild(itemNode);
|
||||
const comp = itemNode.getComponent(TalentItemComp);
|
||||
if (!comp) continue;
|
||||
comp.updateItem(cfg, lv, unlocked);
|
||||
comp.onTalentTap = (uuid: number) => this.onTalentTap(uuid);
|
||||
if (!cardHeight) cardHeight = itemNode.getComponent(UITransform)?.height ?? 0;
|
||||
}
|
||||
|
||||
// Grid 三列手算容器高度(与旧版图鉴页口径一致,spacing 15 / 上下 padding 15)
|
||||
const rows = Math.ceil(cfgs.length / 3);
|
||||
if (cardHeight > 0 && rows > 0) {
|
||||
const contentHeight = rows * cardHeight + (rows - 1) * 15 + 30;
|
||||
const uiTransform = this.talents_content.getComponent(UITransform);
|
||||
if (uiTransform) uiTransform.height = contentHeight;
|
||||
for (const item of this.talent_items) {
|
||||
item.updateItem();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +133,7 @@ export class TalentsComp extends CCComp {
|
||||
|
||||
/**
|
||||
* 在指定节点下弹出 smalltip 气泡提示
|
||||
* @param anchor 气泡挂载的父节点(优先页签,卡片点击时传卡片节点)
|
||||
* @param anchor 气泡挂载的父节点
|
||||
* @param text 提示文案
|
||||
*/
|
||||
private showSmallTip(anchor: Node | null, text: string): void {
|
||||
@@ -260,27 +141,45 @@ export class TalentsComp extends CCComp {
|
||||
tip?.show(text);
|
||||
}
|
||||
|
||||
/** 卡片点击统一入口:未解锁/已满级/点数不足走 smalltip 气泡;其余弹出 CommonPrompt 确认加点,成功后事件驱动刷新 */
|
||||
/**
|
||||
* 按 uuid 找到对应的天赋卡节点(气泡锚点用)
|
||||
* @param uuid 天赋 uuid
|
||||
*/
|
||||
private findItemNode(uuid: number): Node | null {
|
||||
for (const item of this.talent_items) {
|
||||
if (item.talent_uuid === uuid) return item.node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** 卡片点击统一入口:层位未解锁/前置未满足/已满级/点数不足走 smalltip 气泡;其余弹出 CommonPrompt 确认加点,成功后事件驱动刷新 */
|
||||
private onTalentTap(uuid: number): void {
|
||||
const cfg = TalentSet[uuid];
|
||||
if (!cfg) return;
|
||||
const levels = smc.getTalentLevels();
|
||||
const anchor = this.findItemNode(uuid);
|
||||
|
||||
const tab = this.tabNodes.get(cfg.tier);
|
||||
// 层位解锁:第 N 层要求第 N-1 层累计投入 ≥ 阈值
|
||||
if (!isTalentTierUnlocked(levels, cfg.tier)) {
|
||||
const invested = getTalentTierInvestedPoints(levels, (cfg.tier - 1) as TalentTier);
|
||||
this.showSmallTip(tab?.node ?? null, `${TIER_TAB_TEXT[cfg.tier].lockName}投入${TALENT_TIER_UNLOCK_THRESHOLD} 点解锁`);
|
||||
this.showSmallTip(anchor, `${TIER_NAMES[cfg.tier - 1]}投入${TALENT_TIER_UNLOCK_THRESHOLD} 点解锁`);
|
||||
return;
|
||||
}
|
||||
// 软前置:前置天赋等级需达标
|
||||
if (!isTalentPrereqMet(levels, cfg)) {
|
||||
const preCfg = TalentSet[cfg.prereq_uuid!];
|
||||
const preName = preCfg ? preCfg.name : `天赋${cfg.prereq_uuid}`;
|
||||
this.showSmallTip(anchor, `需「${preName}」达到 Lv.${cfg.prereq_lv}`);
|
||||
return;
|
||||
}
|
||||
const lv = smc.getTalentLv(uuid);
|
||||
if (lv >= cfg.max_lv) {
|
||||
this.showSmallTip(tab?.node ?? null, "该天赋已满级");
|
||||
this.showSmallTip(anchor, "该天赋已满级");
|
||||
return;
|
||||
}
|
||||
const cost = getTalentUpgradeCost(cfg.tier);
|
||||
if (cost <= 0) return;
|
||||
if (smc.getTalentPoints() < cost) {
|
||||
this.showSmallTip(tab?.node ?? null, "天赋点不足");
|
||||
this.showSmallTip(anchor, "天赋点不足");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -294,7 +193,7 @@ export class TalentsComp extends CCComp {
|
||||
maskClose: true,
|
||||
okFunc: () => {
|
||||
if (!smc.upgradeTalent(uuid)) {
|
||||
this.showSmallTip(this.tabNodes.get(cfg.tier)?.node ?? null, "天赋点不足");
|
||||
this.showSmallTip(anchor, "天赋点不足");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user