local UIRedEnvelopeRainCountDown = UIViewClass() local RedEnvelopeRainDuration = DataSheetManager.ConstData:GetDataByID("RedEnvelopeRainDuration").IntValue -------------------- function UIRedEnvelopeRainCountDown:OnOpened(context) self:RegistSystemEvent(EventID.RedEnvelope_RefreshCountDown, self.RefreshCountDown) -- 打开界面时停止自动寻路 防止抽卡TimeLine和剧情重叠 NotSyncBattleSetter.StopAutoFightPathInTown() --停止现在的寻路 CTL.Level.TryBreakConveyProgress() --打断传送 -- 玩家不在队伍中 & 在匹配状态 则取消匹配 if not CTL.Team.IsInTeam() then CTL.TeamMatch.CancelCurMatch() end self:RefreshCountDown() self:OnUpdateCountDownTime(0, 0) end -------------------- function UIRedEnvelopeRainCountDown:RefreshCountDown() self:StartRepeatFunc(self.OnUpdateCountDownTime, 1) end function UIRedEnvelopeRainCountDown:OnUpdateCountDownTime(deltaTime, timeSinceUpdate) local residueTime = MDL.RedEnvelopRain.GetRemainSecond() - RedEnvelopeRainDuration - timeSinceUpdate UIUtils.SetLabel(self.txt_Num, math.ceil(residueTime)) if residueTime <= 0 then self:CloseView(true) UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIRedEnvelopeRainStart) end end return UIRedEnvelopeRainCountDown