You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
3.7 KiB
106 lines
3.7 KiB
|
|
//*********************
|
|
// create by 流云
|
|
// time: Wed Aug 19 2026
|
|
// desc: 每日俸禄(段位金币 + 胜场金币)
|
|
//*********************
|
|
import { _decorator, Node } from 'cc';
|
|
import { Auto_PopEmolument } from './Auto_PopEmolument';
|
|
import { UIID } from '../../game/ConfigRes';
|
|
import { RankDataManager } from '../../manager/RankDataManager';
|
|
import { EmolumentDataManager } from '../../manager/EmolumentDataManager';
|
|
import { RankReport } from '../../manager/RankReport';
|
|
import type { EmolumentCoinFlySource } from '../PanelHome/PanelHomeEmolumentCoinFlyPresenter';
|
|
import type { UIPanelHome } from '../PanelHome/UIPanelHome';
|
|
|
|
const { ccclass } = _decorator;
|
|
|
|
@ccclass('UIPopEmolument')
|
|
export class UIPopEmolument extends Auto_PopEmolument {
|
|
|
|
onInit(): void {
|
|
void this._refreshView();
|
|
}
|
|
|
|
click_bgMask(): void {
|
|
this.click_btnReceive();
|
|
}
|
|
|
|
click_btnReceive(): void {
|
|
const rankGold = EmolumentDataManager.getRankTierGold();
|
|
const winGold = EmolumentDataManager.calcWinRewardGold();
|
|
const flySources = this._buildCoinFlySources(rankGold, winGold);
|
|
|
|
const total = EmolumentDataManager.claim();
|
|
if (total == null) {
|
|
console.warn('[UIPopEmolument] 弹窗已开但领取失败');
|
|
this.close(2);
|
|
return;
|
|
}
|
|
|
|
RankReport.rankSalary();
|
|
gg.dot?.updateRedDot();
|
|
this.close(2);
|
|
this._playHomeCoinFly(flySources);
|
|
}
|
|
|
|
/** 奖励 > 0 的起点:记录 Pop 金币节点世界坐标(影子模板用 Home 顶栏金币) */
|
|
private _buildCoinFlySources(rankGold: number, winGold: number): EmolumentCoinFlySource[] {
|
|
const sources: EmolumentCoinFlySource[] = [];
|
|
if (rankGold > 0) {
|
|
const source = this._captureCoinFlySource(this.ui_coin);
|
|
if (source) sources.push(source);
|
|
}
|
|
if (winGold > 0) {
|
|
const source = this._captureCoinFlySource(this.ui_coin1);
|
|
if (source) sources.push(source);
|
|
}
|
|
return sources;
|
|
}
|
|
|
|
/** 记录 PopEmolument 金币节点世界坐标 */
|
|
private _captureCoinFlySource(coinNode: Node | null): EmolumentCoinFlySource | null {
|
|
if (!coinNode?.isValid) {
|
|
console.log('[UIPopEmolument] 金币节点缺失');
|
|
return null;
|
|
}
|
|
return { worldPos: coinNode.worldPosition.clone() };
|
|
}
|
|
|
|
/** 通知 Home 播放金币飞行(延迟一帧,等 Pop 关闭释放 Rank 资源后再生成影子) */
|
|
private _playHomeCoinFly(sources: EmolumentCoinFlySource[]): void {
|
|
if (!sources.length) return;
|
|
const home = gg.ui.getPanelBase(UIID.Home) as UIPanelHome | null;
|
|
if (!home?.isValid) {
|
|
console.log('[UIPopEmolument] Home 未打开,跳过金币飞');
|
|
return;
|
|
}
|
|
home.playEmolumentCoinFly(sources);
|
|
}
|
|
|
|
private async _refreshView(): Promise<void> {
|
|
await EmolumentDataManager.ensureTable();
|
|
if (!this.isValid) return;
|
|
|
|
const stars = EmolumentDataManager.getSnapStars();
|
|
const wins = EmolumentDataManager.getSnapWins();
|
|
const rankGold = EmolumentDataManager.getRankTierGold(stars);
|
|
const winGold = EmolumentDataManager.calcWinRewardGold(wins);
|
|
|
|
const tier = RankDataManager.resolveTierByStars(stars);
|
|
await RankDataManager.applyRankLevelIconToNodeAsync(this.ui_rankLevel, tier?.id);
|
|
|
|
if (this.lb_num1) {
|
|
this.lb_num1.string = String(rankGold);
|
|
}
|
|
if (this.lb_winNum) {
|
|
this.lb_winNum.string = String(wins);
|
|
}
|
|
if (this.lb_num2) {
|
|
this.lb_num2.string = String(winGold);
|
|
}
|
|
if (this.btnReceive?.isValid) {
|
|
this.btnReceive.active = true;
|
|
}
|
|
}
|
|
}
|
|
|