GuideTaskLimitView = GuideTaskLimitView or BaseClass(BaseView)
|
|
|
|
function GuideTaskLimitView:__init()
|
|
self.base_file = "guide"
|
|
self.layout_file = "GuideTaskLimitView"
|
|
self.layer_name = "Top"
|
|
self.close_mode = CloseMode.CloseDestroy
|
|
self.destroy_imm = true
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
self:InitEvent()
|
|
end
|
|
self.open_callback = function ()
|
|
self.diff_time = 10
|
|
GlobalEventSystem:Fire(EventName.STOP_AUTO_DO_TASK)
|
|
self:StartTimer()
|
|
end
|
|
self.close_callback = function ()
|
|
|
|
GlobalEventSystem:Fire(EventName.START_AUTO_DO_TASK)
|
|
end
|
|
self.destroy_callback = function ()
|
|
self:Clear()
|
|
end
|
|
end
|
|
|
|
function GuideTaskLimitView:Clear()
|
|
self:StopTimer()
|
|
end
|
|
|
|
function GuideTaskLimitView:LoadSuccess()
|
|
self.sureBtn = self:GetChild("sureBtn").gameObject
|
|
self.label = self:GetChild("sureBtn/Text"):GetComponent("Text")
|
|
end
|
|
|
|
function GuideTaskLimitView:InitEvent()
|
|
local function clickHandler(target)
|
|
self:Close()
|
|
end
|
|
AddClickEvent(self.sureBtn, clickHandler)
|
|
end
|
|
|
|
function GuideTaskLimitView:StartTimer()
|
|
local function onTimer()
|
|
if self.diff_time < 0 then
|
|
self:Close()
|
|
else
|
|
self.label.text = string.format("确定(%d)", self.diff_time)
|
|
self.diff_time = self.diff_time - 1
|
|
end
|
|
end
|
|
if not self.timer_id then
|
|
self.timer_id = GlobalTimerQuest:AddPeriodQuest(onTimer,1,-1)
|
|
end
|
|
end
|
|
|
|
function GuideTaskLimitView:StopTimer()
|
|
self.label.text = ""
|
|
if self.timer_id then
|
|
GlobalTimerQuest:CancelQuest(self.timer_id)
|
|
self.timer_id = nil
|
|
end
|
|
end
|