-- <*
|
|
-- @Author: Saber
|
|
-- @Description: 招财猫广告界面
|
|
-- *>
|
|
FortuneCatAdTipsView = FortuneCatAdTipsView or BaseClass(BaseView)
|
|
local FortuneCatAdTipsView = FortuneCatAdTipsView
|
|
|
|
function FortuneCatAdTipsView:__init()
|
|
self.base_file = "fortuneCat"
|
|
self.layout_file = "FortuneCatAdTipsView"
|
|
self.layer_name = "Main"
|
|
self.destroy_imm = true
|
|
self.change_scene_close = true
|
|
self.use_background = false --全屏界面默认使用这个参数,非全屏界面自行设置
|
|
self.show_time = 20 -- 界面展示时间
|
|
self.model = FortuneCatModel:getInstance()
|
|
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
self:AddEvent()
|
|
end
|
|
self.open_callback = function ( )
|
|
self:UpdateView()
|
|
end
|
|
self.destroy_callback = function ( )
|
|
self:DestroySuccess()
|
|
end
|
|
end
|
|
|
|
function FortuneCatAdTipsView:Open(sub_type)
|
|
self.sub_type = sub_type
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function FortuneCatAdTipsView:LoadSuccess()
|
|
local nodes = {
|
|
"ad_bg:obj:img",
|
|
"ad_bg/close_btn:obj",
|
|
}
|
|
self:GetChildren(nodes)
|
|
self.transform.sizeDelta = Vector2(ScreenWidth, ScreenHeight)
|
|
|
|
local base_type = CustomActivityModel.CustomActBaseType.FORTUNE_CAT
|
|
local icon_sub_type_base = base_type*1000
|
|
if self.sub_type >= 10001 then
|
|
icon_sub_type_base = base_type*100000
|
|
end
|
|
local pos = ActivityIconManager:getInstance():GetIconWorldPos(icon_sub_type_base + self.sub_type)
|
|
SetAnchoredPosition(self.ad_bg, pos.x - 100, pos.y - 80)
|
|
end
|
|
|
|
function FortuneCatAdTipsView:AddEvent()
|
|
local function click_event(target)
|
|
if target == self.ad_bg_obj then
|
|
self.model:Fire(FortuneCatModel.OPEN_FORTUNE_CAT_VIEW, true, self.sub_type)
|
|
self:Close()
|
|
elseif target == self.close_btn_obj then
|
|
self:Close()
|
|
end
|
|
end
|
|
AddClickEvent(self.ad_bg_obj, click_event)
|
|
AddClickEvent(self.close_btn_obj, click_event, LuaSoundManager.SOUND_UI.NONE)
|
|
end
|
|
|
|
function FortuneCatAdTipsView:UpdateView()
|
|
local cur_time = Status.NowTime
|
|
local function auto_close_timer()
|
|
local pass_time = Status.NowTime - cur_time
|
|
if pass_time > self.show_time then
|
|
self:Close()
|
|
end
|
|
end
|
|
self:ClearAutoCloseTimerId()
|
|
self.auto_close_timer_id = GlobalTimerQuest:AddPeriodQuest(auto_close_timer, 1, -1)
|
|
end
|
|
|
|
function FortuneCatAdTipsView:ClearAutoCloseTimerId( )
|
|
if self.auto_close_timer_id then
|
|
GlobalTimerQuest:CancelQuest(self.auto_close_timer_id)
|
|
self.auto_close_timer_id = nil
|
|
end
|
|
end
|
|
|
|
function FortuneCatAdTipsView:DestroySuccess( )
|
|
self:ClearAutoCloseTimerId()
|
|
self.model:SetFcAdViewOpenFlag()
|
|
end
|