源战役客户端
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

194 wiersze
5.9 KiB

CSGWarResultView = CSGWarResultView or BaseClass(BaseView)
local CSGWarResultView = CSGWarResultView
--[[
CSGWarResultView.TabData = {
[1] = {name = "人物", level = MainRoleModel.TabOpenLevel[1]},
}
--]]
function CSGWarResultView:__init()
self.base_file = "CSGWar"
self.layout_file = "CSGWarResultView"
self.layer_name = "Top"
self.destroy_imm = true
self.use_background = true --全屏界面默认使用这个参数
--self.hide_maincancas = true --全屏界面需要放开隐藏主UI
self.change_scene_close = false
self.append_to_ctl_queue = false --是否要添加进界面堆栈
self.need_show_money = false --是否要显示顶部的金钱栏
self.click_bg_toClose = true
self.model = CSGWarModel:getInstance()
self.item_list = {}
self.load_callback = function ()
self:LoadSuccess()
self:AddEvent()
end
self.open_callback = function ( )
self:OpenSuccess()
end
self.switch_callback = function(index)
self:SwitchTab(index)
end
self.destroy_callback = function ( )
self:DestroySuccess()
end
end
function CSGWarResultView:Open( )
--self.data = data
BaseView.Open(self)
end
function CSGWarResultView:LoadSuccess()
local nodes = {
"bg:raw","bg1:raw","bg2:raw",
"time_text:tmp","item_scroll",
"item_scroll/Viewport/item_con", "occupy_text:tmp",
"con_player", "lb_reward_tip:tmp",
}
self:GetChildren(nodes)
lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("com_result_bg_1124_549"), false)
lua_resM:setOutsideRawImage(self, self.bg1_raw, GameResPath.GetCSGWarImage("csgwar_result_bg"), false)
lua_resM:setOutsideRawImage(self, self.bg2_raw, GameResPath.GetCSGWarImage("csgwar_result_bg2"), false)
end
function CSGWarResultView:AddEvent()
end
function CSGWarResultView:OpenSuccess()
self:UpdateView()
self:StartTime(10)
end
function CSGWarResultView:UpdateView()
local result_data = self.model:GetCSGWarResultInfo()
if result_data and TableSize(result_data) > 0 then
local cfg = Config.Crossguildwarscene
local str = ""
local index = 0
local sort_func = function ( a, b )
return a.city_id < b.city_id
end
table.sort(result_data.occupy_city, sort_func)
for i,v in ipairs(result_data.occupy_city) do
index = index + 1
str = str .. " "..cfg[v.city_id].name
if index % 2 == 0 then
str = str .. "\n"
end
end
self.occupy_text_tmp.text = str ~= "" and str or "非常遗憾,本次活动您的社团未占领任何据点"
self:UpdateRewardItem(result_data)
self:UpdateCityListItem(result_data.city_list)
end
end
function CSGWarResultView:UpdateRewardItem( result_data )
local my_guild_id = RoleManager.Instance.mainRoleInfo.guild_id
local is_fight_guild = self.model:IsCSGWarFightGuild(my_guild_id)
local is_leader = RoleManager.Instance.mainRoleInfo.position == GuildModel.GuildPosition.Leader
local is_central = false
local is_no_city = TableSize(result_data.occupy_city) == 0
for i,v in pairs(result_data.occupy_city) do
if v.city_id == 1 then
is_central = true
break
end
end
local is_main = true--result_data.room_id == 1 只有主战区了
local goods_list = {}
if not is_no_city then
if is_fight_guild then--如果是参战公会 读参战公会的配置
local area_str = is_main and "mteam" or "steam"
local city_str = is_central and "centerfield" or "surroundfield"
local position_str = is_leader and "lord" or "member"
local key_str = string.format("%s_%s_%s_rewards", area_str, city_str, position_str)
local kv_cfg = self.model:GetCSGWarKVCFG(key_str)
goods_list = stringtotable(kv_cfg.value)
else--不是参战公会 那统一就是帮众奖励 只区分是否主城
local area_str = is_main and "mteam" or "steam"
local city_str = is_central and "centerfield" or "surroundfield"
local position_str = "member"
local key_str = string.format("%s_%s_%s_rewards", area_str, city_str, position_str)
local kv_cfg = self.model:GetCSGWarKVCFG(key_str)
goods_list = stringtotable(kv_cfg.value)
end
end
if not self.award_list_com then
self.award_list_com = self:AddUIComponent(UI.ItemListCreator)
end
local info = {
data_list = goods_list,
item_con = self.item_con,
scroll_view = self.item_scroll,
obj_pool_type = UIObjPool.UIType.AwardItem,
start_y = -4,
item_width = 62,
space_x = 10,
alignment = UnityEngine.TextAnchor.UpperCenter,
on_update_item = function(item, i, v)
item:SetData(v[2], v[3])
end,
}
self.award_list_com:UpdateItems(info)
if #goods_list <= 0 then
self.lb_reward_tip_tmp.text = "本次活动未获得任何奖励"
else
self.lb_reward_tip_tmp.text = ""
end
end
function CSGWarResultView:UpdateCityListItem( city_list )
-- if not city_list or TableSize(city_list) <= 0 then return end
local city_list = city_list or {}
local temp_list = {}
for k,v in pairs(city_list) do
temp_list[v.city_id] = true
end
for i=1,5 do -- 没人占领的补充空数据
if not temp_list[i] then
table.insert(city_list, {city_id = i, is_empty = true})
end
end
-- 排序
local sort_func = function ( a, b )
return a.city_id < b.city_id
end
table.sort(city_list, sort_func)
for i,v in ipairs(city_list) do
self.item_list[i] = self.item_list[i] or CSGWarResultCityItem.New(self.con_player)
local item = self.item_list[i]
item:SetData(v)
item:SetPosition(0, (i - 1) * -70 + (-1.5))
end
end
function CSGWarResultView:StartTime( time )
self.time_text_tmp.text = string.format("%s秒后自动关闭", HtmlColorTxt(time, ColorUtil.GREEN_DARK))
local function on_show_time()
time = time - 1
if time > 0 then
self.time_text_tmp.text = string.format("%s秒后自动关闭", HtmlColorTxt(time, ColorUtil.GREEN_DARK))
else
self:Close()
end
end
self.show_timer_id = GlobalTimerQuest:AddPeriodQuest(on_show_time, 1, -1)
end
function CSGWarResultView:DestroySuccess( )
if self.show_timer_id then
GlobalTimerQuest:CancelQuest(self.show_timer_id)
self.show_timer_id = nil
end
for k,v in pairs(self.item_list) do
v:DeleteMe()
end
self.item_list = {}
end