源战役客户端
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

292 righe
9.1 KiB

  1. CommonHuntResultView2 = CommonHuntResultView2 or BaseClass(BaseView)
  2. local CommonHuntResultView2 = CommonHuntResultView2
  3. function CommonHuntResultView2:__init()
  4. self.base_file = "common"
  5. self.layout_file = "CommonHuntResultView2"
  6. self.layer_name = "Activity"
  7. self.is_set_zdepth = true
  8. self.click_bg_toClose = false
  9. self.use_background = true
  10. self.change_scene_close = true
  11. self.reward_item_list = {}
  12. -- self.loop_mgr = LoopScrowViewMgr.New()
  13. self.column_num = 5 --一行多少个图标
  14. self.show_count = 10
  15. self.init_event = {}
  16. self.use_local_view = true
  17. self.load_callback = function ()
  18. self:LoadSuccess()
  19. self:InitEvent()
  20. end
  21. self.open_callback = function ()
  22. self:SetData()
  23. end
  24. self.close_callback = function ()
  25. end
  26. self.destroy_callback = function ()
  27. self:Remove()
  28. end
  29. end
  30. function CommonHuntResultView2:LoadSuccess()
  31. self.mask_btn,
  32. self.score_obj
  33. = GetChildGameObjects(self.transform, {
  34. "maskBtn",
  35. "parentCon/get_score"
  36. })
  37. self.mask_btn.transform.sizeDelta = Vector2(ScreenWidth, ScreenHeight)
  38. self.score_num = self:GetChild("parentCon/get_score/text"):GetComponent("Text")
  39. self.rune_goods_panel_list = {}
  40. self.huntBtn_list = {}
  41. self.huntBtn_dot_list = {}
  42. self.consumable_image_list = {}
  43. self.consumable_text_list = {}
  44. self.huntItem_list = {}
  45. self.huntBtn_text_list = {}
  46. self.huntBtn_image_list = {}
  47. self.draw_btn_iamge_list = {}
  48. for i = 1, 2 do
  49. self.huntItem_list[i] = self:GetChild("parentCon/hunt/hunt_"..i)
  50. self.huntBtn_list[i] = self:GetChild("parentCon/hunt/hunt_"..i.."/btn").gameObject
  51. self.huntBtn_dot_list[i] = self:GetChild("parentCon/hunt/hunt_"..i.."/btn/red_dot").gameObject
  52. self.consumable_image_list[i] = self:GetChild("parentCon/hunt/hunt_"..i.."/consumable"):GetComponent("Image")
  53. self.consumable_text_list[i] = self:GetChild("parentCon/hunt/hunt_"..i.."/consumable/text"):GetComponent("Text")
  54. self.huntBtn_text_list[i] = self:GetChild("parentCon/hunt/hunt_"..i.."/btn/Text"):GetComponent("Text")
  55. self.huntBtn_image_list[i] = self:GetChild("parentCon/hunt/hunt_"..i.."/image"):GetComponent("Image")
  56. self.draw_btn_iamge_list[i] = self:GetChild("parentCon/hunt/hunt_"..i.."/btn"):GetComponent("Image")
  57. end
  58. self.scroll,
  59. self.panel,
  60. self.parent,
  61. self.get_rune,
  62. self.effect,
  63. self.parentCon,
  64. self.effect1
  65. = GetChildTransforms(self.transform,
  66. {
  67. "parentCon/ScrollView",
  68. "parentCon/ScrollView/Viewport/panel",
  69. "parentCon/con/parent",
  70. "parentCon/get_rune",
  71. "parentCon/effect",
  72. "parentCon",
  73. "effect1",
  74. })
  75. self.scroll.gameObject:SetActive(false)
  76. self.get_rune.gameObject:SetActive(false)
  77. self:AddUIEffect("ui_lwmb_boom",self.effect1, self.layer_name, nil, 1, false, nil, nil, nil)
  78. self.bg,
  79. self.bg1,
  80. self.icon
  81. = GetChildImages(self.transform,
  82. {
  83. "parentCon/bg1",
  84. "parentCon/bg1/image",
  85. "parentCon/get_score/icon",
  86. })
  87. lua_resM:setOutsideImageSprite(self, self.bg, GameResPath.GetCommonImage("jsui_bg"), false)
  88. lua_resM:setOutsideImageSprite(self, self.bg1, GameResPath.GetCommonImage("jsui_bg"), false)
  89. end
  90. function CommonHuntResultView2:InitEvent()
  91. local function OnItemClick(target)
  92. for i, v in ipairs(self.huntBtn_list) do
  93. if target == v then
  94. local callfunc = self["btn"..i.."_call"]
  95. if callfunc then
  96. callfunc()
  97. end
  98. end
  99. self:Close()
  100. end
  101. end
  102. for i, v in ipairs(self.huntBtn_list) do
  103. AddClickEvent(v, OnItemClick)
  104. end
  105. local function OnBtnClick(target)
  106. if target == self.mask_btn then
  107. self:Close()
  108. if self.maskBtn_call then
  109. self.maskBtn_call()
  110. end
  111. end
  112. end
  113. AddClickEvent(self.mask_btn, OnBtnClick)
  114. end
  115. --[[
  116. close_call
  117. btn1_call btn2_call
  118. maskBtn_call
  119. animEnd_call
  120. parm_list
  121. --]]
  122. function CommonHuntResultView2:Open(target_list, close_call, btn1_call, btn2_call, maskBtn_call, animEnd_call, parm_list)
  123. -- self.type = type
  124. self.target_list = target_list or {}
  125. self.close_call = close_call
  126. self.btn1_call = btn1_call
  127. self.btn2_call = btn2_call
  128. self.maskBtn_call = maskBtn_call
  129. self.animEnd_call = animEnd_call
  130. self.parm_list = parm_list
  131. BaseView.Open(self)
  132. end
  133. function CommonHuntResultView2:Close()
  134. if self.close_call then
  135. self.close_call()
  136. end
  137. BaseView.Close(self)
  138. end
  139. function CommonHuntResultView2:SetData()
  140. self:SetReward()
  141. self:AnalysicParmlist()
  142. local delay = function ()
  143. self:AddUIEffect("ui_accounts_gongxihuode",self.effect, self.layer_name, nil, 1, false,nil,nil,nil)
  144. self:ClearTweenAnim()
  145. for i,v in ipairs(self.reward_item_list) do
  146. v:SetVisible(true)
  147. end
  148. local function callback()
  149. if self.animEnd_call then
  150. self.animEnd_call()
  151. end
  152. end
  153. self.tween_id_1 = TweenLite.to(self, self.parentCon, TweenLite.UiAnimationType.SCALE, Vector3(1,1,1), 0.2,callback)
  154. end
  155. local evet = GlobalTimerQuest:AddPeriodQuest(delay,0.2,1)
  156. table.insert(self.init_event,evet)
  157. end
  158. function CommonHuntResultView2:SetBtnView(btn1_txt, btn2_txt)
  159. self.huntBtn_text_list[1].text = btn1_txt and btn1_txt or ""
  160. self.huntBtn_text_list[2].text = btn2_txt and btn2_txt or ""
  161. end
  162. function CommonHuntResultView2:SetGradeShow(get_score_title, get_score_icon_ab, get_score_icon_res, score)
  163. self.score_obj.transform:GetComponent("Text").text = get_score_title and get_score_title or ""
  164. self.score_num.text = score and score or ""
  165. if get_score_icon_ab and get_score_icon_res then
  166. lua_resM:setImageSprite(self, self.icon, get_score_icon_ab, get_score_icon_res)
  167. end
  168. end
  169. function CommonHuntResultView2:SetCostShow(cost_icon_ab, cost_icon_res, btn1_cost_txt, btn2_cost_txt)
  170. if cost_icon_ab and cost_icon_res then
  171. self.huntBtn_image_list[1].gameObject:SetActive(true)
  172. self.huntBtn_image_list[2].gameObject:SetActive(true)
  173. for i = 1, 2 do
  174. lua_resM:setImageSprite(self, self.consumable_image_list[i], cost_icon_ab, cost_icon_res)
  175. end
  176. end
  177. self.consumable_text_list[1].text = btn1_cost_txt and btn1_cost_txt or ""
  178. self.consumable_text_list[2].text = btn2_cost_txt and btn2_cost_txt or ""
  179. end
  180. --外部资源的
  181. function CommonHuntResultView2:SetCostShowOutSide(res_path,icon_size, btn1_cost_txt, btn2_cost_txt)
  182. self.huntBtn_image_list[1].gameObject:SetActive(true)
  183. self.huntBtn_image_list[2].gameObject:SetActive(true)
  184. icon_size = icon_size or co.TableXY(35,38)
  185. for i = 1, 2 do
  186. self.consumable_image_list[i].transform.sizeDelta = Vector2(icon_size.x,icon_size.y)
  187. lua_resM:setOutsideImageSprite(self,self.consumable_image_list[i],res_path,false)
  188. end
  189. self.consumable_text_list[1].text = btn1_cost_txt and btn1_cost_txt or ""
  190. self.consumable_text_list[2].text = btn2_cost_txt and btn2_cost_txt or ""
  191. end
  192. function CommonHuntResultView2:SetReward()
  193. -- if #self.target_list > 5 then
  194. -- self.parent:GetComponent("ContentSizeFitter").enabled = true
  195. -- end
  196. local create_count = math.min(self.show_count, #self.target_list)
  197. for k = 1, create_count do
  198. local item = self.reward_item_list[k]
  199. if item == nil then
  200. item = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.parent, nil, self.layer_name)
  201. local id = self.target_list[k].type_id or self.target_list[k].typeId
  202. local count = self.target_list[k].goods_num or self.target_list[k].count
  203. local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(id)
  204. local spe_color
  205. if basic and basic.color == 3 then
  206. spe_color = 3
  207. end
  208. item:SetData(id, count, nil, nil, nil, nil, nil, nil, nil, nil, spe_color)
  209. -- item:SetPosition(94*((k - 1)%5),math.floor((k - 1)/5) * -91)
  210. self.reward_item_list[k] = item
  211. item.gameObject:SetActive(false)
  212. end
  213. end
  214. end
  215. function CommonHuntResultView2:Remove()
  216. self:ClearRewardShow()
  217. self:ClearUIEffect(self.effect)
  218. self:ClearUIEffect(self.effect1)
  219. for i,v in ipairs(self.init_event) do
  220. GlobalTimerQuest:CancelQuest(v)
  221. end
  222. self.init_event = nil
  223. self:ClearTweenAnim()
  224. end
  225. --删除奖励
  226. function CommonHuntResultView2:ClearRewardShow()
  227. for k,v in pairs(self.reward_item_list) do
  228. v:ReleaseObj()
  229. v = nil
  230. end
  231. self.reward_item_list = {}
  232. end
  233. function CommonHuntResultView2:ClearTweenAnim( )
  234. if self.tween_id_1 then
  235. TweenLite.Stop(self.tween_id_1)
  236. self.tween_id_1 = nil
  237. end
  238. end
  239. function CommonHuntResultView2:AnalysicParmlist( )
  240. if self.parm_list then
  241. if self.parm_list.tag == "JoyWish" then
  242. local data = self.parm_list
  243. if data.btn_text_list then
  244. end
  245. if data.cost_data_list then
  246. local cost = data.cost_data_list
  247. self:SetCostShowOutSide(cost.res_path,cost.icon_size,cost.one_str,cost.ten_str)
  248. end
  249. if data.btn_list then
  250. for k,image in pairs(self.draw_btn_iamge_list) do
  251. lua_resM:setImageSprite(self,image,data.btn_list.abName,data.btn_list["resName"..k],false)
  252. image.transform.sizeDelta = Vector2(data.btn_list.size.x,data.btn_list.size.y)
  253. end
  254. self:SetBtnView(data.btn_list.text1,data.btn_list.text2)
  255. end
  256. for _,v in pairs(self.huntBtn_text_list) do
  257. v.gameObject:GetComponent("Outline").enabled = false
  258. end
  259. elseif self.parm_list.tag == "godhoodtower" then
  260. self.huntBtn_list[1]:SetActive(false)
  261. self.huntBtn_list[2]:SetActive(false)
  262. end
  263. end
  264. end