
import { _decorator, director } from 'cc';
import BasePanel from '../../../core/component/BasePanel';
import Data from '../../../core/manager/Data';
import WindowManager from '../../../core/manager/WindowManager';
import { Main } from '../Main';
import platformSystem from 'db://assets/platform/platformSystem';
import audioManager from 'db://assets/manager/audioManager';
import { constants } from 'db://assets/data/constants';
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) {
        audioManager.playOneShot(constants.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.Instance().backHall();
                break;
            case "btn_replay":
                this.close();
                WindowManager.ins.open("LevelLayer");
                break;
            case "btn_back":
                this.close();
                break;
        }
    }

}
