源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

201 lines
6.6 KiB

  1. --通用兑换展示界面
  2. ComDialogueShowView = ComDialogueShowView or BaseClass(BaseView)
  3. local ComDialogueShowView = ComDialogueShowView
  4. ComDialogueShowView.Type = {
  5. DunNomal = 1,--副本进入
  6. DunWave = 2,--波数类型
  7. DunForever = 3,--副本进入永久类型
  8. }
  9. function ComDialogueShowView:__init()
  10. self.base_file = "uiComponent"
  11. self.layout_file = "ComDialogueShowView"
  12. self.layer_name = "Top"
  13. self.mask_open_sound = true
  14. self.mask_close_sound = true
  15. self.use_background = false
  16. self.destroy_imm = true
  17. self.change_scene_close = false
  18. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  19. self.need_show_money = false --是否要显示顶部的金钱栏
  20. self.model = MainUIModel:getInstance()
  21. self.width = 408--预制宽度
  22. self.origin_x = 0--起始X坐标
  23. self.delay_time = 5--默认时间
  24. self.tween_lite_list = {}
  25. self.load_callback = function ()
  26. self:LoadSuccess()
  27. self:AddEvent()
  28. end
  29. self.open_callback = function ( )
  30. self:OpenSuccess()
  31. end
  32. self.destroy_callback = function ( )
  33. self:DestroySuccess()
  34. end
  35. end
  36. function ComDialogueShowView:DestroySuccess()
  37. self:StopDialogueAction()
  38. end
  39. function ComDialogueShowView:LoadSuccess()
  40. local nodes = {
  41. "con/nameBg:img", "con/desc:tmp", "con/bg:img", "con:obj", "con/name:tmp", "con/headImg:img",
  42. }
  43. self:GetChildren(nodes)
  44. --创建时默认将alpha置为0隐藏
  45. self.con_obj:GetComponent("CanvasGroup").alpha = 0
  46. lua_resM:setImageSprite(self, self.nameBg_img, "comDialogue_asset", "com_dialogue_name_bg")
  47. lua_resM:setImageSprite(self, self.bg_img, "comDialogue_asset", "com_dialogue_bg")
  48. if self.need_refreshData then
  49. self:UpdateView( )
  50. end
  51. self.transform.anchoredPosition = Vector2(ClientConfig.iphone_x_offset_left, -121)
  52. end
  53. function ComDialogueShowView:AddEvent()
  54. -- local function onBtnClickHandler(target,x,y)
  55. -- if target == self.mask_bg_obj then--关闭
  56. -- self:Close()
  57. -- end
  58. -- end
  59. -- AddClickEvent(self.mask_bg_obj,onBtnClickHandler,1)
  60. local function onOrientationChange()
  61. self.transform.anchoredPosition = Vector2(ClientConfig.iphone_x_offset_left, -121)
  62. end
  63. self:BindEvent(GlobalEventSystem, EventName.ORIENTATION_DID_CHANGE, onOrientationChange)
  64. -- local data = {
  65. -- head_type = 1,
  66. -- desc = "当时我很机智,我说我不会游泳 我妈妈会游泳,再说你也会!",
  67. -- head_name = "赤骨光子",
  68. -- hide_time = 5,
  69. -- dalay_time = 3,
  70. -- is_task_type = false,--是否是任务配置类型 如果是要隐藏功能预告界面
  71. -- }
  72. local function onShowDialogueView(data)--展示对话界面
  73. if not self.is_loaded or not data or not data.head_type then return end
  74. data.desc = ChuanWenManager:getInstance():FormatColorTag2(data.desc)--这边要解析一下颜色
  75. self:StopDialogueAction()
  76. local function dalayFunc( ... )
  77. if data.is_task_type then
  78. GlobalEventSystem:Fire(EventName.HIDE_LEFT_MIDDLE_VIEW, true, MainUIModel.MAIN_MODE)
  79. end
  80. self:StartDialogueAction(data)
  81. end
  82. self.delay_timer_id = setTimeout(dalayFunc,data.dalay_time)
  83. end
  84. self:BindEvent(GlobalEventSystem, EventName.SHOW_COM_DIALOGUE_SHOW_VIEW, onShowDialogueView)
  85. local function stopDialogueFunc( ... )
  86. self:StopDialogueAction()
  87. end
  88. self:BindEvent(GlobalEventSystem, EventName.STOP_COM_DIALOGUE_SHOW_VIEW, onShowDialogueView)
  89. local function changeSceneViewFuc( ... )--切换场景就要隐藏
  90. self:StopDialogueAction()
  91. end
  92. self:BindEvent(GlobalEventSystem, SceneEventType.SCENE_CHANGED, changeSceneViewFuc)
  93. end
  94. --data.delay_time--关闭时间
  95. --data.title_res--标题资源
  96. --data.title_ab_name--标题资源ab包路径
  97. --data.award = {kind,type_id,goods_num,goods_vo}
  98. --data.col_num = 6 -- 每行展示的个数
  99. function ComDialogueShowView:Open( )
  100. BaseView.Open(self)
  101. end
  102. function ComDialogueShowView:OpenSuccess( )
  103. self:UpdateView()
  104. end
  105. function ComDialogueShowView:UpdateView( )
  106. if self.is_loaded then
  107. self.need_refreshData = false
  108. else
  109. self.need_refreshData = true
  110. return
  111. end
  112. if not self.data then return end
  113. end
  114. --开始对话展示
  115. function ComDialogueShowView:StartDialogueAction( data )
  116. lua_resM:setImageSprite(self, self.headImg_img, "comDialogue_asset", "com_dialogue_head_"..data.head_type, true)
  117. self.name_tmp.text = data.head_name
  118. self.desc_tmp.text = data.desc
  119. self:UpdateTime(data)
  120. local function anim_end_func( ... )
  121. end
  122. local pos = data.pos or Vector3(0,0,0)
  123. self.tween_lite_list[1] = TweenLite.to(self, self.con.transform, TweenLite.UiAnimationType.POS, pos, 0.3)
  124. self.tween_lite_list[2] = TweenLite.to(self, self.con, TweenLite.UiAnimationType.ALPHA_ALL, 1, 0.3,anim_end_func)
  125. -- 通知动画开始
  126. GlobalEventSystem:Fire(EventName.START_COM_DIALOGUE_SHOW_ANIM)
  127. self.model:SetDialogueActionFlag(true)
  128. end
  129. function ComDialogueShowView:HideDialogueAction( data )
  130. self.con_obj:GetComponent("CanvasGroup").alpha = 1
  131. SetAnchoredPosition(self.con,0,0)
  132. local function anim_end_func( ... )--动画执行完要吧功能预告展示回来
  133. self:StopDialogueAction(data)
  134. end
  135. local pos = Vector3(-self.width,0,0)
  136. self.tween_lite_list[3] = TweenLite.to(self, self.con.transform, TweenLite.UiAnimationType.POS, pos, 0.3,anim_end_func)
  137. self.tween_lite_list[4] = TweenLite.to(self, self.con, TweenLite.UiAnimationType.ALPHA_ALL, 0, 0.3,anim_end_func)
  138. end
  139. --停止对话展示
  140. function ComDialogueShowView:StopDialogueAction( data )
  141. if data and data.is_task_type then
  142. GlobalEventSystem:Fire(EventName.HIDE_LEFT_MIDDLE_VIEW, false, MainUIModel.MAIN_MODE)
  143. end
  144. -- 对话展示结束后通知绑定了这个事件的界面用于做其他的展示逻辑
  145. self.model:SetDialogueActionFlag(false)
  146. GlobalEventSystem:Fire(EventName.FINISHED_COM_DIALOGUE_SHOW_ANIM)
  147. self.con_obj:GetComponent("CanvasGroup").alpha = 0
  148. SetAnchoredPosition(self.con,-self.width,0)
  149. if self.timer_id then
  150. GlobalTimerQuest:CancelQuest(self.timer_id)
  151. self.timer_id = nil
  152. end
  153. if self.delay_timer_id then
  154. GlobalTimerQuest:CancelQuest(self.delay_timer_id)
  155. self.delay_timer_id = nil
  156. end
  157. for i,v in ipairs(self.tween_lite_list) do
  158. if v then
  159. TweenLite.Stop(v)
  160. v = nil
  161. end
  162. end
  163. end
  164. function ComDialogueShowView:UpdateTime( data )
  165. local time = data.hide_time or self.delay_time
  166. local function countDown()
  167. if self._use_delete_method then return end
  168. if not data then return end
  169. time = time - 1
  170. if time > 0 then
  171. else
  172. self:HideDialogueAction(data)
  173. end
  174. end
  175. countDown()
  176. if not self.timer_id then
  177. self.timer_id = GlobalTimerQuest:AddPeriodQuest(countDown,1)
  178. end
  179. end