源战役客户端
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

95 строки
2.6 KiB

1 месяц назад
  1. StartTimeTip = StartTimeTip or BaseClass(BaseView)
  2. local StartTimeTip = StartTimeTip
  3. --[[
  4. 321
  5. 使
  6. local data = {
  7. time = time,--倒计时时间(目前只有3/2/1,多的数字要去加资源哦)
  8. call_back = function() --时间到期回调函数
  9. self.model:Fire(BeachConst.REQ_QUIT_SCENE)
  10. end,
  11. }
  12. GlobalEventSystem:Fire(EventName.OPEN_START_TIME_TIP,data)
  13. --]]
  14. function StartTimeTip:__init()
  15. self.base_file = "common"
  16. self.layout_file = "StartTimeTip"
  17. self.layer_name = "Main"
  18. self.destroy_imm = true
  19. self.change_scene_close = false
  20. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  21. self.need_show_money = false --是否要显示顶部的金钱栏
  22. self.change_scene_close = true
  23. -- self.is_set_zdepth = true
  24. self.click_bg_toClose = false
  25. ------------------------
  26. -- 一级全屏界面:
  27. self.hide_maincancas = false --隐藏主界面
  28. self.use_background = false --不一定显示遮罩
  29. ------------------------
  30. self.load_callback = function ()
  31. self:LoadSuccess()
  32. end
  33. self.open_callback = function ( )
  34. self:OpenSuccess()
  35. end
  36. self.close_win_callback = function ( )
  37. self:Close()
  38. end
  39. self.destroy_callback = function ( )
  40. self:DestroySuccess()
  41. end
  42. end
  43. function StartTimeTip:Open( data )
  44. self.data = data
  45. self.data.end_time = data.time + TimeUtil:getServerTime() --把时间段转为时间戳,兼容计时器帧率不稳定的问题
  46. BaseView.Open(self)
  47. end
  48. function StartTimeTip:LoadSuccess()
  49. local nodes = {
  50. "container/startTimeText:txt", "container:obj", "container/startTimeBg:img",
  51. }
  52. self:GetChildren(nodes)
  53. lua_resM:setOutsideImageSprite(self, self.startTimeBg_img, GameResPath.GetCommonImage("com_start_tip"),true)
  54. self:AddEvent()
  55. -------------------------
  56. SetSizeDelta(self.transform, ScreenWidth, ScreenHeight)
  57. SetAnchoredPositionY(self.container, -209)
  58. end
  59. function StartTimeTip:AddEvent()
  60. end
  61. function StartTimeTip:OpenSuccess()
  62. self:UpdateView()
  63. end
  64. function StartTimeTip:UpdateView()
  65. self.clock_time = self.data.end_time - TimeUtil:getServerTime()
  66. local call_back = self.data and self.data.call_back
  67. local function clockFun()
  68. self.startTimeText_txt.text = math.ceil(self.clock_time)
  69. self.clock_time = self.data.end_time - TimeUtil:getServerTime()
  70. if self.clock_time <= 0 then
  71. self:Close()
  72. if call_back then
  73. call_back()
  74. end
  75. end
  76. end
  77. -- clockFun()
  78. self.close_time_id = self.close_time_id or GlobalTimerQuest:AddPeriodQuest(clockFun, 0.3, -1)
  79. end
  80. function StartTimeTip:DestroySuccess( )
  81. if self.close_time_id then
  82. GlobalTimerQuest:CancelQuest(self.close_time_id)
  83. self.close_time_id = nil
  84. end
  85. end