
import { _decorator, director } from 'cc';
import platformSystem from '../platform/platformSystem';

import BasePanel from '../core/component/BasePanel';
import { audioMgr } from '../core/manager/AudioManager';
import Data from '../core/manager/Data';
import WindowManager from '../core/manager/WindowManager';
import { Main } from '../game/Main';
import { GameConst } from '../core/common/GameConst';
const { ccclass, property } = _decorator;

@ccclass('PauseLayer')
export class PauseLayer extends BasePanel {

    onDestroy() {
        this.dispatch("PAUSE_LAYER_CLOSE")
        super.onDestroy();
    }
    start(){
        platformSystem.platform.showInterstitialAd();
    }

    onBtnClicked(event: any, customEventData: any) {
       audioMgr.playOneShot(GameConst.audios.btnclick);
        var btnName = event.target.name;
        switch (btnName) {
            case "btn_close":
                this.close();
                break;
            case "btn_hall":
                Data.user.life--;
                Data.user.life_cost_time = Date.now();
                this.close();
                Main.I.backHall();
                break;
            case "btn_replay":
                this.close();
                WindowManager.ins.open("LevelLayer");
                break;
            case "btn_back":
                this.close();
                break;
        }
    }

}
