teleport.lua 592 B

1234567891011121314151617181920212223242526272829
  1. local Teleport = extend(Ability)
  2. ----------------
  3. -- Data
  4. ----------------
  5. Teleport.cooldown = 15
  6. ----------------
  7. -- Behavior
  8. ----------------
  9. function Teleport:activate()
  10. self.unit.animation:on('event', function(event)
  11. if event.data.name == 'teleport' then
  12. self.unit.x = ctx.map.width - self.unit.x
  13. end
  14. end)
  15. end
  16. function Teleport:use()
  17. self.unit.animation:set('teleport')
  18. if self.unit.animation.state.name == 'teleport' then
  19. self.unit.casting = true
  20. self.timer = self.cooldown
  21. ctx.sound:play(data.media.sounds.vuju.teleport)
  22. end
  23. end
  24. return Teleport