//********************* // create by 流云 // time: Fri Jul 31 2026 // desc: //********************* import { _decorator } from 'cc'; import { Auto_PopAutoM } from './Auto_PopAutoM'; import { AUTO_MERGE_UNLOCK_VIDEO_COUNT, canClaimAutoMergeChapter1HardFree, claimAutoMergeChapter1HardFree, getAutoMergeVideoUnlockCount, isAutoMergeFeatureEnabled, isAutoMergePermanentlyUnlocked, recordAutoMergeVideoUnlock, } from '../../battle/BattleAutoMergeUnlock'; import { BattleRuntime } from '../../battle/runtime/BattleRuntime'; const { ccclass } = _decorator; @ccclass('UIPopAutoM') export class UIPopAutoM extends Auto_PopAutoM { onInit(): void { this._refreshUnlockCountUi(); this._syncFreeUseVideoIcon(); } private _isChapter1HardFree(): boolean { const match = gg.game.CurentBattle as BattleRuntime | null; if (!match) return false; return canClaimAutoMergeChapter1HardFree(match.LevelConfigId); } private _refreshUnlockCountUi(): void { const count = getAutoMergeVideoUnlockCount(); this.rt_Count.string = `已使用:(${count}/${AUTO_MERGE_UNLOCK_VIDEO_COUNT})次 `; } /** 第一章困难免费时隐藏「视频标」 */ private _syncFreeUseVideoIcon(): void { const videoIcon = this.btnUse?.getChildByName('视频标'); if (videoIcon?.isValid) { videoIcon.active = !this._isChapter1HardFree(); } } click_btnClose(): void { this.close(2); } click_btnUse(): void { if (!isAutoMergeFeatureEnabled()) return; const match = gg.game.CurentBattle as BattleRuntime | null; if (!match || match.IsGameOver) return; // 第一章困难:首次免费激活本局自动合成(不看广告、不计入视频解锁次数) if (canClaimAutoMergeChapter1HardFree(match.LevelConfigId)) { claimAutoMergeChapter1HardFree(); match.grantAutoMergeForMatch(); gg.sdk.reportDY('inLevel', `${gg.game.getReportDYBattleLabel()}-自动合成-第一章困难免费`); this.close(2); return; } gg.sdk.showVideoAd((res) => { if (!res) { gg.ui.showToast('观看视频失败'); return; } recordAutoMergeVideoUnlock(); match.grantAutoMergeForMatch(); gg.sdk.reportDY( 'inLevel', `${gg.game.getReportDYBattleLabel()}-AD-自动合成${isAutoMergePermanentlyUnlocked() ? '-永久解锁' : ''}`, ); this.close(2); }); } }