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:
@@ -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 抽象方法实现) */
|
||||
|
||||
Reference in New Issue
Block a user