skillBehaviorDartle.lua 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. local skillBehavior = require("skill/skillBehavior")
  2. local skillBehaviorDartle = class("skillBehaviorDartle", skillBehavior)
  3. local skillPresentLaunch = require("skill/skillPresentLaunch")
  4. local skillPresentFly = require("skill/skillPresentFly")
  5. local skillPresentHit = require("skill/skillPresentHit")
  6. local TIMER_INTERVAL = 0.02
  7. function skillBehaviorDartle:ctor(id, data, config)
  8. skillBehaviorDartle.super.ctor(self, id, data, config)
  9. self._launchPresent = nil
  10. self._flyJoined = false
  11. self._count = 4
  12. self._flyEnable = false
  13. self._finished = 0
  14. self._delayTime = TIMER_INTERVAL
  15. self._flyPresents = {}
  16. end
  17. function skillBehaviorDartle:init()
  18. end
  19. function skillBehaviorDartle:launch()
  20. skillBehaviorDartle.super.launch(self)
  21. if self._data.skillStage == 1 then
  22. self:joinLaunch()
  23. elseif self._data.skillStage == 2 then
  24. self:joinLaunchOver()
  25. else
  26. self:joinLaunch()
  27. self:joinLaunchOver()
  28. end
  29. -- launch
  30. self:launchBehavior()
  31. end
  32. function skillBehaviorDartle:launchBehavior()
  33. if self._launchPresent then
  34. self._launchPresent:launch()
  35. return true
  36. end
  37. self._flyEnable = true
  38. return false
  39. end
  40. function skillBehaviorDartle:joinLaunch()
  41. if self._launchPresent then
  42. return nil
  43. end
  44. self._launchPresent = skillPresentLaunch.new(self._data, self._config, self._launchRoot, nil, self)
  45. self._launchPresent:init()
  46. end
  47. function skillBehaviorDartle:joinLaunchOver()
  48. self._flyJoined = true
  49. end
  50. function skillBehaviorDartle:onLaunch(skillPB)
  51. end
  52. function skillBehaviorDartle:onFinish(skillPB)
  53. if skillPB:getType() == global.MMO.SKILL_PRESENT_LAUNCH then
  54. self._flyEnable = true
  55. self._launchPresent = nil
  56. if not self._flyJoined then
  57. self:disable()
  58. end
  59. elseif skillPB:getType() == global.MMO.SKILL_PRESENT_FLY then
  60. self._finished = self._finished + 1
  61. if self._finished >= self._count then
  62. self:disable()
  63. end
  64. end
  65. end
  66. function skillBehaviorDartle:Tick(dt)
  67. if self._launchPresent then
  68. self._launchPresent:Tick(dt)
  69. end
  70. for _, v in pairs(self._flyPresents) do
  71. v:Tick(dt)
  72. end
  73. if self._flyEnable and #self._flyPresents < self._count then
  74. if self._delayTime >= TIMER_INTERVAL then
  75. self._delayTime = 0
  76. local target = {dest = cc.p(self._data.hitX, self._data.hitY), id = (self._data.param and self._data.param ~= "") and self._data.param or nil}
  77. local present = skillPresentFly.new(self._data, self._config, self._flyRoot, target, self)
  78. table.insert(self._flyPresents, present)
  79. present:init()
  80. present:launch()
  81. else
  82. self._delayTime = self._delayTime + dt
  83. end
  84. end
  85. end
  86. return skillBehaviorDartle