// Learn cc.Class:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] https://www.cocos2d-x.org/docs/creator/manual/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;
        //     }
        // },
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        if(this.node.name == 'Skill4'){
            setTimeout(function(){
                if(this.node)
                this.node.destroy()
            }.bind(this),10000)
        }
        else if(this.node.name == 'Skill2'){
            setTimeout(function(){
                if(this.node)
                this.node.destroy()
            }.bind(this),1400)
        }
        else{
            setTimeout(function(){
                if(this.node)
                this.node.destroy()
            }.bind(this),2400)
        }
    },
    onCollisionEnter: function (other, self) {
        if(this.node.name == 'Skill1'){

        }
        else if(this.node.name == 'Skill3'){
            if( other.node.name!='EnemyBullet'){
                if(!this.isBoom){
                    this.isBoom = 1
                    this.node.stopAllActions()
                    this.node.runAction(cc.sequence(cc.moveBy(0.2,0,120),cc.scaleTo(0.5,2.4)))
                }
                setTimeout(function(){
                    if(this.node)
                    self.node.destroy()
                }.bind(this),2000)
            }
        }            
        else if(this.node.name == 'Skill4'){
            this.node.runAction(cc.sequence(cc.tintTo(0.1,255,0,0),cc.tintTo(0.1,255,255,255)))
        }
        else
        self.node.destroy()
    }

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