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

193 regels
5.9 KiB

4 weken geleden
  1. CSGWarResultView = CSGWarResultView or BaseClass(BaseView)
  2. local CSGWarResultView = CSGWarResultView
  3. --[[
  4. CSGWarResultView.TabData = {
  5. [1] = {name = "人物", level = MainRoleModel.TabOpenLevel[1]},
  6. }
  7. --]]
  8. function CSGWarResultView:__init()
  9. self.base_file = "CSGWar"
  10. self.layout_file = "CSGWarResultView"
  11. self.layer_name = "Top"
  12. self.destroy_imm = true
  13. self.use_background = true --全屏界面默认使用这个参数
  14. --self.hide_maincancas = true --全屏界面需要放开隐藏主UI
  15. self.change_scene_close = false
  16. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  17. self.need_show_money = false --是否要显示顶部的金钱栏
  18. self.click_bg_toClose = true
  19. self.model = CSGWarModel:getInstance()
  20. self.item_list = {}
  21. self.load_callback = function ()
  22. self:LoadSuccess()
  23. self:AddEvent()
  24. end
  25. self.open_callback = function ( )
  26. self:OpenSuccess()
  27. end
  28. self.switch_callback = function(index)
  29. self:SwitchTab(index)
  30. end
  31. self.destroy_callback = function ( )
  32. self:DestroySuccess()
  33. end
  34. end
  35. function CSGWarResultView:Open( )
  36. --self.data = data
  37. BaseView.Open(self)
  38. end
  39. function CSGWarResultView:LoadSuccess()
  40. local nodes = {
  41. "bg:raw","bg1:raw","bg2:raw",
  42. "time_text:tmp","item_scroll",
  43. "item_scroll/Viewport/item_con", "occupy_text:tmp",
  44. "con_player", "lb_reward_tip:tmp",
  45. }
  46. self:GetChildren(nodes)
  47. lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("com_result_bg_1124_549"), false)
  48. lua_resM:setOutsideRawImage(self, self.bg1_raw, GameResPath.GetCSGWarImage("csgwar_result_bg"), false)
  49. lua_resM:setOutsideRawImage(self, self.bg2_raw, GameResPath.GetCSGWarImage("csgwar_result_bg2"), false)
  50. end
  51. function CSGWarResultView:AddEvent()
  52. end
  53. function CSGWarResultView:OpenSuccess()
  54. self:UpdateView()
  55. self:StartTime(10)
  56. end
  57. function CSGWarResultView:UpdateView()
  58. local result_data = self.model:GetCSGWarResultInfo()
  59. if result_data and TableSize(result_data) > 0 then
  60. local cfg = Config.Crossguildwarscene
  61. local str = ""
  62. local index = 0
  63. local sort_func = function ( a, b )
  64. return a.city_id < b.city_id
  65. end
  66. table.sort(result_data.occupy_city, sort_func)
  67. for i,v in ipairs(result_data.occupy_city) do
  68. index = index + 1
  69. str = str .. " "..cfg[v.city_id].name
  70. if index % 2 == 0 then
  71. str = str .. "\n"
  72. end
  73. end
  74. self.occupy_text_tmp.text = str ~= "" and str or "非常遗憾,本次活动您的社团未占领任何据点"
  75. self:UpdateRewardItem(result_data)
  76. self:UpdateCityListItem(result_data.city_list)
  77. end
  78. end
  79. function CSGWarResultView:UpdateRewardItem( result_data )
  80. local my_guild_id = RoleManager.Instance.mainRoleInfo.guild_id
  81. local is_fight_guild = self.model:IsCSGWarFightGuild(my_guild_id)
  82. local is_leader = RoleManager.Instance.mainRoleInfo.position == GuildModel.GuildPosition.Leader
  83. local is_central = false
  84. local is_no_city = TableSize(result_data.occupy_city) == 0
  85. for i,v in pairs(result_data.occupy_city) do
  86. if v.city_id == 1 then
  87. is_central = true
  88. break
  89. end
  90. end
  91. local is_main = true--result_data.room_id == 1 只有主战区了
  92. local goods_list = {}
  93. if not is_no_city then
  94. if is_fight_guild then--如果是参战公会 读参战公会的配置
  95. local area_str = is_main and "mteam" or "steam"
  96. local city_str = is_central and "centerfield" or "surroundfield"
  97. local position_str = is_leader and "lord" or "member"
  98. local key_str = string.format("%s_%s_%s_rewards", area_str, city_str, position_str)
  99. local kv_cfg = self.model:GetCSGWarKVCFG(key_str)
  100. goods_list = stringtotable(kv_cfg.value)
  101. else--不是参战公会 那统一就是帮众奖励 只区分是否主城
  102. local area_str = is_main and "mteam" or "steam"
  103. local city_str = is_central and "centerfield" or "surroundfield"
  104. local position_str = "member"
  105. local key_str = string.format("%s_%s_%s_rewards", area_str, city_str, position_str)
  106. local kv_cfg = self.model:GetCSGWarKVCFG(key_str)
  107. goods_list = stringtotable(kv_cfg.value)
  108. end
  109. end
  110. if not self.award_list_com then
  111. self.award_list_com = self:AddUIComponent(UI.ItemListCreator)
  112. end
  113. local info = {
  114. data_list = goods_list,
  115. item_con = self.item_con,
  116. scroll_view = self.item_scroll,
  117. obj_pool_type = UIObjPool.UIType.AwardItem,
  118. start_y = -4,
  119. item_width = 62,
  120. space_x = 10,
  121. alignment = UnityEngine.TextAnchor.UpperCenter,
  122. on_update_item = function(item, i, v)
  123. item:SetData(v[2], v[3])
  124. end,
  125. }
  126. self.award_list_com:UpdateItems(info)
  127. if #goods_list <= 0 then
  128. self.lb_reward_tip_tmp.text = "本次活动未获得任何奖励"
  129. else
  130. self.lb_reward_tip_tmp.text = ""
  131. end
  132. end
  133. function CSGWarResultView:UpdateCityListItem( city_list )
  134. -- if not city_list or TableSize(city_list) <= 0 then return end
  135. local city_list = city_list or {}
  136. local temp_list = {}
  137. for k,v in pairs(city_list) do
  138. temp_list[v.city_id] = true
  139. end
  140. for i=1,5 do -- 没人占领的补充空数据
  141. if not temp_list[i] then
  142. table.insert(city_list, {city_id = i, is_empty = true})
  143. end
  144. end
  145. -- 排序
  146. local sort_func = function ( a, b )
  147. return a.city_id < b.city_id
  148. end
  149. table.sort(city_list, sort_func)
  150. for i,v in ipairs(city_list) do
  151. self.item_list[i] = self.item_list[i] or CSGWarResultCityItem.New(self.con_player)
  152. local item = self.item_list[i]
  153. item:SetData(v)
  154. item:SetPosition(0, (i - 1) * -70 + (-1.5))
  155. end
  156. end
  157. function CSGWarResultView:StartTime( time )
  158. self.time_text_tmp.text = string.format("%s秒后自动关闭", HtmlColorTxt(time, ColorUtil.GREEN_DARK))
  159. local function on_show_time()
  160. time = time - 1
  161. if time > 0 then
  162. self.time_text_tmp.text = string.format("%s秒后自动关闭", HtmlColorTxt(time, ColorUtil.GREEN_DARK))
  163. else
  164. self:Close()
  165. end
  166. end
  167. self.show_timer_id = GlobalTimerQuest:AddPeriodQuest(on_show_time, 1, -1)
  168. end
  169. function CSGWarResultView:DestroySuccess( )
  170. if self.show_timer_id then
  171. GlobalTimerQuest:CancelQuest(self.show_timer_id)
  172. self.show_timer_id = nil
  173. end
  174. for k,v in pairs(self.item_list) do
  175. v:DeleteMe()
  176. end
  177. self.item_list = {}
  178. end