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

@ccclass('dpComponent')
export class dpComponent extends Component {

    //plane移动动画
    @property(Animation)
    public p_an:Animation = null;

    private dpSpeed:number = 0;

    @property
    public _dpType = dpImpl.dpType.TYPE1;

    //飞行最大距离
    public dp_max:number = 12;

    start() {

        this.p_an.crossFade('p_an', .5);
    }

    update(deltaTime: number) {

        const pos = this.node.position;
        let movez = pos.z + this.dpSpeed;
        this.node.setPosition(pos.x, pos.y, movez);
        
        if(movez > this.dp_max) this.node.destroy();

    }

    public _init(speed:number){
        this.dpSpeed = speed;
    }

}

