local UISpecialLoadingPanel = UIViewClass() local curProgress = 0 -- **************** 通用部分 ******************* -- function UISpecialLoadingPanel:OnCreated() end function UISpecialLoadingPanel:OnOpened() self.targetProgress = 0 curProgress = 0 self:RegisterEvents() self:SetLoadingTips() self:StartRepeatFunc(self.OnUpdateFun, 0) self.progressBar1.value = 0 self.uptoEnterLevel = false -- 是否打开了进入特效 self.isFastPlaying = false -- 是否进入到了快速补帧 --UIUtils.SetActive(self.progressBar3, false) --UIUtils.SetActive(self.progressBar4, false) --开门动作 self.closeId = self:PlayUIAnimation("Close") UIUtils.SetActive(self.effect_ChainLS, true) UIUtils.SetActive(self.effect_ChainRS, true) UIUtils.SetActive(self.effect_ChainTS1, true) UIUtils.SetActive(self.effect_ChainTS2, true) CTL.Sound.PlayGameSound("UI_hero") UTL.UIRender.AdaptiveImageSizeFit(self.img_BgTop, true) UTL.UIRender.AdaptiveImageSizeFit(self.img_BgBottom, true) end function UISpecialLoadingPanel:SetLoadingTips() local tipsNum = DataSheetManager.LoadingTips:GetDataCount() local randomId = CTL.Loading.GetRandomNumber(tipsNum) local tip = DataSheetManager.LoadingTips:GetDataByID(randomId).LoadingTextIDS UIUtils.SetLabelText(self.ProgressLabel, Const_IDS[tip]) end function UISpecialLoadingPanel:RegisterEvents() self:RegistSystemEvent(EventID.UI_Loading_HandleStep, self.HandleLoadStep) end function UISpecialLoadingPanel:OnUpdateFun(deltaTime, timeSinceUpdate) if curProgress > 0 and MDL.Loading.GetIsLoadingState() == false then self:GotoClose() self:StopRepeatFunc(self.OnUpdateFun) end if curProgress >= 0.8 and self.uptoEnterLevel == false then self.uptoEnterLevel = true --播放龙头特效 if self.effect_enter then self.effect_enter:PlayUIEffect() end end end function UISpecialLoadingPanel:HandleLoadStep(step) if step == LuaConst.Enum_LoadingStep.EnterLevel then self:UpdateProgress(1) elseif step == LuaConst.Enum_LoadingStep.FastPlay then if self.isFastPlaying == false then self.isFastPlaying = true --UIUtils.SetActive(self.progressBar3, true) --UIUtils.SetActive(self.progressBar4, true) end local preProgress = CTL.Loading.GetInGameLoadingProgress(step) self:UpdateProgress(preProgress, true) if preProgress > 0.8 then UIUtils.SetLabelText(self.ProgressLabel , Const_IDS.IDS_ConnectingBattle2 )-- 更新进度条下面的文字 else self.ProgressLabel.text = string.format("%s %u %%", UIUtils.GetLocalizedTxt(Const_IDS.IDS_ConnectingBattle1) , math.floor(preProgress*100)) end else local preProgress = CTL.Loading.GetInGameLoadingProgress(step) local curProgressTemp = curProgress if preProgress> curProgressTemp then self:UpdateProgress(preProgress) end end end function UISpecialLoadingPanel:UpdateProgress(value, isFastPlay) if isFastPlay then --self.progressBar3.value = value --self.progressBar4.value = value else self.progressBar1.value = value --self.progressBar2.value = value end curProgress = value local percent = math.floor(value*100) --self.PercentLabel.text = string.format("%u%%",percent) end function UISpecialLoadingPanel:GotoClose() -- 关门动作 - 结束则关闭界面 --UIUtils.SetActive(self.progressBar1, false) --UIUtils.SetActive(self.progressBar2, false) --UIUtils.SetActive(self.progressBar3, false) --UIUtils.SetActive(self.progressBar4, false) UIUtils.SetActive(self.ProgressLabel, false) if self.effect_enter then --self.effect_enter:StopUIEffect() end self.openId = self:PlayUIAnimation("Open", true) UIUtils.SetActive(self.effect_ChainLS, false) UIUtils.SetActive(self.effect_ChainRS, false) UIUtils.SetActive(self.effect_ChainTS1, false) UIUtils.SetActive(self.effect_ChainTS2, false) UIUtils.SetActive(self.effect_ChainLF, true) UIUtils.SetActive(self.effect_ChainRF, true) UIUtils.SetActive(self.effect_ChainTF1, true) UIUtils.SetActive(self.effect_ChainTF2, true) end function UISpecialLoadingPanel:OnUIAnimationStoped(id) if self.openId == id then self:CloseView() end end function UISpecialLoadingPanel:OnClosed() self:UpdateProgress(1) end return UISpecialLoadingPanel