
import { LQCollide } from "../../Script/Collide/lq_collide_system/lq_collide";
import { LQCollideInfoList } from "../../Script/Collide/lq_collide_system/lq_collide_config";
import move from "./update/move";


const {ccclass, property} = cc._decorator;

@ccclass
export default class bullet extends LQCollide {

    /*===========================自动绑定组件开始===========================*/
	/*自动生成*/
    @property({type:dragonBones.ArmatureDisplay, displayName:""})
    private $dragon_bone:dragonBones.ArmatureDisplay = null;

	/*===========================自动绑定组件结束===========================*/

    /*===========================自动生成按钮事件开始==========================*/

	/*===========================自动生成按钮事件结束==========================*/

    moveCpt: move = null;
    protected onLoad(): void {
        this.$dragon_bone.playAnimation('appear', 1);
        this.$dragon_bone.addEventListener('complete', ()=>{
            this.$dragon_bone.playAnimation('bullet_1', 0);
        });
    }

    public on_enter(collide: LQCollide): void {
        // cc.log(collide);
        this.node.destroy();
        if(collide.collide_group_index == LQCollideInfoList.enemy) {
            collide.node.destroy();
            cc.log('@@ -- ', collide.node.name);
        }
    }

    getMoveCpt(): move{
        if(!this.moveCpt) {
            this.moveCpt = this.node.getComponent(move);
            if(!this.moveCpt) {
                this.moveCpt = this.node.addComponent(move);
            }
        }

        return this.moveCpt;
    }
}