|
|
@@ -23,6 +23,13 @@ function UIWaitingView:FillContent(data, uiBase)
|
|
|
end
|
|
|
|
|
|
function UIWaitingView:Init()
|
|
|
+ --LogError("Type = "..self.controller.NoticeType)
|
|
|
+ self.noticeRoot:SetActive(self.controller.NoticeType >= 0)
|
|
|
+ if self.controller.NoticeType == 1 then -- 普通
|
|
|
+ self.notice.text.text = self.controller.NoticeText
|
|
|
+ elseif self.controller.NoticeType == 2 then --计时
|
|
|
+ self:AutoPlayTimer()
|
|
|
+ end
|
|
|
end
|
|
|
|
|
|
function UIWaitingView:RemoveEventListener()
|
|
|
@@ -36,7 +43,10 @@ function UIWaitingView:AddUIEventListener()
|
|
|
end
|
|
|
|
|
|
function UIWaitingView:OnHide()
|
|
|
-
|
|
|
+ if self.curTimer then
|
|
|
+ ManagerContainer.LuaTimerMgr:RemoveTimer(self.curTimer)
|
|
|
+ self.curTimer = nil
|
|
|
+ end
|
|
|
end
|
|
|
|
|
|
function UIWaitingView:OnShow(data)
|
|
|
@@ -45,6 +55,10 @@ function UIWaitingView:OnShow(data)
|
|
|
end
|
|
|
|
|
|
function UIWaitingView:OnClose()
|
|
|
+ if self.curTimer then
|
|
|
+ ManagerContainer.LuaTimerMgr:RemoveTimer(self.curTimer)
|
|
|
+ self.curTimer = nil
|
|
|
+ end
|
|
|
|
|
|
end
|
|
|
|
|
|
@@ -53,5 +67,47 @@ function UIWaitingView:OnDispose()
|
|
|
|
|
|
end
|
|
|
|
|
|
+
|
|
|
+function UIWaitingView:AutoPlayTimer()
|
|
|
+ self.maxTime = self.controller.TimeData[1]
|
|
|
+ self.dtTime = self.controller.TimeData[2]
|
|
|
+ self.TimerCount = math.ceil(self.maxTime/self.dtTime)
|
|
|
+ self.EndTimerCb = self.controller.TimeData[3]
|
|
|
+ self.EndTimerCbParams = self.controller.TimeData[4]
|
|
|
+ self.curTime =0
|
|
|
+ self.curTimer = nil
|
|
|
+
|
|
|
+ --LogError("maxTime = "..self.maxTime.." dtTime = "..self.dtTime.." TimerCount = "..self.TimerCount)
|
|
|
+ self:StartTimer()
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+function UIWaitingView:StartTimer()
|
|
|
+
|
|
|
+ self.notice.text.text = string.formatbykey(self.controller.NoticeText,tostring(self.maxTime))
|
|
|
+ self.curTimer = ManagerContainer.LuaTimerMgr:AddLuaTimer(self.dtTime * 1000, self.TimerCount,function ()
|
|
|
+ self:UpdateTimer()
|
|
|
+ end, nil)
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+function UIWaitingView:UpdateTimer()
|
|
|
+ self.curTime = self.curTime + 1
|
|
|
+ --self.timersTxt.text.text = tostring(self.maxTime - self.curTime)
|
|
|
+ --string.formatbykey('WalletGold',price)--tostring(price)
|
|
|
+-- if self.notice then
|
|
|
+-- self.notice.text.text = string.formatbykey(self.controller.NoticeText,
|
|
|
+-- tostring(self.maxTime - (self.dtTime * self.curTime)))
|
|
|
+-- end
|
|
|
+
|
|
|
+
|
|
|
+ self.notice.text.text = string.formatbykey(self.controller.NoticeText,tostring(self.maxTime - (self.dtTime* self.curTime)))
|
|
|
+ if (self.TimerCount <= self.curTime) then
|
|
|
+ ManagerContainer.LuaTimerMgr:RemoveTimer(self.curTimer)
|
|
|
+ self.curTimer = nil
|
|
|
+ self.EndTimerCb(self.EndTimerCbParams)
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
return UIWaitingView
|
|
|
|