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

118 rivejä
4.1 KiB

-- <*
-- @Author: Saber
-- @Description: 藏宝图奖池预览界面
-- *>
TreasureMapRewardPreviewView = TreasureMapRewardPreviewView or BaseClass(BaseView)
local TreasureMapRewardPreviewView = TreasureMapRewardPreviewView
function TreasureMapRewardPreviewView:__init()
self.base_file = "treasureMap"
self.layout_file = "TreasureMapRewardPreviewView"
self.layer_name = "Activity"
self.destroy_imm = true
self.use_background = true --全屏界面默认使用这个参数,非全屏界面自行设置
self.hide_maincancas = false --全屏界面需要隐藏主UI
self.change_scene_close = true --是否切换场景时关闭(弹出界面使用)
self.model = TreasureMapModel:getInstance()
self.cur_index = 1
self.load_callback = function ()
self:LoadSuccess()
self:AddEvent()
end
self.open_callback = function ( )
self:SwitchTab(self.cur_index)
end
self.destroy_callback = function ( )
self:DestroySuccess()
end
end
function TreasureMapRewardPreviewView:Open(index)
self.cur_index = index or self.cur_index
BaseView.Open(self)
end
function TreasureMapRewardPreviewView:LoadSuccess()
local nodes = {
"win_bg:raw", "close_btn:obj",
"item_scroll",
"item_scroll/Viewport/item_con",
-- 页签1
"tab_con/tab1:obj",
"tab_con/tab1/tab1_selected:obj",
"tab_con/tab1/tab1_name:tmp",
"tab_con/tab1/tab1_name_sel:tmp",
-- 页签2
"tab_con/tab2:obj",
"tab_con/tab2/tab2_selected:obj",
"tab_con/tab2/tab2_name:tmp",
"tab_con/tab2/tab2_name_sel:tmp",
"tip_con/tip_icon:obj",
}
self:GetChildren(nodes)
lua_resM:setOutsideRawImage(self, self.win_bg_raw, GameResPath.GetViewBigBg("tm_preview_bg"))
end
function TreasureMapRewardPreviewView:AddEvent()
local function click_event(target)
if target == self.close_btn_obj then
self:Close()
elseif target == self.tab1_obj then
self:SwitchTab(1)
elseif target == self.tab2_obj then
self:SwitchTab(2)
elseif target == self.tip_icon_obj then -- 查看概率
UIToolTipMgr:getInstance():AppendLuckyProbTips(424, self.cur_index, 1)
end
end
AddClickEvent(self.close_btn_obj, click_event)
AddClickEvent(self.tab1_obj, click_event, LuaSoundManager.SOUND_UI.SWITCH)
AddClickEvent(self.tab2_obj, click_event, LuaSoundManager.SOUND_UI.SWITCH)
AddClickEvent(self.tip_icon_obj, click_event)
end
function TreasureMapRewardPreviewView:SwitchTab(index)
self.cur_index = index
self.tab1_selected_obj:SetActive(self.cur_index == 1)
self.tab2_selected_obj:SetActive(self.cur_index == 2)
self.tab1_name_tmp.text = self.cur_index == 1 and "" or "普通藏宝图"
self.tab1_name_sel_tmp.text = self.cur_index == 1 and "普通藏宝图" or ""
self.tab2_name_tmp.text = self.cur_index == 2 and "" or "高级藏宝图"
self.tab2_name_sel_tmp.text = self.cur_index == 2 and "高级藏宝图" or ""
self:UpdateView()
end
function TreasureMapRewardPreviewView:UpdateView()
-- 获取藏宝图奖励数据
local data = self.model:GetTreasureMapRewardPreviewData(self.cur_index)
self.reward_item_creator = self.reward_item_creator or self:AddUIComponent(UI.ItemListCreator)
local info = {
data_list = data,
scroll_view = self.item_scroll,
item_con = self.item_con,
obj_pool_type = UIObjPool.UIType.AwardItem,
item_width = 62,
item_height = 62,
start_x = 8,
start_y = -6.5,
space_x = 16,
space_y = 16,
create_frequency = 0.01,
is_scroll_back_on_update = true,
alignment = UnityEngine.TextAnchor.UpperLeft,
on_update_item = function(item, i, v)
local typeId, lock = GoodsModel:getInstance():GetMappingTypeId(v.rewards[1], v.rewards[2])
item:SetData(typeId, v.rewards[3], nil, nil, lock)
item:SetItemSize(62, 62)
end,
}
self.reward_item_creator:UpdateItems(info)
end
function TreasureMapRewardPreviewView:DestroySuccess( )
end