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

223 lines
8.8 KiB

  1. EquipCollectRightItem = EquipCollectRightItem or BaseClass(BaseItem)
  2. local EquipCollectRightItem = EquipCollectRightItem
  3. function EquipCollectRightItem:__init()
  4. self.base_file = "equipCollect"
  5. self.layout_file = "EquipCollectRightItem"
  6. self.model = EquipCollectModel:GetInstance()
  7. self.equip_item_list = {}
  8. self.pos = false
  9. self.pos_map_list = {
  10. [1] = EquipModel.EquipType.Weapon,
  11. [2] = EquipModel.EquipType.Head,
  12. [3] = EquipModel.EquipType.Body,
  13. [4] = EquipModel.EquipType.Shoulder,
  14. [5] = EquipModel.EquipType.Hand,
  15. [6] = EquipModel.EquipType.Leg,
  16. [7] = EquipModel.EquipType.Shoes,
  17. }
  18. self:Load()
  19. end
  20. function EquipCollectRightItem:Load_callback()
  21. self.nodes = {
  22. "icon_image:img:obj", "btn/btn_text:tmp", "bg:img", "name_text:tmp", "finishi_image:obj", "item_con", "btn:obj:img", "btn/btn_red:obj",
  23. }
  24. self:GetChildren(self.nodes)
  25. self:AddEvents()
  26. if self.need_refreshData then
  27. self:UpdateView()
  28. end
  29. self:AddToStageHandler()
  30. end
  31. function EquipCollectRightItem:AddEvents( )
  32. local function on_click( )
  33. if self.data and self.data[1] then
  34. self.model:Fire(EquipCollectConst.CLICK_EQUIP_COLLECT_ITEM, self.data[1].id, self.data[1].sub_id)
  35. end
  36. -------------------------
  37. if self.can_click then
  38. self.model:Fire(EquipCollectConst.REQUEST_SCMD_EVENT,15220, self.data[1].id, self.data[1].sub_id)
  39. else
  40. if self.data[1].id == 1 and self.data[1].sub_id == 1 then--第一套装备领取的时候关界面 强制做主线
  41. self.model:Fire(EquipCollectConst.OPEN_EC_MAIN_VIEW, false)
  42. GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK) --启动自动任务
  43. else
  44. local key = self.click_jump.pos .. "@" .. self.click_jump.id .. "@" .. self.click_jump.pos
  45. local cfg = Config.Equipmentempty[key]
  46. if cfg then
  47. BagModel:getInstance():Fire(BagModel.EQUIP_ITEM_GET_WAY_TIPS, cfg,0,0,"equipCollect")
  48. else
  49. print(">>>>>ec unfinfd config Equipmentempty ", self.pos_type, self.series )
  50. end
  51. end
  52. -- local type_id = self.model:GetEquipCollectEquipId(self.click_jump.id, self.click_jump.sub_id,self.click_jump.pos)
  53. -- UIToolTipMgr:getInstance():AppendEquipTips(type_id, x, y, nil, nil, nil, nil, nil, nil, true)
  54. end
  55. end
  56. AddClickEvent(self.btn_obj, on_click)
  57. local function onGuideTrigger()
  58. self:AddToStageHandler()
  59. end
  60. self:BindEvent(GlobalEventSystem, EventName.TRIGGER_GUIDE_TYPE, onGuideTrigger)
  61. local function CLICK_EQUIP_COLLECT_ITEM( id,sub_id )
  62. self.model.mask_lead_effect[sub_id] = true--点击之后就去掉特效
  63. if self.data and self.data[1] then
  64. if self.data[1].id == id and self.data[1].sub_id == sub_id then
  65. self:ClearUIEffect(self.bg.transform)
  66. self.showing_effect = false
  67. end
  68. end
  69. end
  70. self:BindEvent(self.model, EquipCollectConst.CLICK_EQUIP_COLLECT_ITEM, CLICK_EQUIP_COLLECT_ITEM)
  71. end
  72. function EquipCollectRightItem:UpdateView( )
  73. local server_data = self.model:GetEquipCollectInfo(self.data[1].id, self.data[1].sub_id)
  74. local is_all_collect = self.model:CheckIsAllEquipCollected(self.data[1].id, self.data[1].sub_id)
  75. self.btn_obj:SetActive(not is_all_collect)
  76. self.finishi_image_obj:SetActive(is_all_collect)
  77. lua_resM:setImageSprite(self, self.bg_img, "equipCollectOut_asset", "equipcollect_color_bg"..self.data[1].sub_id, true)
  78. local str = "收集 %s 套装7件 (%s/7)"
  79. local name = self.model:GetEquipCollectSubTypeName(self.data[1].id, self.data[1].sub_id)
  80. local progress = self.model:GetEquipCollectProgress(self.data[1].id, self.data[1].sub_id)
  81. local cur_active_num = 0
  82. if TableSize(progress) > 0 then
  83. cur_active_num = progress.can_active
  84. end
  85. if cur_active_num == 7 then-- 可以点按钮
  86. lua_resM:setImageSprite(self, self.btn_img, "alphaCommon_asset", "tyui_btn_2")
  87. SetTMPSharedMaterial(self.btn_text_tmp,ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkOrangeBtn)
  88. self.can_click = true
  89. self.click_jump = nil
  90. self.btn_text_tmp.text = "领取"
  91. else
  92. lua_resM:setImageSprite(self, self.btn_img, "alphaCommon_asset", "tyui_btn_1")
  93. SetTMPSharedMaterial(self.btn_text_tmp,ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkBlueBtn)
  94. self.can_click = false
  95. self.btn_text_tmp.text = "获取装备"
  96. self.click_jump = nil
  97. end
  98. self.name_text_tmp.text = string.format(str, HtmlColorTxt(name, ColorUtil.YELLOW_DARK), HtmlColorTxt(cur_active_num, cur_active_num == 7 and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK ))
  99. self.btn_red_obj:SetActive(self.model:IsEquipCollectNeedRedById(self.data[1].id, self.data[1].sub_id))
  100. local award = stringtotable(self.model:GetEqipCollectAward(self.data[1].id, self.data[1].sub_id))
  101. if TableSize(award) > 0 then
  102. local designation_id = DesignationModel:GetInstance():GetDesignationIdByGoodsId(award[1][2])
  103. local cfg = Config.Dsgt
  104. cc.ActionManager:getInstance():removeAllActionsFromTarget(self.icon_image)
  105. if cfg[designation_id].type == 1 then--文字称号(文字称号也用图片了)
  106. self.icon_image_obj:SetActive(true)
  107. lua_resM:setOutsideImageSprite(self, self.icon_image_img, GameResPath.GetDesignImage(cfg[designation_id].id), true)
  108. elseif cfg[designation_id].type == 2 then--图片称号
  109. self.icon_image_obj:SetActive(true)
  110. lua_resM:setOutsideImageSprite(self, self.icon_image_img, GameResPath.GetDesignImage(cfg[designation_id].id), true)
  111. elseif cfg[designation_id].type == 3 then--特效称号
  112. if not self.dynamic_image_obj then
  113. self.dynamic_image_obj = UiFactory.createChild(self.icon_image, UIType.Image, "dynamic_image")
  114. self.dynamic_image_img = self.dynamic_image_obj:GetComponent("Image")
  115. self.dynamic_image = self.dynamic_image_obj.transform
  116. SetAnchoredPosition(self.dynamic_image,0,0)
  117. else
  118. self.dynamic_image_obj:SetActive(true)
  119. end
  120. SetSizeDelta(self.icon_image, 210*0.5,90*0.5)
  121. self.icon_image_obj:SetActive(true)
  122. local data = DesignationModel:GetInstance():GetDynamicDesignationCFG(designation_id)
  123. local res = Split(data[1].res,"_")--分割出来配置 然后取文字
  124. local font_res = res[1] or ""
  125. lua_resM:setImageSprite(self, self.dynamic_image_img, data[1].ab, font_res.."_font", true)
  126. SetSizeDelta(self.dynamic_image, 210*0.5,90*0.5)
  127. self.icon_image_obj:SetActive(true)
  128. local action = cc.Animation.New(data,0.15)
  129. cc.ActionManager:getInstance():addAction(cc.RepeatForever.New(action),self.icon_image.transform)
  130. end
  131. end
  132. local x_offset = 78
  133. for i=1,7 do
  134. local item = self.equip_item_list[i]
  135. if not item then
  136. item = EquipCollectEquipItem.New(self.item_con)
  137. item:SetPosition(x_offset*(i-1) - 16, 10)
  138. self.equip_item_list[i] = item
  139. end
  140. if not self.can_click and not self.click_jump then
  141. self.click_jump = server_data[self.pos_map_list[i]] and self.click_jump or self.data[self.pos_map_list[i]]
  142. end
  143. item:SetData(self.data[self.pos_map_list[i]], index, self.pos_map_list[i], server_data[self.pos_map_list[i]], "equip_collect_base_view")
  144. end
  145. if self.time_delay_effect then
  146. GlobalTimerQuest:CancelQuest(self.time_delay_effect)
  147. self.time_delay_effect = nil
  148. end
  149. if (self.show_first_effect == self.data[1].sub_id) and (not self.model.mask_lead_effect[self.data[1].sub_id]) then
  150. if not self.showing_effect then
  151. local function delay( )
  152. self.showing_effect = true
  153. self:AddUIEffect("ui_jujiaodianji", self.bg.transform, "Activity", Vector3(268,-23,0), 1, true)
  154. end
  155. self.time_delay_effect = setTimeout(delay,0.3)
  156. end
  157. else
  158. self.showing_effect = false
  159. self:ClearUIEffect(self.bg.transform)
  160. end
  161. end
  162. function EquipCollectRightItem:SetData( data,_,_,pos,show_first_effect )
  163. self.data = data
  164. self.pos = pos
  165. self.show_first_effect = show_first_effect
  166. if self.is_loaded then
  167. self.need_refreshData = false
  168. self:UpdateView()
  169. else
  170. self.need_refreshData = true
  171. end
  172. end
  173. function EquipCollectRightItem:__delete( )
  174. for i,v in ipairs(self.equip_item_list) do
  175. v:DeleteMe()
  176. v = nil
  177. end
  178. self.equip_item_list = {}
  179. cc.ActionManager:getInstance():removeAllActionsFromTarget(self.icon_image)
  180. if self.bg then
  181. self:ClearUIEffect(self.bg.transform)
  182. end
  183. if self.time_delay_effect then
  184. GlobalTimerQuest:CancelQuest(self.time_delay_effect)
  185. self.time_delay_effect = nil
  186. end
  187. end
  188. function EquipCollectRightItem:AddToStageHandler()
  189. if self.pos ~= 1 then return end
  190. local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_SUIT_COLLECT,3)
  191. if not helpVo then return end
  192. local help_type = helpVo.help_type
  193. if (help_type == HelpType.TYPE_SUIT_COLLECT ) then
  194. local step = helpVo.step
  195. local button = false
  196. if (help_type == HelpType.TYPE_SUIT_COLLECT and step == 3 ) then
  197. button = self.btn_obj
  198. end
  199. if button then
  200. local function call_back()
  201. end
  202. GlobalEventSystem:Fire(EventName.OPEN_GUIDE_PROMPT_VIEW, button.transform, button.transform.parent.transform, call_back, helpVo, self.layout_file)
  203. end
  204. else
  205. GlobalEventSystem:Fire(EventName.CLOSE_GUIDE_PROMPT_VIEW)
  206. end
  207. end