源战役客户端
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

131 行
3.9 KiB

  1. ExitTimeTip = ExitTimeTip or BaseClass(BaseView)
  2. local ExitTimeTip = ExitTimeTip
  3. --[[
  4. 使
  5. local data = {
  6. time = time,--倒计时时间
  7. use_action = 15,--最后几秒使用闪烁
  8. -------------------------
  9. call_back = function() --时间到期回调函数
  10. self.model:Fire(BeachConst.REQ_QUIT_SCENE)
  11. end,
  12. exit_desc = "%s 自动退出",--不同退出提示
  13. time_str = "秒后",--需要放大的时间链接字符串<size=130%><#ffffff>10秒后</color></size>击败小怪解除
  14. }
  15. GlobalEventSystem:Fire(EventName.OPEN_EXIT_TIME_TIP,data)
  16. --]]
  17. function ExitTimeTip:__init()
  18. self.base_file = "common"
  19. self.layout_file = "ExitTimeTip"
  20. self.layer_name = "Main"
  21. self.destroy_imm = true
  22. self.change_scene_close = true
  23. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  24. self.need_show_money = false --是否要显示顶部的金钱栏
  25. -- self.is_set_zdepth = true
  26. self.click_bg_toClose = false
  27. ------------------------
  28. -- 一级全屏界面:
  29. self.hide_maincancas = false --隐藏主界面
  30. self.use_background = false --不一定显示遮罩
  31. ------------------------
  32. CommonController.Instance:Fire(EventName.CLOSE_SPECIALTIPVIEW)--防止重叠
  33. self.load_callback = function ()
  34. self:LoadSuccess()
  35. end
  36. self.open_callback = function ( )
  37. self:OpenSuccess()
  38. end
  39. self.close_win_callback = function ( )
  40. self:Close()
  41. end
  42. self.destroy_callback = function ( )
  43. self:DestroySuccess()
  44. end
  45. end
  46. function ExitTimeTip:Open( data )
  47. data.time = data.time or 10
  48. self.data = data
  49. self.data.end_time = data.time + TimeUtil:getServerTime() --把时间段转为时间戳,兼容计时器帧率不稳定的问题
  50. self.data.exit_desc = data.exit_desc or "自动退出"
  51. self.data.time_str = data.time_str or "秒后"
  52. BaseView.Open(self)
  53. end
  54. function ExitTimeTip:LoadSuccess()
  55. local nodes = {
  56. "container/exitTimeText:tmp", "container:obj", "container/exitTimeBg:raw",
  57. }
  58. self:GetChildren(nodes)
  59. lua_resM:setOutsideRawImage(self, self.exitTimeBg_raw, GameResPath.GetViewBigBg("special_tip_di_3"), false)
  60. self:AddEvent()
  61. -------------------------
  62. SetSizeDelta(self.transform, ScreenWidth, ScreenHeight)
  63. SetAnchoredPosition(self.transform, 0, 0)
  64. end
  65. function ExitTimeTip:AddEvent()
  66. end
  67. function ExitTimeTip:OpenSuccess()
  68. self:UpdateView()
  69. end
  70. function ExitTimeTip:UpdateView()
  71. self.clock_time = self.data.end_time - TimeUtil:getServerTime()
  72. local use_action = self.data and self.data.use_action or 0
  73. local call_back = self.data and self.data.call_back
  74. SetVisibleByRotate( self.container.transform, self.clock_time > 0 )
  75. -------------------------
  76. local function clockFun()
  77. self.clock_time = self.data.end_time - TimeUtil:getServerTime()
  78. if self.clock_time >= 0 then
  79. self.exitTimeText_tmp.text = string.format("<size=130%%><#ffffff>%s%s</color></size>%s",self.clock_time,self.data.time_str,self.data.exit_desc)
  80. -------------------------
  81. if (not self.is_action) and (self.clock_time <= use_action) then
  82. self:StartExitAction()
  83. end
  84. else
  85. if call_back then
  86. call_back()
  87. end
  88. self:Close()
  89. end
  90. end
  91. clockFun()
  92. self.close_time_id = self.close_time_id or GlobalTimerQuest:AddPeriodQuest(clockFun, 0.5, -1)
  93. end
  94. --开始退出按钮闪烁动画
  95. function ExitTimeTip:StartExitAction( )
  96. self.is_action = true
  97. if not self.container_canvas then
  98. self.container_canvas = self.container:GetComponent("CanvasGroup")
  99. end
  100. self.container_canvas.alpha = 0
  101. local function show_icon_func( percent )
  102. self.container_canvas.alpha = percent
  103. end
  104. local show_update = cc.CustomUpdate.New(0.5,show_icon_func)
  105. local function hide_icon_func( percent )
  106. self.container_canvas.alpha = 1 - percent
  107. end
  108. local hide_update = cc.CustomUpdate.New(0.5,hide_icon_func)
  109. local action = cc.Sequence.New(show_update,hide_update)
  110. self:AddAction(cc.RepeatForever.New(action), self.container)
  111. end
  112. function ExitTimeTip:DestroySuccess( )
  113. if self.close_time_id then
  114. GlobalTimerQuest:CancelQuest(self.close_time_id)
  115. self.close_time_id = nil
  116. end
  117. end