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

251 rivejä
7.7 KiB

-- <*
-- @Author: msh
-- @Description: 跨国团战公示界面view
-- *>
CSGWarShowView = CSGWarShowView or BaseClass(BaseView)
local CSGWarShowView = CSGWarShowView
function CSGWarShowView:__init()
self.base_file = "CSGWar"
self.layout_file = "CSGWarShowView"
self.layer_name = "UI"
self.destroy_imm = true
self.use_background = G_USING_BG --全屏界面默认使用这个参数
--self.hide_maincancas = true --全屏界面需要放开隐藏主UI
self.change_scene_close = true
self.append_to_ctl_queue = false --是否要添加进界面堆栈
self.need_show_money = false --是否要显示顶部的金钱栏
self.close_fog = true
self.model = CSGWarModel:GetInstance()
self.model:Fire(CSGWarConst.REQ_CSGWAR_SCMD, 60101)
self.show_item_list = {}
self.cur_area_index = 1 -- 只会是1
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 CSGWarShowView:Open( )
--self.data = data
BaseView.Open(self)
self.model:SetLoginRed( false )
end
function CSGWarShowView:LoadSuccess()
local nodes = {
"tip_text:tmp",
"title:img",
"bg:obj:raw",
"show_con/power_text:txt",
"show_con/show_item_con",
"show_con:obj",
"show_con/occupy_server_text:tmp",
"show_con/receive_image:obj:img",
"show_con/guild_text:tmp",
"show_con/name_text:tmp",
"show_con/occupy_bg:obj",
"show_con/occupy_text:tmp",
"show_con/role_con",
"show_con/reward_image:obj:img",
"show_con/reward_red_image:obj",
"pic_close:obj",
}
self:GetChildren(nodes)
self:UpdateBaseView( )
end
function CSGWarShowView:UpdateBaseView( )
lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("CSGWar_show_bg_1044_540"),false)
lua_resM:setOutsideImageSprite(self,self.title_img,GameResPath.GetCSGWarImage("CSGWar_show_title"),false)
local function bg_back_func( ... )
if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then
self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend"))
end
self:MoveUIToBack(self.bg)
self:MoveUIToBack(self.title)
end
if self.background_wnd then
bg_back_func()
else
self.bg_back_func = bg_back_func
end
end
function CSGWarShowView:AddEvent()
local on_click = function ( click_obj )
if self.pic_close_obj == click_obj then
self:Close()
elseif click_obj == self.reward_image_obj then
self.model:Fire(CSGWarConst.REQ_CSGWAR_SCMD, 60107, self.cur_area_index, 1)
end
end
AddClickEvent(self.pic_close_obj, on_click)
AddClickEvent(self.reward_image_obj, on_click)
local function on_update_show_item( )
self:UpdateShowItem()
self:UpdateCentralInfo()
self:UpdateRedDot()
end
self.on_update_show_item_id = self.model:BindOne("CSGWar_occupy_info", on_update_show_item)
local function on_update_red( )
self:UpdateRedDot()
end
self.on_update_red_id = self.model:Bind(CSGWarConst.ANS_CSGWAR_RED, on_update_red)
end
function CSGWarShowView:OpenSuccess()
self:UpdateView()
end
function CSGWarShowView:UpdateView()
-- local str = ChuanWenManager:getInstance():FormatColorTag2(CSGWarConst.TIP_DESC, true)
-- self.tip_text_tmp.text = str
-- SetAnchoredPosition(self.tip_text, -262, -190)
self:UpdateShowItem()
self:UpdateCentralInfo()
self:SetTimerShow()
self:UpdateRedDot()
end
function CSGWarShowView:UpdateShowItem( )
local data = self.model:GetCSGWarOccupyInfo() or {}
local x_offset = 352
local y_offset = 208
for i=1,4 do
local item = self.show_item_list[i]
if not item then
item = CSGWarShowItem.New(self.show_item_con)
item:SetPosition((i - 1) % 2 * x_offset-6, -math.floor((i - 1) / 2) * y_offset+8)
self.show_item_list[i] = item
end
item:SetData(data[i+1], i, self.cur_area_index)
end
end
--更新中心城区信息
function CSGWarShowView:UpdateCentralInfo( )
local data = self.model:GetCSGWarOccupyInfo() or {}
if data[1] then
local guild_str = GetCSLongName(data[1].guild_name, data[1].server_num, false, ColorUtil.GREEN_DARK)
local boss_str = string.format("%s %s", HtmlColorTxt("团长:", ColorUtil.YELLOW_DARK), data[1].chief_name)
local str = string.format("%s\n%s", guild_str, boss_str)
self.occupy_text_tmp.text = str
-- self.occupy_server_text_tmp.text = GetCSLongName("服", data[1].server_num, true)
self.occupy_server_text_tmp.text = KfWorldModel:GetInstance():GetContrayNameById(data[1].fact_id)
local server_id = RoleManager.Instance.mainRoleInfo.server_id
self.reward_image_obj:SetActive(server_id == data[1].server_id)
self.receive_image_obj:SetActive(data[1].is_received_reward == 1)
if data[1].is_received_reward == 1 then
lua_resM:setImageSprite(self, self.reward_image_img, "CSGWar_asset", "CSGWar_item3")
else
lua_resM:setImageSprite(self, self.reward_image_img, "CSGWar_asset", "CSGWar_item2")
end
self.guild_text_tmp.text = guild_str
self.name_text_tmp.text = boss_str
self.power_text_txt.text = "f"..data[1].chief_power
self:SetRoleModel(data[1].chief_id)
else
local guild_str = "暂无占领"
local boss_str = "团长: 暂无"
local str = string.format("%s\n%s", guild_str, boss_str)
self.occupy_text_tmp.text = str
self.occupy_server_text_tmp.text = "暂无占领"
self.receive_image_obj:SetActive(false)
self.reward_image_obj:SetActive(false)
self.guild_text_tmp.text = guild_str
self.name_text_tmp.text = boss_str
self.power_text_txt.text = ""
self:SetRoleModel()
end
end
function CSGWarShowView:SetRoleModel( role_id )
role_id = role_id or 0
self.role_id = role_id
if role_id ~= 0 then
SetLocalScale(self.role_con, 1, 1, 1)
else
SetLocalScale(self.role_con, 0.001, 0.001, 0.001)
end
local res_data = {
father_node = self,
transform = self.role_con,
fashion_type = FuncOpenModel.TypeId.Clothes,
size = Vector2(720,720),
scale = 180,
position = Vector3(90,-100,0),
ui_model_type = UIModelCommon.ModelType.BackModel,
}
FuncOpenModel:getInstance():SetRoleModelByID(role_id, res_data)
end
-- 结束倒计时
function CSGWarShowView:SetTimerShow()
local _, end_show_time = self.model:NeedShowCSGWarResult()
if end_show_time and end_show_time - TimeUtil:getServerTime() > 0 then
local function onTimer()
local sec = end_show_time - TimeUtil:getServerTime()
if sec > 0 then
self.tip_text_tmp.text = string.format("公示结束倒计时:<color=%s>%s</color>", ColorUtil.GREEN_DARK,TimeUtil:timeConvert6(sec, false))
else
self.tip_text_tmp.text = string.format("公示结束倒计时:<color=%s>已结束</color>",ColorUtil.RED_DARK)
GlobalTimerQuest:CancelQuest(self.timer_id)
self.timer_id = nil
end
end
if not self.timer_id then
self.timer_id = GlobalTimerQuest:AddPeriodQuest(onTimer, 1, -1)
end
else
self.tip_text_tmp.text = string.format("公示结束倒计时:<color=%s>已结束</color>",ColorUtil.RED_DARK)
end
end
function CSGWarShowView:UpdateRedDot( )
local red_data = self.model:GetCSGWarRedData()
if red_data.occupy_red and red_data.occupy_red_data[1] then
self.reward_red_image_obj:SetActive(true)
else
self.reward_red_image_obj:SetActive(false)
end
end
function CSGWarShowView:SwitchTab( index )
end
function CSGWarShowView:DestroySuccess( )
for i,v in ipairs(self.show_item_list) do
v:DeleteMe()
v = nil
end
self.show_item_list = {}
if self.timer_id then
GlobalTimerQuest:CancelQuest(self.timer_id)
self.timer_id = nil
end
if self.on_update_show_item_id then
self.model:UnBind(self.on_update_show_item_id)
self.on_update_show_item_id = nil
end
if self.on_update_red_id then
self.model:UnBind(self.on_update_red_id)
self.on_update_red_id = nil
end
end