源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

62 行
1.5 KiB

  1. GuideTaskLimitView = GuideTaskLimitView or BaseClass(BaseView)
  2. function GuideTaskLimitView:__init()
  3. self.base_file = "guide"
  4. self.layout_file = "GuideTaskLimitView"
  5. self.layer_name = "Top"
  6. self.close_mode = CloseMode.CloseDestroy
  7. self.destroy_imm = true
  8. self.load_callback = function ()
  9. self:LoadSuccess()
  10. self:InitEvent()
  11. end
  12. self.open_callback = function ()
  13. self.diff_time = 10
  14. GlobalEventSystem:Fire(EventName.STOP_AUTO_DO_TASK)
  15. self:StartTimer()
  16. end
  17. self.close_callback = function ()
  18. GlobalEventSystem:Fire(EventName.START_AUTO_DO_TASK)
  19. end
  20. self.destroy_callback = function ()
  21. self:Clear()
  22. end
  23. end
  24. function GuideTaskLimitView:Clear()
  25. self:StopTimer()
  26. end
  27. function GuideTaskLimitView:LoadSuccess()
  28. self.sureBtn = self:GetChild("sureBtn").gameObject
  29. self.label = self:GetChild("sureBtn/Text"):GetComponent("Text")
  30. end
  31. function GuideTaskLimitView:InitEvent()
  32. local function clickHandler(target)
  33. self:Close()
  34. end
  35. AddClickEvent(self.sureBtn, clickHandler)
  36. end
  37. function GuideTaskLimitView:StartTimer()
  38. local function onTimer()
  39. if self.diff_time < 0 then
  40. self:Close()
  41. else
  42. self.label.text = string.format("确定(%d)", self.diff_time)
  43. self.diff_time = self.diff_time - 1
  44. end
  45. end
  46. if not self.timer_id then
  47. self.timer_id = GlobalTimerQuest:AddPeriodQuest(onTimer,1,-1)
  48. end
  49. end
  50. function GuideTaskLimitView:StopTimer()
  51. self.label.text = ""
  52. if self.timer_id then
  53. GlobalTimerQuest:CancelQuest(self.timer_id)
  54. self.timer_id = nil
  55. end
  56. end