源战役客户端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

206 linhas
5.5 KiB

4 semanas atrás
  1. GuildWarResultView = GuildWarResultView or BaseClass(BaseView)
  2. local GuildWarResultView= GuildWarResultView
  3. function GuildWarResultView:__init()
  4. self.base_file = "guildScene"
  5. self.layout_file = "GuildWarResultView"
  6. self.layer_name = "Activity"
  7. self.use_background = true
  8. self.click_bg_toClose = true
  9. self.change_scene_close = true
  10. self.destroy_imm = true
  11. self.is_set_zdepth = true
  12. self.model = GuildModel:getInstance()
  13. self.item_list = {}
  14. self.open_callback = function()
  15. end
  16. self.load_callback = function()
  17. self:LoadSuccess()
  18. self:InitEvent()
  19. end
  20. self.close_callback = function ()
  21. end
  22. self.destroy_callback = function()
  23. self:Remove()
  24. end
  25. end
  26. function GuildWarResultView:Open()
  27. self.data = self.model.guild_war_info.result
  28. BaseView.Open(self)
  29. end
  30. function GuildWarResultView:Remove()
  31. self.model.guild_war_info.result = false
  32. if self.timer then
  33. GlobalTimerQuest:CancelQuest(self.timer)
  34. self.timer = nil
  35. end
  36. for i,item in pairs(self.item_list) do
  37. item:ReleaseObj()
  38. end
  39. self.item_list = {}
  40. end
  41. function GuildWarResultView:LoadSuccess()
  42. local nodes = {
  43. "title_bg:raw",
  44. "bg_1:raw:obj",
  45. "itemRoot/Viewport/Content",
  46. "itemRoot",
  47. "leader_mvp:tmp",
  48. "my_rank:tmp",
  49. "guild_rank:tmp",
  50. "guid_mvp:tmp",
  51. "left_label:tmp",
  52. }
  53. self:GetChildren(nodes)
  54. if not self.data then
  55. self:Close()
  56. return
  57. end
  58. self:UpdateView()
  59. self:CheckLeftTime()
  60. self:UpdateItem()
  61. end
  62. function GuildWarResultView:InitEvent()
  63. local function onBtnClickHandler(target )
  64. if target == self.bg_1_obj then
  65. self:Close()
  66. end
  67. end
  68. AddClickEvent(self.bg_1_obj,onBtnClickHandler)
  69. end
  70. function GuildWarResultView:UpdateView()
  71. self.guid_mvp_tmp.text = self.data.mvp_guild
  72. self.leader_mvp_tmp.text = self.data.mvp_leader
  73. self.guild_rank_tmp.text = string.format("社团排名:%s", HtmlColorTxt("" .. self.data.my_guild_rank .. "", "#fdffc2"))
  74. self.my_rank_tmp.text = string.format("个人排名:%s", HtmlColorTxt("" .. self.data.my_rank .. "", "#fdffc2"))
  75. lua_resM:setOutsideRawImage(self, self.bg_1_raw, GameResPath.GetViewBigBg("guild_event_war_bg3"), false)
  76. lua_resM:setOutsideRawImage(self,self.title_bg_raw,GameResPath.GetGuildImage("guild_event_war_txt2_pointfilter"))
  77. end
  78. function GuildWarResultView:CheckLeftTime()
  79. local left_time = 10
  80. local function timer_func()
  81. left_time = left_time - 1
  82. if left_time and left_time > 0 then
  83. self.left_label_tmp.text = string.format("%s 秒后自动退出", HtmlColorTxt(tostring(left_time) , "#2cf86f"))
  84. else
  85. self:Close()
  86. end
  87. end
  88. if not self.timer then
  89. self.timer = GlobalTimerQuest:AddPeriodQuest(timer_func, 1)
  90. end
  91. timer_func()
  92. end
  93. function GuildWarResultView:UpdateItem()
  94. --社团排名奖励
  95. local reward_list = self.model:GuildWarGetGuildRewardByRank(self.data.my_guild_rank)
  96. --如果明星摄团团长是自己,要加上这部分的奖励显示
  97. if self.data.mvp_leader == RoleManager.Instance.mainRoleInfo.name and Config.Guildwarkv["star_org_award"] and Config.Guildwarkv["star_org_award"]["value_content"] then
  98. local mvp_reward_list = stringtotable(Config.Guildwarkv["star_org_award"]["value_content"])
  99. local not_exit_list = {}
  100. for i,v in ipairs(mvp_reward_list) do
  101. local is_exit = false
  102. for ii,vv in ipairs(reward_list) do
  103. if v[1] == vv[11] and v[2] == vv[2] then
  104. vv[3] = vv[3] + v[3]
  105. is_exit = true
  106. break
  107. end
  108. end
  109. if not is_exit then
  110. table.insert(not_exit_list, v)
  111. end
  112. end
  113. if #not_exit_list > 0 then
  114. for i,v in ipairs(not_exit_list) do
  115. table.insert(reward_list, v)
  116. end
  117. end
  118. end
  119. --积分榜奖励
  120. local score_reward_list = self.model:GuildWarGetScoreRewardByRank(self.data.my_rank)
  121. if score_reward_list and #score_reward_list > 0 then
  122. local not_exit_list = {}
  123. for i,v in ipairs(score_reward_list) do
  124. local is_exit = false
  125. for ii,vv in ipairs(reward_list) do
  126. if v[1] == vv[11] and v[2] == vv[2] then
  127. vv[3] = vv[3] + v[3]
  128. is_exit = true
  129. break
  130. end
  131. end
  132. if not is_exit then
  133. table.insert(not_exit_list, v)
  134. end
  135. end
  136. if #not_exit_list > 0 then
  137. for i,v in ipairs(not_exit_list) do
  138. table.insert(reward_list, v)
  139. end
  140. end
  141. end
  142. --击杀榜奖励
  143. local kill_reward_list = self.model:GuildWarGetKillRewardByRank(self.data.kill_rank)
  144. if kill_reward_list and #kill_reward_list > 0 then
  145. local not_exit_list = {}
  146. for i,v in ipairs(kill_reward_list) do
  147. local is_exit = false
  148. for ii,vv in ipairs(reward_list) do
  149. if v[1] == vv[11] and v[2] == vv[2] then
  150. vv[3] = vv[3] + v[3]
  151. is_exit = true
  152. break
  153. end
  154. end
  155. if not is_exit then
  156. table.insert(not_exit_list, v)
  157. end
  158. end
  159. if #not_exit_list > 0 then
  160. for i,v in ipairs(not_exit_list) do
  161. table.insert(reward_list, v)
  162. end
  163. end
  164. end
  165. if #reward_list > 0 then
  166. for i,v in ipairs(reward_list) do
  167. local item = self.item_list[i]
  168. if item == nil then
  169. item = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.Content)
  170. self.item_list[i] = item
  171. end
  172. local goods_Id, lock = GoodsModel:getInstance():GetMappingTypeId(v[1], v[2])
  173. local goodVo = GoodsModel:getInstance():GetGoodsBasicByTypeId(goods_Id)
  174. if goodVo then
  175. item:SetItemSize(78, 78)
  176. item:SetData(goodVo.type_id, v[3] , goodVo.color, nil, lock)
  177. item:SetVisible(true)
  178. item:SetAnchoredPosition((i - 1) * 87,0)
  179. end
  180. end
  181. for i=#reward_list + 1,#self.item_list do
  182. self.item_list[i]:SetVisible(false)
  183. end
  184. end
  185. end