源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

204 行
5.8 KiB

  1. StrengthView = StrengthView or BaseClass(BaseView)
  2. function StrengthView:__init()
  3. self.base_file = "strength"
  4. self.layout_file = "StrengthView"
  5. self.layer_name = "Activity"
  6. self.destroy_imm = false
  7. self.delay_delete_time = 1
  8. self.use_background = false
  9. self.hide_maincancas = false
  10. self.use_show_anim = true
  11. self.use_hide_anim = true
  12. self.item_list = {}
  13. self.open_guide_close = true
  14. self.model = StrengthModel:getInstance()
  15. self.change_scene_close = true
  16. self:AddPreLoadList("strength",{"StrengthItem"})
  17. self.load_callback = function()
  18. self:LoadSuccess()
  19. self:InitEvent()
  20. end
  21. self.open_callback = function()
  22. self:UpdateView()
  23. self:AutoCheckViewNotData()
  24. end
  25. self.close_callback = function()
  26. end
  27. self.destroy_callback = function()
  28. self:Remove()
  29. end
  30. end
  31. function StrengthView:Remove()
  32. for k,v in pairs(self.item_list) do
  33. v:DeleteMe()
  34. end
  35. self.item_list = {}
  36. self:ClearTimer()
  37. end
  38. function StrengthView:LoadSuccess()
  39. local nodes = {
  40. "close_btn:obj",
  41. }
  42. self:GetChildren(nodes)
  43. self.ScrollView,
  44. self.ScrollViewViewport,
  45. self.ScrollViewCon,
  46. self.InfoCon
  47. = GetChildTransforms(self.transform,
  48. {
  49. "InfoCon/ScrollView",
  50. "InfoCon/ScrollView/Viewport",
  51. "InfoCon/ScrollView/Viewport/Content",
  52. "InfoCon",
  53. })
  54. self.firstChargeBtn = self:GetChild("InfoCon/firstChargeBtn").gameObject
  55. self.img_sp_img = self:GetChild("InfoCon/firstChargeBtn/img_sp"):GetComponent("Image")
  56. SetAnchoredPosition(self.transform,(ScreenWidth / 2 - 460 - ClientConfig.iphone_x_offset_right), 230-ScreenHeight / 2 )
  57. SetAnchoredPosition(self.close_btn, - (ScreenWidth / 2 - 460 - ClientConfig.iphone_x_offset_right), -(230-ScreenHeight / 2 ))
  58. SetSizeDelta(self.close_btn, ScreenWidth * 1.5, ScreenHeight*1.5)
  59. end
  60. function StrengthView:InitEvent()
  61. local function onBtnClickHandler(target)
  62. if target == self.firstChargeBtn then
  63. local b,res,module_id,module_sub,module_name,sub_tab_id = self.model:GetOtherOption()
  64. if b then
  65. OpenFun.Open(module_id, module_sub, nil,sub_tab_id)
  66. end
  67. self:Close()
  68. elseif target == self.close_btn_obj then
  69. self:Close()
  70. end
  71. end
  72. AddClickEvent(self.close_btn_obj,onBtnClickHandler)
  73. AddClickEvent(self.firstChargeBtn,onBtnClickHandler)
  74. local function onGuideTrigger()
  75. self:AddToStageHandler()
  76. end
  77. self:BindEvent(GlobalEventSystem, EventName.TRIGGER_GUIDE_TYPE, onGuideTrigger)
  78. end
  79. function StrengthView:UpdateView( )
  80. local call_back = function( vo )
  81. self:ClickOperation(vo)
  82. end
  83. local list = self.model:GetStrengthList()
  84. local b,res,module_id,module_sub,module_name = self.model:GetOtherOption()
  85. if b then
  86. if #list <= 2 then
  87. self.firstChargeBtn.gameObject:SetActive(false)
  88. SetSizeDeltaY(self.ScrollView, 173)
  89. else
  90. lua_resM:setImageSprite(self,self.img_sp_img,"strength_asset",res)
  91. self.firstChargeBtn.gameObject:SetActive(true)
  92. SetSizeDeltaY(self.ScrollView, 110)
  93. end
  94. else
  95. self.firstChargeBtn.gameObject:SetActive(false)
  96. SetSizeDeltaY(self.ScrollView, 162)
  97. end
  98. --如果小于2条的时候,这首充跟着item滑动
  99. if #list > 0 and #list <= 2 then
  100. local b,res,module_id,module_sub,module_name,sub_tab_id = self.model:GetOtherOption()
  101. if b then
  102. table.insert(list, {name = module_name, winId = module_id, subId = module_sub, tabId = nil, sort_id=80, res_name = res, sub_tab_id = sub_tab_id})
  103. end
  104. end
  105. local h = 0
  106. for i,v in ipairs(list) do
  107. local item = self.item_list[i]
  108. if not item then
  109. item = StrengthItem.New(self.ScrollViewCon)
  110. self.item_list[i] = item
  111. end
  112. item:SetVisible(true)
  113. item:SetData(v, call_back)
  114. if v.winId == 159 and v.subId == 1 then
  115. item:SetAnchoredPosition(0, -h - 7)
  116. h = h + 55
  117. else
  118. item:SetAnchoredPosition(0, -(i - 1) * 54 )
  119. h = h + 54
  120. end
  121. end
  122. SetSizeDeltaY(self.ScrollViewCon, h)
  123. for i=#list+1, #self.item_list do
  124. self.item_list[i]:SetVisible(false)
  125. end
  126. self:AddToStageHandler()
  127. end
  128. function StrengthView:ClickOperation( vo )
  129. if vo.winId == 610 and vo.subId == 0 and vo.tabId == 1 then
  130. ExpDunModel:getInstance():Fire(ExpDunModel.CHECK_OPEN_HANGUP_RECEIVE_VIEW)
  131. elseif vo.winId == 610 and vo.subId == 0 and vo.tabId == 2 then
  132. ExpDunModel:getInstance():Fire(ExpDunModel.OPEN_QUICK_HANGUP_VIEW, true)
  133. elseif vo.winId == 210 then
  134. GlobalEventSystem:Fire(EventName.OPEN_SKILL_VIEW, vo.tabId, true)
  135. else
  136. OpenFun.Open(vo.winId, vo.subId, vo.tabId, vo.sub_tab_id)
  137. end
  138. self:Close()
  139. end
  140. -- 有时候界面会出现空白的情况 所以加一个判断机制 在打开界面的情况下 倒计时几秒后检查数据还有没有
  141. function StrengthView:AutoCheckViewNotData()
  142. self:ClearTimer()
  143. if self._use_delete_Method then return end
  144. local function DelayFunc()
  145. local bool = self.model:CanStrength()
  146. if not bool then
  147. self:Close()
  148. end
  149. end
  150. self.timer = setTimeout(DelayFunc, 5)
  151. end
  152. function StrengthView:ClearTimer()
  153. if self.timer then
  154. GlobalTimerQuest:CancelQuest(self.timer)
  155. self.timer = nil
  156. end
  157. end
  158. function StrengthView:AddToStageHandler()
  159. local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_SHOW_FIGHT_UP_TIPS,1)
  160. if not helpVo then return end
  161. local help_type = helpVo.help_type
  162. if help_type == HelpType.TYPE_SHOW_FIGHT_UP_TIPS then
  163. local step = helpVo.step
  164. local button = false
  165. if (help_type == HelpType.TYPE_SHOW_FIGHT_UP_TIPS and step == 1) then
  166. button = self.firstChargeBtn
  167. end
  168. if button then
  169. local function call_back()
  170. end
  171. GlobalEventSystem:Fire(EventName.OPEN_GUIDE_PROMPT_VIEW, button.transform, button.transform.parent.transform, call_back, helpVo, self.layout_file)
  172. end
  173. end
  174. end
  175. function StrengthView:Close()
  176. --完成引导
  177. local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_SHOW_FIGHT_UP_TIPS,1)
  178. if helpVo then
  179. GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP,helpVo)
  180. end
  181. BaseView.Close(self)
  182. end