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.
AdLike2048/assets/script/ui/PopBattleSpeed/UIPopBattleSpeed.ts

54 lines
1.6 KiB

3 weeks ago

//*********************
// create by 流云
// time: Wed Jul 29 2026
// desc:
//*********************
import { _decorator } from 'cc';
import { Auto_PopBattleSpeed } from './Auto_PopBattleSpeed';
import {
BATTLE_SPEED_UNLOCK_VIDEO_COUNT,
getBattleSpeedVideoUnlockCount,
isBattleSpeedPermanentlyUnlocked,
recordBattleSpeedVideoUnlock,
} from '../../battle/BattleSpeedUnlock';
import { BattleRuntime } from '../../battle/runtime/BattleRuntime';
const { ccclass } = _decorator;
@ccclass('UIPopBattleSpeed')
export class UIPopBattleSpeed extends Auto_PopBattleSpeed {
onInit(): void {
this._refreshUnlockCountUi();
}
private _refreshUnlockCountUi(): void {
const count = getBattleSpeedVideoUnlockCount();
this.rt_Count.string =
`<b>已使用:(<color=#FF1400>${count}/${BATTLE_SPEED_UNLOCK_VIDEO_COUNT}</color>)次 </b>`;
}
click_btnClose(): void {
this.close(2);
}
click_btnUse(): void {
const match = gg.game.CurentBattle as BattleRuntime | null;
if (!match || match.IsGameOver) return;
gg.sdk.showVideoAd((res) => {
if (!res) {
gg.ui.showToast('观看视频失败');
return;
}
recordBattleSpeedVideoUnlock();
match.grantBattleSpeed2xForMatch();
gg.sdk.reportDY(
'inLevel',
`${gg.game.getReportDYBattleLabel()}-AD-战斗加速${isBattleSpeedPermanentlyUnlocked() ? '-永久解锁' : ''}`,
);
this.close(2);
});
}
}