//顶部碰撞体脚本

cc.Class({
    extends: cc.Component,

    properties: {
        deathUI: cc.Node,  //游戏结束界面节点
        knife: cc.Node,   //一把飞镖节点
        knifeNum: cc.Node, //三把飞镖节点
        labSanNum: cc.Label,  //显示三镖齐发还有几次用完
        threeDartBtn: cc.Node, //三镖齐发按钮
        textBg: cc.Node,
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {

    },

    //发生碰撞后的回调函数  (顶部碰撞体)
    /**
     * @param  {} other  与之碰撞的节点
     * @param  {} self  自身节点
     */
    onCollisionEnter: function (other,self) {
        console.log("顶部碰撞体",cc.HQ.GameMgr.isGameOver);
        if(!cc.HQ.GameMgr.isGameOver){
            cc.HQ.GameMgr.isInitGame =false;
            this.onSanKnifeShow();
            //游戏结束
            this.onCheckOver();
        }

    },

    //发射三飞镖，就算游戏结束也要把三飞镖减掉
    //三飞镖数量显示
    onSanKnifeShow: function(){
        console.log("游戏结束三飞镖数还剩",cc.HQ.Local.weaponClones);
        if(!cc.HQ.Local.experWeapons){
            if(cc.HQ.Local.weaponClones && cc.HQ.Local.weaponClones>0){
                this.knife.active =false;
                this.knifeNum.active =true;
                //显示三镖齐发还剩几发
                this.textBg.active =true;
                this.labSanNum.string ="X"+cc.HQ.Local.weaponClones;
            }else{
                // console.log("111111111111111");
                if(!this.knife.active){
                    this.knife.active =true;
                    this.knifeNum.active =false;
                    this.threeDartBtn.active =true;  //三镖齐发按钮显示
                    this.labSanNum.node.active =false;
                    this.textBg.active =false;
                }
            }
        }
    },


    //游戏结束
    onCheckOver: function(){
        this.deathUI.active =true;
        // cc.HQ.showGroupRank =false;
    },

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