refactor(talents): 优化天赋页签展示与投入点数显示
1. 更新阶位页签文案配置,调整锁提示文本 2. 新增各阶已投入点数标签的序列化与映射 3. 重构页签刷新逻辑,分离文案和投入点数展示 4. 简化未解锁阶位的提示文案
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -30,11 +30,11 @@ import { oops } from "db://oops-framework/core/Oops";
|
|||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
/** 阶位页签展示文案(锁定态追加投入进度) */
|
/** 阶位页签展示文案(lockName 用于未解锁提示) */
|
||||||
const TIER_TAB_TEXT: Record<number, { title: string; lockName: string }> = {
|
const TIER_TAB_TEXT: Record<number, { title: string; lockName: string }> = {
|
||||||
[TalentTier.Basic]: { title: "Ⅰ 基础", lockName: "一阶" },
|
[TalentTier.Basic]: { title: "基础天赋", lockName: "基础天赋" },
|
||||||
[TalentTier.Specialized]: { title: "Ⅱ 专精", lockName: "一阶" },
|
[TalentTier.Specialized]: { title: "专精天赋", lockName: "基础天赋" },
|
||||||
[TalentTier.Super]: { title: "Ⅲ 超强", lockName: "二阶" },
|
[TalentTier.Super]: { title: "传说天赋", lockName: "专精天赋" },
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 阶位页签选中高亮子节点名(可选,编辑器侧搭建) */
|
/** 阶位页签选中高亮子节点名(可选,编辑器侧搭建) */
|
||||||
@@ -87,6 +87,15 @@ export class TalentsComp extends CCComp {
|
|||||||
@property({ type: Label, tooltip: "三阶页签文案" })
|
@property({ type: Label, tooltip: "三阶页签文案" })
|
||||||
lbl_tab_super: Label = null!;
|
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: "看广告重置按钮" })
|
@property({ type: Node, tooltip: "看广告重置按钮" })
|
||||||
btn_reset: Node = null!;
|
btn_reset: Node = null!;
|
||||||
|
|
||||||
@@ -96,13 +105,13 @@ export class TalentsComp extends CCComp {
|
|||||||
/** 是否已完成首次默认阶位选择 */
|
/** 是否已完成首次默认阶位选择 */
|
||||||
private inited: boolean = false;
|
private inited: boolean = false;
|
||||||
|
|
||||||
/** 阶位 → 页签节点/文案/气泡 映射(onLoad 时装配) */
|
/** 阶位 → 页签节点/文案/投入点数/气泡 映射(onLoad 时装配) */
|
||||||
private tabNodes: Map<TalentTier, { node: Node | null; label: Label | null; tip: SmallTipComp | null }> = new Map();
|
private tabNodes: Map<TalentTier, { node: Node | null; label: Label | null; invest: Label | null; tip: SmallTipComp | null }> = new Map();
|
||||||
|
|
||||||
protected onLoad(): void {
|
protected onLoad(): void {
|
||||||
this.tabNodes.set(TalentTier.Basic, { node: this.tab_basic, label: this.lbl_tab_basic, tip: this.getSmallTip(this.tab_basic) });
|
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, tip: this.getSmallTip(this.tab_special) });
|
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, tip: this.getSmallTip(this.tab_super) });
|
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) {
|
for (const [tier, tab] of this.tabNodes) {
|
||||||
tab.node?.on(NodeEventType.TOUCH_END, () => this.selectTier(tier), this);
|
tab.node?.on(NodeEventType.TOUCH_END, () => this.selectTier(tier), this);
|
||||||
@@ -163,19 +172,14 @@ export class TalentsComp extends CCComp {
|
|||||||
this.refreshGrid(levels);
|
this.refreshGrid(levels);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 页签文案 + 解锁进度 + 选中高亮(sp_on)+ 锁定图标(locked)+ 未选中态(noactive) */
|
/** 页签文案 + 各阶已投入点数 + 选中高亮(sp_on)+ 锁定图标(locked)+ 未选中态(noactive) */
|
||||||
private refreshTabs(levels: Record<number, number>): void {
|
private refreshTabs(levels: Record<number, number>): void {
|
||||||
for (const [tier, tab] of this.tabNodes) {
|
for (const [tier, tab] of this.tabNodes) {
|
||||||
const text = TIER_TAB_TEXT[tier];
|
const text = TIER_TAB_TEXT[tier];
|
||||||
const unlocked = isTalentTierUnlocked(levels, tier);
|
const unlocked = isTalentTierUnlocked(levels, tier);
|
||||||
if (tab.label) {
|
if (tab.label) tab.label.string = text.title;
|
||||||
if (unlocked) {
|
// 各阶已投入点数(该阶所有天赋等级之和)
|
||||||
tab.label.string = text.title;
|
if (tab.invest) tab.invest.string = `${getTalentTierInvestedPoints(levels, tier)}`;
|
||||||
} else {
|
|
||||||
const invested = getTalentTierInvestedPoints(levels, (tier - 1) as TalentTier);
|
|
||||||
tab.label.string = `${text.title} ${invested}/${TALENT_TIER_UNLOCK_THRESHOLD}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 锁定图标:该阶未解锁时显示,解锁后隐藏(一阶恒解锁,节点可缺省)
|
// 锁定图标:该阶未解锁时显示,解锁后隐藏(一阶恒解锁,节点可缺省)
|
||||||
const locked = tab.node?.getChildByName(TAB_LOCKED_CHILD);
|
const locked = tab.node?.getChildByName(TAB_LOCKED_CHILD);
|
||||||
if (locked) locked.active = !unlocked;
|
if (locked) locked.active = !unlocked;
|
||||||
@@ -248,7 +252,7 @@ export class TalentsComp extends CCComp {
|
|||||||
const tab = this.tabNodes.get(cfg.tier);
|
const tab = this.tabNodes.get(cfg.tier);
|
||||||
if (!isTalentTierUnlocked(levels, cfg.tier)) {
|
if (!isTalentTierUnlocked(levels, cfg.tier)) {
|
||||||
const invested = getTalentTierInvestedPoints(levels, (cfg.tier - 1) as TalentTier);
|
const invested = getTalentTierInvestedPoints(levels, (cfg.tier - 1) as TalentTier);
|
||||||
this.showSmallTip(tab?.node ?? null, `${TIER_TAB_TEXT[cfg.tier].lockName}投入 ${invested}/${TALENT_TIER_UNLOCK_THRESHOLD} 点解锁本阶`);
|
this.showSmallTip(tab?.node ?? null, `${TIER_TAB_TEXT[cfg.tier].lockName}投入${TALENT_TIER_UNLOCK_THRESHOLD} 点解锁`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const lv = smc.getTalentLv(uuid);
|
const lv = smc.getTalentLv(uuid);
|
||||||
|
|||||||
Reference in New Issue
Block a user