源战役客户端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

319 řádky
9.2 KiB

před 4 týdny
  1. GodActivityResultView = GodActivityResultView or BaseClass(BaseView)
  2. local GodActivityResultView = GodActivityResultView
  3. function GodActivityResultView:__init()
  4. self.base_file = "godActivity"
  5. self.layout_file = "GodActivityResultView"
  6. self.layer_name = "Activity"
  7. self.destroy_imm = true
  8. self.use_background = true
  9. self.change_scene_close = true
  10. self.hide_maincancas = true --是否隐藏主界面
  11. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  12. self.need_show_money = false --是否要显示顶部的金钱栏
  13. self.blur_activity_bg = true
  14. self.use_show_anim = true
  15. self.use_hide_anim = true
  16. self.is_set_zdepth = true
  17. self.model = GodModel:getInstance()
  18. self.item_list = {}
  19. self.start_pos_x = 0
  20. self.start_pos_y = 0
  21. self.draw_num_type = 0 --结算数量类型 1|单抽 2|10连
  22. self.last_draw_time = 0
  23. self.load_callback = function ()
  24. self:LoadSuccess()
  25. self:AddEvent()
  26. end
  27. self.open_callback = function ( )
  28. self:OpenSuccess()
  29. end
  30. self.close_win_callback = function ( )
  31. self:Close()
  32. end
  33. self.destroy_callback = function ( )
  34. self:DestroySuccess()
  35. end
  36. end
  37. --普通/限时
  38. --单抽/十连
  39. --抽奖返回数据
  40. function GodActivityResultView:Open(data)
  41. self.pool_type = data.pool_type
  42. self.draw_num_type = data.type
  43. self.data = data
  44. BaseView.Open(self)
  45. end
  46. function GodActivityResultView:LoadSuccess()
  47. local nodes = {
  48. "resultBg:img:obj",
  49. "itemCon:obj",
  50. "ScrollView", "ScrollView/Viewport/Content", "ScrollView/Viewport:img",
  51. "visCon:obj",
  52. "visCon/confirmBtn:obj",
  53. "visCon/againBtn:obj",
  54. "visCon/costIcon:img",
  55. "visCon/costPrice:tmp",
  56. "visCon/againBtn/againText:tmp",
  57. "scoreNum:tmp",
  58. "effectCon:obj",
  59. "visCon/lightEffect",
  60. }
  61. self:GetChildren(nodes)
  62. self.visCon_obj:SetActive(true)
  63. self.confirmBtn_obj:SetActive(true)
  64. SetLocalPosition(self.transform, 0, 0,-1000)
  65. local function bg_back_func( ... )
  66. self.itemCon_obj:SetActive(false)
  67. self.awarditem = CapsuleEggAwardItem.New(self.itemCon)
  68. lua_resM:setOutsideImageSprite(self, self.resultBg_img, GameResPath.GetCapsuleEggRes("capsule_egg_result_shine_837_630"))
  69. if self.need_refreshData then
  70. self:UpdateView(self.pool_type)
  71. end
  72. end
  73. if self.background_wnd then
  74. bg_back_func()
  75. else
  76. self.bg_back_func = bg_back_func
  77. end
  78. SetAnchoredPosition(self.lightEffect,0,-40)
  79. self:AddUIEffect("ui_jihuoxinxitong01", self.lightEffect, self.layer_name, nil, 1.2, true,nil,nil, nil, nil,nil)
  80. end
  81. function GodActivityResultView:AddEvent()
  82. local on_click = function ( click_obj )
  83. if self.confirmBtn_obj == click_obj then--关闭界面
  84. self:Close()
  85. -- elseif self.againBtn_obj == click_obj then--再来
  86. -- if TimeUtil:getServerTimeMs()/1000 - self.last_draw_time > 1 then
  87. -- self.last_draw_time = TimeUtil:getServerTimeMs()/1000
  88. -- self:LuckStart()
  89. -- end
  90. end
  91. end
  92. AddClickEvent(self.confirmBtn_obj, on_click)
  93. -- AddClickEvent(self.againBtn_obj, on_click)
  94. end
  95. function GodActivityResultView:OpenSuccess()
  96. self:UpdateView(self.pool_type)
  97. end
  98. function GodActivityResultView:UpdateView(pool_type)
  99. self.pool_type = pool_type
  100. if self.is_loaded then
  101. self.need_refreshData = false
  102. else
  103. self.need_refreshData = true
  104. return
  105. end
  106. local award_data = {}
  107. local debug_test = false
  108. if debug_test then
  109. local temp_data = {}
  110. local tt = {0,230003,5}
  111. for i=1,10 do
  112. table.insert(temp_data,tt)
  113. end
  114. award_data = temp_data
  115. else
  116. award_data = self.data.award
  117. end
  118. self.reward_list = {}
  119. for k,v in pairs(award_data) do
  120. table.insert(self.reward_list,{gtype_id = v[2],goods_num = v[3]})
  121. end
  122. self:Reset()
  123. if not self.reward_list or #self.reward_list == 0 then
  124. return
  125. end
  126. local reward_count = #self.reward_list
  127. if reward_count == 1 then
  128. self.draw_num_type = 1
  129. self.againText_tmp.text = "再来1次"
  130. self.scoreNum_tmp.text = 1
  131. elseif reward_count>1 and reward_count<=10 then
  132. self.draw_num_type = 2
  133. self.againText_tmp.text = "再来10次"
  134. self.scoreNum_tmp.text = 10
  135. end
  136. -- self:UpdateCost()
  137. self:UpdateRewardBoxes()
  138. end
  139. function GodActivityResultView:Reset( )--重置
  140. if self.awarditem then
  141. self.awarditem:StopAction()
  142. self.awarditem:SetAwardItemVis(false)
  143. end
  144. self.Content.anchoredPosition = Vector2(self.start_pos_x,self.start_pos_y)
  145. for k,v in pairs(self.item_list) do
  146. v:SetAwardItemVis(false)
  147. v:StopAction()
  148. end
  149. end
  150. function GodActivityResultView:UpdateRewardBoxes()
  151. local reward_count = #self.reward_list
  152. if reward_count == 1 then
  153. self.itemCon_obj:SetActive(true)
  154. self.awarditem:SetData(self.reward_list[1],1)
  155. self.awarditem:StartAction(1)
  156. return
  157. end
  158. local x = 0
  159. local y = 0
  160. for i = 1, reward_count do
  161. local item = self.item_list[i]
  162. if not item then
  163. item = CapsuleEggAwardItem.New(self.Content)
  164. self.item_list[i] = item
  165. end
  166. item:SetData(self.reward_list[i],i)
  167. x = (84 + 42) * ((i-1)%5)+5
  168. y = -(84 + 30)* math.floor((i-1)/5)-15
  169. item:SetPosition(x,y)
  170. item:StartAction(i)
  171. end
  172. self.Content.sizeDelta = Vector2(0, (84 + 30)* math.floor(reward_count/5)+15)
  173. end
  174. --[[function GodActivityResultView:UpdateCost( )
  175. local costIcon_res = 0
  176. local cost_ticket_num_list = self.model:GetCostTicketNumList()
  177. if self.draw_num_type == 1 then
  178. costIcon_res = self.model:GetCostTicketGTypeId(self.pool_type,1)
  179. if cost_ticket_num_list[self.pool_type][1] < 1 then
  180. self.costPrice_tmp.text = string.format("<%s>%s</color>/1", ColorUtil.RED_DARK, cost_ticket_num_list[self.pool_type][1])
  181. else
  182. self.costPrice_tmp.text = string.format("<%s>%s</color>/1", ColorUtil.GREEN_DARK, cost_ticket_num_list[self.pool_type][1])
  183. end
  184. elseif self.draw_num_type == 2 then
  185. if self.model:GetCostTicketNumList()[self.pool_type][2] > 0 then
  186. costIcon_res = self.model:GetCostTicketGTypeId(self.pool_type,10)
  187. if cost_ticket_num_list[self.pool_type][2] < 1 then
  188. self.costPrice_tmp.text = string.format("<%s>%s</color>/1", ColorUtil.RED_DARK, cost_ticket_num_list[self.pool_type][2])
  189. else
  190. self.costPrice_tmp.text = string.format("<%s>%s</color>/1", ColorUtil.GREEN_DARK, cost_ticket_num_list[self.pool_type][2])
  191. end
  192. else
  193. costIcon_res = self.model:GetCostTicketGTypeId(self.pool_type,1)
  194. if cost_ticket_num_list[self.pool_type][1] < 9 then
  195. self.costPrice_tmp.text = string.format("<%s>%s</color>/9", ColorUtil.RED_DARK, cost_ticket_num_list[self.pool_type][1])
  196. else
  197. self.costPrice_tmp.text = string.format("<%s>%s</color>/9", ColorUtil.GREEN_DARK, cost_ticket_num_list[self.pool_type][1])
  198. end
  199. end
  200. end
  201. lua_resM:setOutsideImageSprite(self, self.costIcon_img, GameResPath.GetGoodsIcon(costIcon_res),true)
  202. end--]]
  203. --[[function GodActivityResultView:LuckStart( )
  204. local ticket_num_list = self.model:GetCostTicketNumList()
  205. local price_asset, price_icon = WordManager:GetCommonMoneyIcon(1)
  206. local cost_price = 0
  207. local tickets_goods_type_id = 102305
  208. if self.pool_type == 1 then
  209. tickets_goods_type_id = 102305
  210. elseif self.pool_type == 2 then
  211. tickets_goods_type_id = 102308
  212. elseif self.pool_type == 3 then
  213. tickets_goods_type_id = 102311
  214. end
  215. local tickets_price = Config.Goodsprice[tickets_goods_type_id].price
  216. if self.draw_num_type == 1 then
  217. if ticket_num_list[self.pool_type][1] >= 1 then--有单抽券直接抽
  218. self.model:Fire(CapsuleEggConst.REQUEST_CCMD_EVENT,17003,self.pool_type,self.draw_num_type,0)
  219. return
  220. else--补齐
  221. cost_price = tickets_price
  222. end
  223. elseif self.draw_num_type == 2 then
  224. if ticket_num_list[self.pool_type][2] >= 1 then
  225. self.model:Fire(CapsuleEggConst.REQUEST_CCMD_EVENT,17003,self.pool_type,self.draw_num_type,0)
  226. return
  227. else
  228. if ticket_num_list[self.pool_type][1] >= 9 then
  229. self.model:Fire(CapsuleEggConst.REQUEST_CCMD_EVENT,17003,self.pool_type,self.draw_num_type,0)
  230. return
  231. else
  232. cost_price = (9-ticket_num_list[self.pool_type][1])*tickets_price
  233. end
  234. end
  235. end
  236. local function close_callback( ... )
  237. self:Close()
  238. end
  239. local function ok_callback()
  240. if GoodsModel:getInstance():IsJinEnough(cost_price) then
  241. self.model:Fire(CapsuleEggConst.REQUEST_CCMD_EVENT,17003,self.pool_type,self.draw_num_type,0)
  242. return
  243. else
  244. local qc_data = {
  245. price = cost_price,
  246. close_callback = close_callback,
  247. }
  248. GlobalEventSystem:Fire(EventName.OPEN_RECHARGE_TIP_VIEW, true, qc_data)
  249. end
  250. end
  251. local function toggle_function( flag )
  252. self.model._again_draw_no_double_check = flag
  253. end
  254. local toggle_tip_data = {
  255. gold_ab_res = price_asset,
  256. gold_res = price_icon,
  257. price = cost_price,
  258. insufficientText = "",
  259. priceText = string.format("<color=#fdffc2>%s</color> 补齐所需的单抽券",cost_price),
  260. titleText = "提示",
  261. ok_callback = ok_callback,
  262. toggle_function = toggle_function,
  263. is_complex_ok_callback = true,
  264. jump_recharge_callback = close_callback,
  265. }
  266. if not self.model._again_draw_no_double_check and cost_price ~= 0 then
  267. GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, toggle_tip_data)
  268. else
  269. ok_callback()
  270. end
  271. end--]]
  272. function GodActivityResultView:DestroySuccess( )
  273. if self.awarditem then
  274. self.awarditem:DeleteMe()
  275. self.awarditem = nil
  276. end
  277. for i,item in pairs(self.item_list) do
  278. item:DeleteMe()
  279. item = nil
  280. end
  281. self.item_list = {}
  282. self:ClearUIEffect(self.lightEffect)
  283. self:ClearUIEffect(self.effectCon)
  284. end