feat(talent): 重构天赋系统为三阶结构并实现全新UI
1. 重构天赋系统为一阶基础/二阶专精/三阶超强三阶结构,移除前置天赋要求改为阶位累计点数解锁 2. 新增阶位解锁校验逻辑与天赋点投入统计 3. 重做天赋UI为三阶Tab页签+迷你升级卡样式,支持状态展示与一键升级 4. 补充新的天赋配置与属性加成,更新天赋系统文档 5. 修复属性计算问题,新增暴击伤害与穿刺伤害加成支持
This commit is contained in:
@@ -1,28 +1,36 @@
|
||||
/**
|
||||
* @file TalentItemComp.ts
|
||||
* @description 天赋图鉴项组件(UI 视图层)
|
||||
* @description 天赋迷你升级卡组件(UI 视图层)
|
||||
*
|
||||
* 职责:
|
||||
* 1. 接收 TalentsComp 下发的天赋卡配置(技能卡)。
|
||||
* 2. 渲染名称、描述、图标和背景。
|
||||
* 3. 背景颜色根据 wave 映射为对应的 poolLv。
|
||||
* 1. 接收 TalentsComp 下发的天赋配置 + 当前等级 + 阶位解锁态,渲染迷你点选卡。
|
||||
* 2. 卡面自包含:图标 / 名称 / 当前已生效数值(Lv0 显示每级数值引导)/ 右下「当前/满级」角标。
|
||||
* 3. 状态机:可升级(右上 + 徽标,绿光呼吸)/ 满级(MAX 金角标)/ 阶未解锁(半透明 + 锁)。
|
||||
* 4. 点击回调上抛(含 + 徽标与卡体),升级校验与 toast 统一由 TalentsComp 处理(单一决策点)。
|
||||
*
|
||||
* 依赖:
|
||||
* - CardSet.CardConfig —— 单条卡牌配置
|
||||
* - SkillSet —— 获取技能图标
|
||||
* - TalentSet.TalentConfig / TalentTier / getTalentDisplayText —— 配置与卡面文案
|
||||
* - CardBgComp —— 阶位品质底框(Ⅰ蓝 / Ⅱ紫 / Ⅲ金)
|
||||
* - smc.uiconsAtlas —— 图标解析(缺省回退资源目录)
|
||||
*/
|
||||
import { _decorator, Label, Sprite, SpriteFrame } from "cc";
|
||||
import { _decorator, Label, Node, NodeEventType, Sprite, SpriteFrame, UIOpacity } 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 { CardConfig } from "../common/config/CardSet";
|
||||
import { FieldSkillSet, SkillSet } from "../common/config/SkillSet";
|
||||
import { TalentConfig, TalentTier, getTalentDisplayText } from "../common/config/TalentSet";
|
||||
import { CardBgComp } from "./CardBgComp";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** TalentItemComp —— 天赋图鉴项组件 */
|
||||
/** 阶位 → 品质底框 card_lv(CARD_LV_BG_COLORS:2=blue、3=purple、4=yellow) */
|
||||
const TIER_TO_BG_LV: Record<number, number> = {
|
||||
[TalentTier.Basic]: 2,
|
||||
[TalentTier.Specialized]: 3,
|
||||
[TalentTier.Super]: 4,
|
||||
};
|
||||
|
||||
/** TalentItemComp —— 天赋迷你升级卡组件 */
|
||||
@ccclass('TalentItemComp')
|
||||
@ecs.register('TalentItem', false)
|
||||
export class TalentItemComp extends CCComp {
|
||||
@@ -30,53 +38,86 @@ export class TalentItemComp extends CCComp {
|
||||
@property({ type: Label, tooltip: "天赋名称" })
|
||||
lbl_name: Label = null!;
|
||||
|
||||
@property({ type: Label, tooltip: "天赋说明" })
|
||||
@property({ type: Label, tooltip: "当前已生效数值(Lv0 显示每级引导)" })
|
||||
lbl_info: Label = null!;
|
||||
|
||||
@property({ type: Label, tooltip: "等级角标(当前/满级)" })
|
||||
lbl_lv: Label = null!;
|
||||
|
||||
@property({ type: Sprite, tooltip: "天赋图标" })
|
||||
icon: Sprite = null!;
|
||||
|
||||
@property({ type: CardBgComp, tooltip: "卡牌背景组件" })
|
||||
@property({ type: CardBgComp, tooltip: "卡牌背景组件(阶位品质色)" })
|
||||
bg: CardBgComp = null!;
|
||||
|
||||
@property({ type: Node, tooltip: "右上 + 升级徽标(可升级时显示)" })
|
||||
node_plus: Node = null!;
|
||||
|
||||
@property({ type: Node, tooltip: "MAX 满级角标" })
|
||||
node_max: Node = null!;
|
||||
|
||||
@property({ type: Node, tooltip: "阶位未解锁遮罩/锁图标" })
|
||||
node_lock: Node = null!;
|
||||
|
||||
/** 点击回调(卡体与 + 徽标同源上抛),由父级统一校验升级 */
|
||||
public onTalentTap: ((uuid: number) => void) | null = null;
|
||||
|
||||
/** 当前展示的天赋 uuid(回调携带) */
|
||||
private curUuid: number = 0;
|
||||
|
||||
protected onLoad(): void {
|
||||
this.node.on(NodeEventType.TOUCH_END, this.onTap, this);
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
this.node.off(NodeEventType.TOUCH_END, this.onTap, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新单条天赋展示
|
||||
* @param config CardPoolList 中的天赋卡(技能卡)配置
|
||||
* 刷新迷你卡展示
|
||||
* @param cfg 天赋配置(TalentSet 条目)
|
||||
* @param lv 当前等级
|
||||
* @param tierUnlocked 所属阶位是否已解锁
|
||||
* @param canUp 父级预判的"可升级"(阶位解锁 + 未满级 + 点数足够)
|
||||
*/
|
||||
public updateItem(config: CardConfig): void {
|
||||
if (!config) return;
|
||||
public updateItem(cfg: TalentConfig, lv: number, tierUnlocked: boolean, canUp: boolean): void {
|
||||
if (!cfg) return;
|
||||
this.curUuid = cfg.uuid;
|
||||
|
||||
if (this.lbl_name) this.lbl_name.string = config.name ?? "";
|
||||
if (this.lbl_info) this.lbl_info.string = config.info ?? "";
|
||||
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}`;
|
||||
|
||||
// 直接复用 CardSet 中已映射好的 card_lv,保证与技能卡牌背景一致
|
||||
// CardSet 通过 waveToCardLv[wave] 由 SKILL_CARD_WAVES 索引推导(wave 1→1, 5→2, 8→3)
|
||||
if (this.bg) {
|
||||
this.bg.apply(config.card_lv || 1);
|
||||
// 阶位品质底框:Ⅰ蓝 / Ⅱ紫 / Ⅲ金
|
||||
if (this.bg) this.bg.apply(TIER_TO_BG_LV[cfg.tier] ?? 1);
|
||||
|
||||
// 图标:uiconsAtlas 优先,资源目录回退(与 TalentItemComp 旧版/SCardComp 口径一致)
|
||||
if (this.icon && cfg.icon) {
|
||||
let frame: SpriteFrame | null = null;
|
||||
if (smc.uiconsAtlas) {
|
||||
frame = smc.uiconsAtlas.getSpriteFrame(cfg.icon);
|
||||
}
|
||||
if (!frame) {
|
||||
frame = oops.res.get("game/heros/cards/" + cfg.icon, SpriteFrame) as SpriteFrame;
|
||||
}
|
||||
if (frame) this.icon.spriteFrame = frame;
|
||||
}
|
||||
|
||||
// 设置图标:驻场卡(skill=undefined 但有 field)走 FieldSkillSet,否则走 SkillSet
|
||||
// 与 SCardComp 保持一致,避免驻场卡无 icon 显示
|
||||
if (this.icon) {
|
||||
let iconId: string | undefined;
|
||||
if (!config.skill && config.field && config.field.length > 0) {
|
||||
// 驻场卡:用 FieldSkillSet[field[0]].icon
|
||||
const fieldUuid = config.field[0].uuid;
|
||||
iconId = FieldSkillSet[fieldUuid]?.icon || `${fieldUuid}`;
|
||||
} else if (config.skill) {
|
||||
// 技能卡:用 SkillSet[skill].icon
|
||||
iconId = SkillSet[config.skill]?.icon;
|
||||
}
|
||||
if (iconId) {
|
||||
if (smc.uiconsAtlas) {
|
||||
const frame = smc.uiconsAtlas.getSpriteFrame(iconId);
|
||||
if (frame) this.icon.spriteFrame = frame;
|
||||
} else {
|
||||
const sf = oops.res.get("game/heros/cards/" + iconId, SpriteFrame) as SpriteFrame;
|
||||
if (sf) this.icon.spriteFrame = sf;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 状态徽标:满级 MAX / 可升级 + / 阶位锁定 🔒
|
||||
const maxed = lv >= cfg.max_lv;
|
||||
if (this.node_max) this.node_max.active = maxed;
|
||||
if (this.node_plus) this.node_plus.active = !maxed && tierUnlocked && canUp;
|
||||
if (this.node_lock) this.node_lock.active = !tierUnlocked;
|
||||
|
||||
// 阶位锁定整卡压暗(UIOpacity:Cocos 3.x 节点透明度组件)
|
||||
const uo = this.node.getComponent(UIOpacity) ?? this.node.addComponent(UIOpacity);
|
||||
uo.opacity = tierUnlocked ? 255 : 110;
|
||||
}
|
||||
|
||||
/** 卡体/+ 徽标点击:上抛 uuid,升级校验与提示由 TalentsComp 统一处理 */
|
||||
private onTap(): void {
|
||||
this.onTalentTap?.(this.curUuid);
|
||||
}
|
||||
|
||||
/** ECS 组件移除时销毁节点(CCComp 抽象方法实现) */
|
||||
|
||||
Reference in New Issue
Block a user