BuffData.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { BuffConf } from "../conf/BuffConf";
  2. import { BattleDataPool } from "./BattleDataPool";
  3. import { BattleUtil } from "./BattleUtil";
  4. import { DataBase } from "./DataBase";
  5. //buff类型, 包含debuff
  6. export class BuffData extends DataBase{
  7. //叠加类型
  8. cover:number;
  9. //来源
  10. srcDataBaseID:number;
  11. srcDataBase:DataBase;
  12. //来源
  13. targetDataBaseID:number;
  14. targetDataBase:DataBase;
  15. //动态参数------------
  16. //持续时间 同类buff可能刷新
  17. duration:number;
  18. //生命时间 当前buff已经存活时间
  19. lifeTime:number;
  20. //其他参数
  21. valueList:Array<number> = [];
  22. init(typeID:number,duration:number,valueList:Array<number>, src:DataBase,target:DataBase){
  23. super._init();
  24. this.typeID = typeID;
  25. this.srcDataBaseID = src.ID;
  26. this.srcDataBase = src;
  27. this.targetDataBaseID = target.ID;
  28. this.targetDataBase = target;
  29. let conf = BuffConf.data[typeID]
  30. if(conf){
  31. this.cover = conf.Cover;
  32. }
  33. else return null;
  34. this.duration = duration;
  35. this.valueList = valueList
  36. return this;
  37. }
  38. clear(){
  39. this.duration = 0;
  40. this.lifeTime = 0;
  41. //来源
  42. this.srcDataBaseID = BattleUtil.TypeID_Init;
  43. this.srcDataBase = null;
  44. //来源
  45. this.targetDataBaseID = BattleUtil.TypeID_Init;
  46. this.targetDataBase = null;
  47. this.valueList = []
  48. }
  49. }
  50. export let BuffDataPool = new BattleDataPool(BuffData,100)