import { Widget, _decorator, Node } from 'cc';
import { UIBase } from '../scriptBase/UIBase';
import { EventMgr } from '../manager/EventMgr';
import { EventType } from '../enum/EventType';
import { TransMgr } from '../manager/TransMgr';
import { GameMgr } from '../manager/GameMgr';
import { UI } from '../enum/UI';
import { AudioMgr } from '../manager/AudioMgr';
import { ModeName } from '../enum/Mode';
import { AdMgr } from '../manager/AdMgr';
const { ccclass, property, requireComponent } = _decorator;

@ccclass('UI/UITimeOut')
@requireComponent(Widget)
export class UITimeOut extends UIBase {

    public onOpen(data?: any): void {
        GameMgr.Pause = true
        AudioMgr.playSfx('通关失败')
    }

    public onClose(data?: any): void {
        GameMgr.Pause = false
    }

    protected async onBtnCloseClick() {
        await TransMgr.Inst.fadeIn()
        this.close()
        GameMgr.quitGame()
        this.open(UI.Main)
        TransMgr.Inst.fadeOut()
    }

    protected onBtnYesClick(): void {
        AdMgr.showRewardedVideo(() => {
            this.close()
            EventMgr.emit(EventType.Revive)
        })
    }

}


