import { _decorator, Component, Node } from 'cc';
import { GUIManager } from '../../../engines/gui/GUIManager';
import { GUIMediator } from '../../../engines/gui/GUIMediator';
import { SceneManager } from '../../../engines/scenes/SceneManager';
import { LiangLiangSDK } from '../../../libs/liangliangSDK';
import { PlatformManager } from '../../../Platform/PlatformManager';
import { UIConst } from '../UIConst';
const { ccclass, property } = _decorator;

@ccclass('FullOutputMediator')
export class FullOutputMediator extends GUIMediator {
    continueShowBanner:boolean = true;
    @property({
        type:Node
    })
    ContinueButton:Node=null;

    start () {
        // Your initialization goes here.
        this.ContinueButton.active = false;
        this.scheduleOnce(this.showContinueButton.bind(this), 3);
    }

    OnShow(data?:any):void{
        PlatformManager.hideBanner();
        this.data=data;
    }

    OnHide():void{

    }

    showContinueButton():void{
        this.ContinueButton.active = true;
    }

    /**
     * 返回主界面
     */
    BackToMain():void{
        SceneManager.single.Swicth("PrepareScene");
        this.HideSelf();
    }
    
    ContinueGame():void{
        if(LiangLiangSDK.CanWuChu() == true){
            if(this.continueShowBanner == true){
                this.__bannerWuChu();
            }else{
                // GUIManager.single.Show(UIConst.FIGHTING_UI);
                SceneManager.single.Swicth("PrepareScene");
                this.HideSelf();
            }
        }else{
            // GUIManager.single.Show(UIConst.FIGHTING_UI);
            SceneManager.single.Swicth("PrepareScene");
            this.HideSelf();
        }
    }

    /**
     * 误触逻辑
     */
    private __bannerWuChu():void{
        this.scheduleOnce(()=>{
            PlatformManager.showBanner();
            this.scheduleOnce(()=>{
                PlatformManager.hideBanner();
                this.continueShowBanner = false;
            }, 1)
        }, 1)
    }
    
    // update (deltaTime: number) {
    //     // Your update function goes here.
    // }
}
