源战役客户端
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

61 righe
2.0 KiB

4 settimane fa
  1. --[[@------------------------------------------------------------------
  2. : Tip的操作包
  3. : deadline
  4. ----------------------------------------------------------------------]]
  5. NowOperateJump = NowOperateJump or BaseClass(NowOperate)
  6. local NowOperateJump = NowOperateJump
  7. function NowOperateJump:__init(start_time, start_pos, end_pos, is_last_tip)
  8. self.type = OperateManager.OperateType.Move
  9. self.start_pos = start_pos
  10. self.end_pos = end_pos
  11. self.is_end = false
  12. self.move_end_handle = nil
  13. self.is_already_do_jump = false --是否已经执行移动操作
  14. end
  15. function NowOperateJump:__delete()
  16. if self.move_end_handle ~= nil then
  17. EventSystem.UnBind(GlobalEventSystem,self.move_end_handle)
  18. end
  19. if self.change_scene_handle then
  20. EventSystem.UnBind(GlobalEventSystem,self.change_scene_handle)
  21. end
  22. end
  23. function NowOperateJump:Init()
  24. --先检测能否立即移动再执行该操作
  25. self:DoJumpAction()
  26. return true
  27. end
  28. function NowOperateJump:DoJumpAction( )
  29. self.is_already_do_jump = true
  30. --监听主角移动结束
  31. local move_end_callback = function ( tip_count )
  32. self.is_end = true
  33. EventSystem.UnBind(GlobalEventSystem,self.move_end_handle)
  34. self.move_end_handle = nil
  35. end
  36. --切换场景的时候,也要结束当前操作包
  37. local change_scene_func = function()
  38. self.is_end = true
  39. EventSystem.UnBind(GlobalEventSystem,self.change_scene_handle)
  40. self.change_scene_handle = nil
  41. end
  42. -- self.move_end_handle = GlobalEventSystem:Bind(SceneEventType.MAIN_ROLE_JUMP_END, move_end_callback)
  43. self.change_scene_handle = EventSystem.Bind(GlobalEventSystem,SceneManager.START, change_scene_func)
  44. local target_p = co.Vector2(self.end_pos.x*SceneObj.LogicRealRatio.x,self.end_pos.y*SceneObj.LogicRealRatio.y)
  45. Scene.Instance:GetMainRole():DoJump(target_p, true)
  46. end
  47. function NowOperateJump:ExcuteImpl(elaspe_time)
  48. --如果还未执行移动操作,则在合适的时间执行该操作
  49. if not self.is_already_do_jump then
  50. self:DoJumpAction()
  51. end
  52. return self.is_end
  53. end