源战役客户端
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.

222 line
6.4 KiB

  1. EquipCollectSuitTipView = EquipCollectSuitTipView or BaseClass(BaseView)
  2. local EquipCollectSuitTipView = EquipCollectSuitTipView
  3. --[[
  4. EquipCollectSuitTipView.TabData = {
  5. [1] = {name = "人物", level = MainRoleModel.TabOpenLevel[1]},
  6. }
  7. --]]
  8. local table_insert = table.insert
  9. function EquipCollectSuitTipView:__init()
  10. self.base_file = "equipCollect"
  11. self.layout_file = "EquipCollectSuitTipView"
  12. self.layer_name = "UI"
  13. self.destroy_imm = true
  14. self.use_background = true --全屏界面默认使用这个参数
  15. self.close_fog = true
  16. --self.hide_maincancas = true --全屏界面需要放开隐藏主UI
  17. self.change_scene_close = true
  18. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  19. self.need_show_money = false --是否要显示顶部的金钱栏
  20. self.item_list = {}
  21. self.tween_list = {}
  22. self.timer_list = {}
  23. self.close_time = 10
  24. self.model = EquipCollectModel:getInstance()
  25. self.item_posy = {
  26. [1] = -415,
  27. [2] = -194,
  28. [3] = -391,
  29. [4] = -194,
  30. [5] = -299,
  31. [6] = -391,
  32. [7] = -299,
  33. }
  34. self.load_callback = function ()
  35. self:LoadSuccess()
  36. self:AddEvent()
  37. end
  38. self.open_callback = function ( )
  39. self:OpenSuccess()
  40. end
  41. self.switch_callback = function(index)
  42. self:SwitchTab(index)
  43. end
  44. self.destroy_callback = function ( )
  45. self:DestroySuccess()
  46. end
  47. end
  48. function EquipCollectSuitTipView:Open(data)
  49. self.data = data
  50. BaseView.Open(self)
  51. end
  52. function EquipCollectSuitTipView:LoadSuccess()
  53. local nodes = {
  54. "item2", "item1", "item5", "item6", "bg:raw", "btn/btn_text:tmp", "btn:obj", "item7", "item3", "role_con", "item4",
  55. "time_text:tmp", "color_image:img",
  56. }
  57. self:GetChildren(nodes)
  58. lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("equipcollect_suit_tip_bg"),false)
  59. local function bg_back_func( ... )
  60. if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then
  61. self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend"))
  62. end
  63. self:MoveUIToBack(self.bg_raw)
  64. end
  65. if self.background_wnd then
  66. bg_back_func()
  67. else
  68. self.bg_back_func = bg_back_func
  69. end
  70. end
  71. function EquipCollectSuitTipView:AddEvent()
  72. local function on_click( )
  73. self:Close()
  74. self.model:Fire(EquipCollectConst.OPEN_EC_MAIN_VIEW, true, EquipCollectConst.TAB_ID.COLLECT, self.data.id, self.sub_id, self.sub_id)
  75. end
  76. AddClickEvent(self.btn_obj, on_click)
  77. end
  78. function EquipCollectSuitTipView:OpenSuccess()
  79. self:UpdateView()
  80. end
  81. --图片上下移动
  82. function EquipCollectSuitTipView:ArrowAnimation(index,time)
  83. if index then
  84. local call_fun = function ()
  85. local function onCompleted()
  86. self:ArrowAnimation(index, 0.01)
  87. end
  88. table.insert(self.tween_list, TweenLite.to(self, self["item"..index].transform,TweenLite.UiAnimationType.ANCHORED_POSY,self.item_posy[index] + 5,1.2,onCompleted))
  89. end
  90. local onDelay = function( )
  91. table.insert(self.tween_list, TweenLite.to(self, self["item"..index].transform,TweenLite.UiAnimationType.ANCHORED_POSY,self.item_posy[index] - 25,1.2,call_fun))
  92. end
  93. table.insert(self.timer_list, setTimeout(onDelay, 0.01))
  94. else
  95. for i=1,7 do
  96. time = 0.05 * i
  97. local call_fun = function ()
  98. local function onCompleted()
  99. self:ArrowAnimation(i, time)
  100. end
  101. table.insert(self.tween_list, TweenLite.to(self, self["item"..i].transform,TweenLite.UiAnimationType.ANCHORED_POSY,self.item_posy[i] + 5,1.2,onCompleted))
  102. end
  103. local onDelay = function( )
  104. table.insert(self.tween_list, TweenLite.to(self, self["item"..i].transform,TweenLite.UiAnimationType.ANCHORED_POSY,self.item_posy[i] - 25,1.2,call_fun))
  105. end
  106. table.insert(self.timer_list, setTimeout(onDelay, time))
  107. end
  108. end
  109. end
  110. --停止动画
  111. function EquipCollectSuitTipView:StopAnim()
  112. for i,v in ipairs(self.tween_list) do
  113. TweenLite.Stop(v)
  114. end
  115. self.tween_list = {}
  116. for i,v in ipairs(self.timer_list) do
  117. GlobalTimerQuest:CancelQuest(v)
  118. end
  119. self.timer_list = {}
  120. end
  121. function EquipCollectSuitTipView:UpdateView()
  122. local server_data = self.model:GetEquipCollectInfo(self.data.id)
  123. local bool = false
  124. --构造一个7个装备的数据
  125. local data = {}
  126. local temp_server_data = {}
  127. for i=1,7 do
  128. data[i] = {
  129. type_id = 0,
  130. pos_id = i,
  131. }
  132. end
  133. for i,v in pairsByKeys(server_data) do
  134. if TableSize(v) == 7 then--满足7件
  135. bool = bool or not self.model:CheckIsAllEquipCollected(self.data.id, i)--并且没领奖励
  136. temp_server_data = bool and v or temp_server_data
  137. self.sub_id = bool and i or self.sub_id
  138. end
  139. end
  140. for i,v in ipairs(temp_server_data) do
  141. data[i].type_id = v
  142. end
  143. local str = string.format("equipcollect_tip%s%s", self.data.id, self.sub_id or self.data.sub_id)
  144. lua_resM:setImageSprite(self, self.color_image_img, "equipCollectOut_asset", str, false)
  145. for i,v in ipairs(data) do
  146. local item = self.item_list[i]
  147. if not item then
  148. item = EquipCollectTipItem.New(self["item"..i])
  149. self.item_list[i] = item
  150. end
  151. item:SetData(v, "suit_view")
  152. item:SetPosition(-14, 0)
  153. end
  154. self:UpdateModel()
  155. self.model:CleanEquipCollectNeedShowTipData()
  156. self:ArrowAnimation()
  157. self:StartCloseTimer()
  158. end
  159. function EquipCollectSuitTipView:SwitchTab( index )
  160. end
  161. function EquipCollectSuitTipView:StartCloseTimer( )
  162. local end_time = self.close_time + TimeUtil:getServerTime()
  163. local function hide_timer()
  164. local left_time = end_time - TimeUtil:getServerTime()
  165. if left_time <= 0 then
  166. self:Close()
  167. self.model:Fire(EquipCollectConst.OPEN_EC_MAIN_VIEW, true, EquipCollectConst.TAB_ID.COLLECT, self.data.id, self.sub_id, self.sub_id)
  168. end
  169. self.time_text_tmp.text = string.format("%s 秒后自动关闭页面", HtmlColorTxt(left_time, ColorUtil.GREEN_DARK))
  170. end
  171. hide_timer()
  172. if not self.hide_timer_id then
  173. self.hide_timer_id = GlobalTimerQuest:AddPeriodQuest(hide_timer, 0.1, -1)
  174. end
  175. end
  176. function EquipCollectSuitTipView:ClearHideTimer( )
  177. if self.hide_timer_id then
  178. GlobalTimerQuest:CancelQuest(self.hide_timer_id)
  179. self.hide_timer_id = nil
  180. end
  181. end
  182. function EquipCollectSuitTipView:DestroySuccess( )
  183. for i,v in ipairs(self.item_list) do
  184. v:DeleteMe()
  185. v = nil
  186. end
  187. self.item_list = {}
  188. self:StopAnim()
  189. self:ClearHideTimer()
  190. end
  191. function EquipCollectSuitTipView:UpdateModel( )
  192. local res_data = {
  193. father_node = self,
  194. transform = self.role_con,
  195. fashion_type = FuncOpenModel.TypeId.Clothes,
  196. scale = 200,
  197. ui_model_type = UIModelCommon.ModelType.BackModel,
  198. layer_name = self.layer_name,
  199. position = Vector2(0, 60+(ScreenHeight-720)/2),
  200. }
  201. FuncOpenModel:getInstance():SetModelRes(res_data)
  202. end
  203. function EquipCollectSuitTipView:ReOpen( data )
  204. self.data = data
  205. self:UpdateView()
  206. end