import { BattleDataPool } from "./BattleDataPool";
import { BattleUtil } from "./BattleUtil";
import { BuffData } from "./BuffData";
import { DataBase } from "./DataBase";
import { EnemyData } from "./EnemyData";
import { HeroData } from "./HeroData";

//弹道子弹
export class BulletData extends DataBase{

    //所属格子 -1表示暂无
    posID: number;
    //当前坐标
    position:BattleUtil.Vector2;
    
    //移动速度
    speedCur: number;
    speedVector:BattleUtil.Vector2;
    //攻击范围
    attackRadius: number;
    //碰撞范围
    boxRadius: number;

    //来源  
    srcHeroID:number;
    srcHero:HeroData;
    //目标敌人
    targetEnemyID:number;
    targetEnemy:EnemyData;
    //目标坐标 如果不指向敌人则指向坐标
    targetPosition:BattleUtil.Vector2;

    buffDataList: Array<BuffData>;

    init(typeID:number,srcHero:HeroData,targetEnemy:EnemyData){
        
        super._init();
        this.speedCur = 100/BattleUtil.FrameRate;
        this.attackRadius = 10;
        this.typeID = typeID;

        this.srcHero = srcHero;
        this.position = srcHero.position;
        this.targetEnemy = targetEnemy;
        this.targetPosition = targetEnemy.position;
        this.speedVector = BattleUtil.Vector2.Sub(this.targetPosition,this.position);
        this.speedVector.normalize();
        this.speedVector.multiply(this.speedCur);
        this.buffDataList = []
        return this;
    }

    clear(): void {
        super.clear();
    }
}

export let BulletDataPool = new BattleDataPool(BulletData,100)

