import FSprite from "../FSprite";

/**
 * 默认的AI
 * 警戒范围内
 * 追击范围
 * 仇恨转移
 */
const {ccclass, property} = cc._decorator;

@ccclass
export default class AIDef extends cc.Component {
    /**
     * 移动速度
     */
    @property({
        displayName: '移动速度'
    })
    public speedN = 80000;
    /**
     * 移动速度
    */
    @property({
        displayName: '警戒范围'
    })
    public dis = 500;

    /**
    * 当前AI控制的精灵
    */
    public sprite:FSprite = null;
    /**
     * 当前仇恨目标
     */
    public target:FSprite = null;

    onLoad () {
        this.sprite = this.node.getComponent(FSprite);
        this.sprite.mRigidBody.linearDamping = 60;
    }

    update (dt) {
        if (this.sprite.gamePause) {
            return;
        }
        this.AI()
        if (this.sprite.isWalk) {
            let moveV2 = this.sprite.moveV2;
            this.sprite.mRigidBody.applyLinearImpulse(
                cc.v2(moveV2.x * this.speedN * dt, moveV2.y * this.speedN * dt),
                this.sprite.mRigidBody.getWorldCenter(),
                true
            );
        }
    }

    public AI(){
        if(this.target && this.target.node.isValid && this.target.isActive){


        }else{
            

        }
    }


}
