import { _decorator, Component, director, Node, tween } from 'cc';
import { Global } from './Global';
import { Clips } from './Enums';
import { AudioMgr } from './AudioMgr';
import { BasePage } from './BasePage';
import { AdManger } from './ad/AdManger';
const { ccclass, property } = _decorator;

@ccclass('MenuAction')
export class MenuAction extends BasePage {

    @property({ type: Node })
    xxx_node: Node

    start() {
        super.start();
    }

    update(deltaTime: number) {

    }

    private set_xxx() {
        this.xxx_node.active = !Global.sound_switch;
    }

    on_off_sound() {
        AudioMgr.ins.playSound(Clips.btn_1);
        Global.sound_switch = !Global.sound_switch;
        this.set_xxx();
    }

    /**
     * show menu plant
     */
    open() {
        super.open();
        //show interstial
        AdManger.show_interstial();
        this.set_xxx();
    }

    /**
     * go to home page
     */
    btn_go_home() {
        this.close();
        director.loadScene("home");
    }

    /**
     * continue game
     */
    btn_continue_game() {
        this.close();
    }

    /**
     * restart game
     *
     */
    btn_restart_game() {
        this.close();
        Global.main_action.restart_game();
    }
}

