源战役客户端
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

223 satır
6.0 KiB

  1. EquipCollectTipView = EquipCollectTipView or BaseClass(BaseView)
  2. local EquipCollectTipView = EquipCollectTipView
  3. --[[
  4. EquipCollectTipView.TabData = {
  5. [1] = {name = "人物", level = MainRoleModel.TabOpenLevel[1]},
  6. }
  7. --]]
  8. function EquipCollectTipView:__init()
  9. self.base_file = "equipCollect"
  10. self.layout_file = "EquipCollectTipView"
  11. self.layer_name = "Top"
  12. self.destroy_imm = true
  13. self.use_background = false --全屏界面默认使用这个参数
  14. --self.hide_maincancas = true --全屏界面需要放开隐藏主UI
  15. self.change_scene_close = true
  16. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  17. self.need_show_money = false --是否要显示顶部的金钱栏
  18. self.model = EquipCollectModel:getInstance()
  19. self.hide_time = 2--关闭倒计时
  20. self.item_list = {}
  21. self.load_callback = function ()
  22. self:LoadSuccess()
  23. self:AddEvent()
  24. end
  25. self.open_callback = function ( )
  26. self:OpenSuccess()
  27. end
  28. self.switch_callback = function(index)
  29. self:SwitchTab(index)
  30. end
  31. self.destroy_callback = function ( )
  32. self:DestroySuccess()
  33. end
  34. end
  35. function EquipCollectTipView:Open(data)
  36. self.data = data
  37. BaseView.Open(self)
  38. end
  39. function EquipCollectTipView:ReOpen( data )
  40. self.data = data
  41. self:UpdateView()
  42. end
  43. function EquipCollectTipView:LoadSuccess()
  44. local nodes = {
  45. "item_con", "bg:raw", "title:img",
  46. }
  47. self:GetChildren(nodes)
  48. self.canvasGroup = self.gameObject:GetComponent("CanvasGroup")
  49. lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("equip_collect_tip_bg"), false)
  50. if AchieveModel:getInstance().tip_view_show then
  51. self.transform.anchoredPosition = Vector2(-3, 211)
  52. else
  53. self.transform.anchoredPosition = Vector2(-3, 61)
  54. end
  55. end
  56. function EquipCollectTipView:AddEvent()
  57. end
  58. function EquipCollectTipView:OpenSuccess()
  59. self:UpdateView()
  60. self:StartCloseTimer()
  61. self:OpenAnimation() -- 播放打开界面的动画
  62. end
  63. -- 播放打开界面的动画
  64. function EquipCollectTipView:OpenAnimation()
  65. self.canvasGroup.alpha = 0
  66. if self.alpha_anim_id then
  67. TweenLite.Stop(self.alpha_anim_id)
  68. self.alpha_anim_id = nil
  69. end
  70. self.alpha_anim_id = TweenLite.to(self, self.canvasGroup, TweenLite.UiAnimationType.ALPHA, 1, 0.2)
  71. end
  72. -- 关闭(隐藏)界面的动画
  73. function EquipCollectTipView:CloseAnimation()
  74. self.canvasGroup.alpha = 1
  75. if self.alpha_anim_id then
  76. TweenLite.Stop(self.alpha_anim_id)
  77. self.alpha_anim_id = nil
  78. end
  79. self.alpha_anim_id = TweenLite.to(self, self.canvasGroup,TweenLite.UiAnimationType.ALPHA, 0, 0.5)
  80. local pos_y = self.transform.anchoredPosition.y + 100
  81. if self.pos_id then
  82. TweenLite.Stop(self.pos_id)
  83. self.pos_id = nil
  84. end
  85. local function callback( )
  86. self:Close()
  87. end
  88. self.pos_id = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.ANCHORED_POSY, pos_y, 0.5, callback)
  89. end
  90. function EquipCollectTipView:CloseAnimation2( )
  91. self.canvasGroup.alpha = 1
  92. if self.alpha_anim_id then
  93. TweenLite.Stop(self.alpha_anim_id)
  94. self.alpha_anim_id = nil
  95. end
  96. self.alpha_anim_id = TweenLite.to(self, self.canvasGroup,TweenLite.UiAnimationType.ALPHA, 0, 0.5)
  97. local pos_y = self.transform.anchoredPosition.y + 100
  98. if self.pos_id then
  99. TweenLite.Stop(self.pos_id)
  100. self.pos_id = nil
  101. end
  102. local function callback( )
  103. self:Close()
  104. end
  105. self.pos_id = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.ANCHORED_POS, Vector2(-330,720), 0.5, callback)
  106. if self.scale_id then
  107. TweenLite.Stop(self.scale_id)
  108. self.scale_id = nil
  109. end
  110. local function callback( )
  111. self:Close()
  112. end
  113. self.scale_id = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.SCALE, Vector3(0.1,0.1,0.1), 0.5, callback)
  114. end
  115. function EquipCollectTipView:StartCloseTimer( )
  116. local end_time = self.hide_time + TimeUtil:getServerTime()
  117. local function hide_timer()
  118. local left_time = end_time - TimeUtil:getServerTime()
  119. if left_time < 0 then
  120. if self.is_full then
  121. self:CloseAnimation2()
  122. else
  123. self:CloseAnimation()
  124. end
  125. self:ClearHideTimer()
  126. end
  127. end
  128. hide_timer()
  129. if not self.hide_timer_id then
  130. self.hide_timer_id = GlobalTimerQuest:AddPeriodQuest(hide_timer, 0.1, -1)
  131. end
  132. end
  133. function EquipCollectTipView:UpdateView()
  134. local server_data = self.model:GetEquipCollectTipData(self.data.id)
  135. lua_resM:setImageSprite(self, self.title_img, "equipCollect_asset","equipCollect_name_font"..self.data.id)
  136. local count = 0
  137. local need_action_data = nil
  138. for i,v in ipairs(server_data) do
  139. if v.type_id > 0 then
  140. count = count + 1
  141. end
  142. if v.need_action then
  143. need_action_data = DeepCopy(v)
  144. need_action_data.index = i
  145. end
  146. end
  147. self.is_full = count == 7
  148. -- self.is_full = true
  149. local x_offset = 68
  150. for i=1,7 do
  151. local item = self.item_list[i]
  152. if not item then
  153. item = EquipCollectTipItem.New(self.item_con)
  154. item:SetPosition(x_offset*(i-1), 1)
  155. self.item_list[i] = item
  156. end
  157. item:SetData(server_data[i])
  158. end
  159. self:StartFlyInAction(need_action_data)--开始飞进来的动画
  160. end
  161. function EquipCollectTipView:StartFlyInAction( need_action_data )
  162. if not need_action_data or self.is_action then
  163. return
  164. end
  165. if not self.action_item then
  166. self.action_item = EquipCollectTipItem.New(self.item_con)
  167. need_action_data.need_action = false
  168. self.action_item:SetData(need_action_data)
  169. end
  170. self.action_item:StartAction(need_action_data)
  171. end
  172. function EquipCollectTipView:ClearHideTimer( )
  173. if self.hide_timer_id then
  174. GlobalTimerQuest:CancelQuest(self.hide_timer_id)
  175. self.hide_timer_id = nil
  176. end
  177. end
  178. function EquipCollectTipView:DestroySuccess( )
  179. self:ClearHideTimer()
  180. if self.delay_closeview_id then
  181. TimerQuest.CancelQuest(GlobalTimerQuest,self.delay_closeview_id)
  182. self.delay_closeview_id = nil
  183. end
  184. if self.alpha_anim_id then
  185. TweenLite.Stop(self.alpha_anim_id)
  186. self.alpha_anim_id = nil
  187. end
  188. if self.pos_id then
  189. TweenLite.Stop(self.pos_id)
  190. self.pos_id = nil
  191. end
  192. if self.scale_id then
  193. TweenLite.Stop(self.scale_id)
  194. self.scale_id = nil
  195. end
  196. for i,v in ipairs(self.item_list) do
  197. v:DeleteMe()
  198. v = nil
  199. end
  200. self.item_list = {}
  201. if self.action_item then
  202. self.action_item:DeleteMe()
  203. self.action_item = nil
  204. end
  205. end