BulletData.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { BattleDataPool } from "./BattleDataPool";
  2. import { BattleUtil } from "./BattleUtil";
  3. import { BuffData } from "./BuffData";
  4. import { DataBase } from "./DataBase";
  5. import { EnemyData } from "./EnemyData";
  6. import { HeroData } from "./HeroData";
  7. //弹道子弹
  8. export class BulletData extends DataBase{
  9. //所属格子 -1表示暂无
  10. posID: number;
  11. //当前坐标
  12. position:BattleUtil.Vector2;
  13. //移动速度
  14. speedCur: number;
  15. speedVector:BattleUtil.Vector2;
  16. //攻击范围
  17. attackRadius: number;
  18. //碰撞范围
  19. boxRadius: number;
  20. //来源
  21. srcHeroID:number;
  22. srcHero:HeroData;
  23. //目标敌人
  24. targetEnemyID:number;
  25. targetEnemy:EnemyData;
  26. //目标坐标 如果不指向敌人则指向坐标
  27. targetPosition:BattleUtil.Vector2;
  28. buffDataList: Array<BuffData>;
  29. init(typeID:number,srcHero:HeroData,targetEnemy:EnemyData){
  30. super._init();
  31. this.speedCur = 100/BattleUtil.FrameRate;
  32. this.attackRadius = 10;
  33. this.typeID = typeID;
  34. this.srcHero = srcHero;
  35. this.position = srcHero.position;
  36. this.targetEnemy = targetEnemy;
  37. this.targetPosition = targetEnemy.position;
  38. this.speedVector = BattleUtil.Vector2.Sub(this.targetPosition,this.position);
  39. this.speedVector.normalize();
  40. this.speedVector.multiply(this.speedCur);
  41. this.buffDataList = []
  42. return this;
  43. }
  44. clear(): void {
  45. super.clear();
  46. }
  47. }
  48. export let BulletDataPool = new BattleDataPool(BulletData,100)