
//一个节点发射运动

cc.Class({
    extends: cc.Component,

    properties: {
        pumpNode: cc.Node,  //飞刀特效
        pumpNode1: cc.Node, //飞刀特效1
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        this.onDaiji();
    },

    onDaiji: function(){
        this.node.runAction(cc.repeatForever(
            cc.sequence(
                cc.moveBy(0.4, 0, 40),
                cc.moveBy(0.4, 0, -40),
            )
        ));    
    },

    onLauch: function(){
        // console.log("444444",this.node.getComponent(cc.BoxCollider).size);
        if(cc.HQ.Local.weaponSkin>0){  //皮肤体验的还有次数
            this.node.getComponent(cc.BoxCollider).size.width =49;
            this.pumpNode.active =false;
            this.pumpNode1.active =false;
        }else{
            // let userCurWeapan =cc.HQ.GameMgr.getCurKnife();  //当前装备的飞刀
            let userCurWeapan =cc.HQ.GameMgr.onSetCurrSkin();  //显示当前装备的飞刀
            console.log("一飞镖ID",userCurWeapan);
            if(userCurWeapan ==65){
                this.node.getComponent(cc.BoxCollider).size.width =140;
                this.pumpNode.active =true;
                this.pumpNode1.active =true;
            }else if(userCurWeapan ==82 ||userCurWeapan ==83 ||userCurWeapan ==84 ||userCurWeapan ==85 ||userCurWeapan ==86 ||userCurWeapan ==87||userCurWeapan ==88||userCurWeapan ==89||userCurWeapan ==90||userCurWeapan ==91 ||userCurWeapan ==92
            ||userCurWeapan ==93 ||userCurWeapan ==94 ||userCurWeapan ==95 ||userCurWeapan ==96){
                this.node.getComponent(cc.BoxCollider).size.width =72;
                this.pumpNode.active =true;
                this.pumpNode1.active =true;
            }else{
                this.node.getComponent(cc.BoxCollider).size.width =49;  
                this.pumpNode.active =false;
                this.pumpNode1.active =false;    
            }
        }

        let cdFunc = cc.callFunc(()=>{
            // cc.HQ.GameMgr.isInitGame =true;    
            this.node.setPosition(0,-325);
            this.node.rotation =0;
        },this)

        let cdFunc2 = cc.callFunc(()=>{
            cc.HQ.GameMgr.isInitGame =true;    
        },this)

        this.node.runAction(cc.sequence(
            cc.spawn(
                cc.rotateBy(0.4, 720),
                cc.moveBy(0.4, 0, 1100)
            ),          
            cdFunc,
            cc.delayTime(0.1),
            cdFunc2
        ));
    },

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