local UIWaitingWithDelayView = UIViewClass() local _rotateSpeed = 3 local maskTime = 2 local EventSystem = require('Event/EventSystem') function UIWaitingWithDelayView:OnCreated() self.isHasUpdate = false self.isHasShowPanel = false end function UIWaitingWithDelayView:OnOpened(context) self:PlayUIAnimation("Alpha_Panel") self:PlayUIAnimation("Alpha_Label") self:PlayUIAnimation(ConstAssetPathConfig.Path33, self.rotate.transform, false) self:RegistSystemEvent(EventID.UI_Refresh_WaitingDelay, self.OnRefresh) self:RegistSystemEvent(EventID.OnNetMsgPaused, self.OnNetMsgPaused) self:OnRefresh(context, true) self:SetPushStyle(LuaConst.PushStyleEnum.CLOSENOTRECOVER) end function UIWaitingWithDelayView:OnRefresh(context, isinit) if context and context.isOnlyShow then UIUtils.SetActive(self.Panel, true) UIUtils.SetActive(self.Mask, false) self.isHasShowPanel = true self.isHasUpdate = false self:StopRepeatFunc(self.OnUpdateFun) else self:InitInfo(context) if isinit or not self.isHasUpdate then if not NetManager.IsNetMsgPaused() then self:StartRepeatFunc(self.OnUpdateFun, 0) end self.isHasUpdate = true else self:ResetRepeatFunc(self.OnUpdateFun) end end end function UIWaitingWithDelayView:InitInfo(context) if context then self.reconnect = context.reconnect if context.text then self.Label.text = context.text end UIUtils.SetActive(self.Panel, true) UIUtils.SetActive(self.Mask, false) self.isHasShowPanel = true else UIUtils.SetActive(self.Panel, false) UIUtils.SetActive(self.Mask, true) self.isHasShowPanel = false end end function UIWaitingWithDelayView:OnUpdateFun(deltaTime, timeSinceUpdate) if self.reconnect then NetManager.AutoReconnect(false) elseif maskTime <= timeSinceUpdate then if not self.isHasShowPanel then UIUtils.SetActive(self.Panel, true) UIUtils.SetActive(self.Mask, false) self.isHasShowPanel = true end end if timeSinceUpdate > NetManager.NetMessageTimeOutMax + 1 then logging.crit(LTAG.CRIT, "UIWaitingWithDelayView界面,长时间重连不上,执行返回登录操作") NetManager.ManualReConnect() if not self.reconnect then EventSystem.Dispatch(EventID.BI_ClientNetState, NetManager.NetStateCode.Disconnect, NetManager.NetStateCode.Normal, NetManager.DisconnectReason.MsgTimeOut) end end end function UIWaitingWithDelayView:OnNetMsgPaused(isPaused) if self.isHasUpdate then if isPaused then self:StopRepeatFunc(self.OnUpdateFun) else self:StartRepeatFunc(self.OnUpdateFun, 0) end end end return UIWaitingWithDelayView