import { _decorator, Animation, Component, Node, tween, Vec3 } from 'cc';
import { config } from '../../config';
const { ccclass, property } = _decorator;

@ccclass('buff_active_effect_item')
export class buff_active_effect_item extends Component {
    private mDis:Vec3 = Vec3.ZERO
    private mFinishCb = null
    public show(type:number,dis:Vec3,pos:Vec3,cb){
        this.node.position = pos
        this.mDis = dis;
        this.mFinishCb = cb
        if(this.mFinishCb!=null){
            this.mFinishCb()
        }
        switch (type) {
            case config.SHOW_BUFF_STATUS.DUN:
                this.node.getComponent(Animation).play("active_dun")
            break;
            case config.SHOW_BUFF_STATUS.XI:
                this.node.getComponent(Animation).play("active_xi")
            break;
            case config.SHOW_BUFF_STATUS.XING:
                this.node.getComponent(Animation).play("active_xing")
            break;
        }
    }

    public buff_free(){
        tween(this.node).to(0.5,{position:this.mDis}).call(()=>{
            this.node.removeFromParent()
        }).start()
    }
}


