// Learn cc.Class:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        // foo: {
        //     // ATTRIBUTES:
        //     default: null,        // The default value will be used only when the component attaching
        //                           // to a node for the first time
        //     type: cc.SpriteFrame, // optional, default is typeof default
        //     serializable: true,   // optional, default is true
        // },
        // bar: {
        //     get () {
        //         return this._bar;
        //     },
        //     set (value) {
        //         this._bar = value;
        //     }
        // },
        yy_Node  : cc.Node,
        yx_Node  : cc.Node,
        zd_Node  : cc.Node,
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () 
    {
        this.setyy_Node();
        this.setyx_Node();
        this.setzd_Node();
       
    },


    setyy_Node()
    {
         //初始化显示开关
         if(cc.rtData.yy)
         {
             this.yy_Node.getChildByName("1").active = true;
             this.yy_Node.getChildByName("2").active = false;
             cc.rtData.AudioMgr.setBGMVolume(1)
         }
         else
         {
             this.yy_Node.getChildByName("1").active = false;
             this.yy_Node.getChildByName("2").active = true;
             cc.rtData.AudioMgr.setBGMVolume(0)
         }
    },

    setyx_Node()
    {
        if(cc.rtData.yx)
        {
            this.yx_Node.getChildByName("1").active = true;
            this.yx_Node.getChildByName("2").active = false;
            cc.rtData.AudioMgr.setSFXVolume(1)
        }
        else
        {
            this.yx_Node.getChildByName("1").active = false;
            this.yx_Node.getChildByName("2").active = true;
            cc.rtData.AudioMgr.setSFXVolume(0)
        }
    },
    setzd_Node()
    {
        if(cc.rtData.zd)
        {
            this.zd_Node.getChildByName("1").active = true;
            this.zd_Node.getChildByName("2").active = false;
        }
        else
        {
            this.zd_Node.getChildByName("1").active = false;
            this.zd_Node.getChildByName("2").active = true;
        }
    },



    start () {

    },

    quit_Cilck()
    {
        cc.rtData.AudioMgr.playComBtnClickSfx();
        this.node.destroy();
    },

    yy_Cilck()
    {
        cc.rtData.AudioMgr.playComBtnClickSfx();
        cc.rtData.yy = !cc.rtData.yy;
        cc.sys.localStorage.setItem('game_yy',cc.rtData.yy ? 1 : 2);

        this.setyy_Node();

    },

    yx_Cilck()
    {
        cc.rtData.AudioMgr.playComBtnClickSfx();
        cc.rtData.yx = !cc.rtData.yx;
        cc.sys.localStorage.setItem('game_yx',cc.rtData.yx ? 1 : 2);
        this.setyx_Node();

    },

    zd_Cilck()
    {
        cc.rtData.AudioMgr.playComBtnClickSfx();
        cc.rtData.zd = !cc.rtData.zd;
        cc.sys.localStorage.setItem('game_zd',cc.rtData.zd ? 1 : 2);
        this.setzd_Node();
    },

    exit_Click()
    {
        cc.rtData.AudioMgr.playComBtnClickSfx();
        cc.game.end();
    },

    rstart_Click()
    {
        cc.rtData.AudioMgr.playComBtnClickSfx();
        if(cc.director.getScene().getName() == "game_in")
        {
            cc.director.loadScene("game_start");
        }
        
    }


    // update (dt) {},
});
