shadowrush.lua 830 B

1234567891011121314151617181920212223
  1. local ShadowRush = extend(Ability)
  2. ShadowRush.ranges = {150, 225, 300}
  3. ShadowRush.cooldowns = {12, 8, 4}
  4. function ShadowRush:update()
  5. local level = self.unit:upgradeLevel('shadowrush')
  6. if self.timer == 0 and self.unit.target and math.abs(self.unit.target.x - self.unit.x) < self.ranges[level] then
  7. self:fire()
  8. self.timer = self.cooldowns[level]
  9. end
  10. end
  11. function ShadowRush:fire()
  12. local level = self.unit:upgradeLevel('shadowrush')
  13. self.unit.animation:set('dash')
  14. if self.unit.target and math.abs(self.unit.target.x - self.unit.x) < self.ranges[level] and math.abs(self.unit.target.x - self.unit.x) > 75 then
  15. self.unit.x = self.unit.target.x - (self.unit.target.width / 2 + self.unit.width / 2) * self:getUnitDirection()
  16. ctx.sound:play(data.media.sounds.xuju.shadowrush)
  17. end
  18. end
  19. return ShadowRush