local UIBattleCountDownFormalPanel = UIViewClass() local EventSystem = require('Event/EventSystem') -- @param1倒计时数字 param2倒计时文字 param3关闭界面后回调 param4是否关闭Mask function UIBattleCountDownFormalPanel:OnOpened(context) self:RegistSystemEvent(EventID.UI_UIBattleCountDownPanel_SetNumber , self.SetNumber) UIUtils.SetLabelText(self.Text_Local, Const_IDS.IDS_BattleReady) UIUtils.SetActive(self.Mask, true) if context then if type(context[1]) == 'number' and context[1] > 0 then self.countDownNum = context[1] self:SetNumber(self.countDownNum) self:StartRepeatFunc(self.OnUpdateFun, 1) end if type(context[2]) == 'string' then UIUtils.SetLabelText(self.Text_Local, Const_IDS[context[2]]) end if context[3] then UIUtils.SetActive(self.Mask, false) end end end function UIBattleCountDownFormalPanel:SetNumber(num) if num > 0 then self.number.text = num if self.playSoundTime == nil then self.playSoundTime = UTL.Time.GetServerTimestamp() CTL.Sound.PlayCountDown(num) else local offset = UTL.Time.GetServerTimestamp() - self.playSoundTime if offset > 0.7 then self.playSoundTime = UTL.Time.GetServerTimestamp() CTL.Sound.PlayCountDown(num) end end end end function UIBattleCountDownFormalPanel:OnUpdateFun() self.countDownNum = self.countDownNum - 1 if self.countDownNum <= 0 then self:CloseView() return end self:SetNumber(self.countDownNum) end function UIBattleCountDownFormalPanel:OnClosed() EventSystem.Dispatch(EventID.UI_UIBattleCountDownPanel_CloseEvent) end return UIBattleCountDownFormalPanel