| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377 |
- local MainTopView = class("MainTopView")
- local ScrollNoticeView = require("UIMain/ScrollNoticeView")
- local showAni = "TopShow"
- local closeAni = "TopClose"
- local scrollNoticeView
- local updateHandle
- local curLimitedTime
- local interLimitedTime = 10
- local curRankTime
- function MainTopView:ctor()
- self.root = nil
- self.state = true
- self.animator = nil
- self.mCanvas = nil
- self.lastSortingOrder = 0
- self.defaultSortingOrder = 0
- end
- function MainTopView:Init(root, canvas, animator, sortingOrder)
- self.root = root
- self.mCanvas = canvas
- self.animator = animator
- self.defaultSortingOrder = sortingOrder
- self.lastSortingOrder = self.defaultSortingOrder
- if not scrollNoticeView then
- scrollNoticeView = ScrollNoticeView.new()
- scrollNoticeView:Init(self.root.noticeBg)
- end
- self:StartUpdate()
- self:InitBtnState()
- end
- function MainTopView:InitBtnState()
- self.root.topRoot.btnActivityTower:SetActive(false)
- self.root.topRoot.btnActivityDojo:SetActive(false)
- self.root.topRoot.btnActivityMap:SetActive(false)
- self.root.topRoot.btnActivityPet:SetActive(false)
- --开发阶段 打开主页面上的战令系统
- self.root.topRoot.btnAirshipRewards:SetActive(false)
- self.root.topRoot.btnActivitySkill:SetActive(false)
- self:ChangeRefreshCombineServerBtn()
- end
- function MainTopView:StartUpdate()
- if not updateHandle then
- updateHandle = UpdateBeat:CreateListener(self.Update, self)
- end
- UpdateBeat:AddListener(updateHandle)
- curLimitedTime = 0
- curRankTime = 0
- end
- function MainTopView:EndUpdate()
- if updateHandle ~= nil then
- UpdateBeat:RemoveListener(updateHandle)
- updateHandle = nil
- end
- end
- function MainTopView:Change(state, order)
- if self.mCanvas == nil then return end
- if state then
- if ManagerContainer.LuaUIMgr:NeedMainHideTop() then
- return
- end
- end
- if state then
- self.lastSortingOrder = self.mCanvas.sortingOrder
- self.mCanvas.sortingOrder = math.max(1000, (order or 1000) + 1)
- self:RefreshTopBtns(true)
- else
- self.mCanvas.sortingOrder = self.lastSortingOrder
- self:RefreshTopBtns(false)
- end
- if self.state ~= state then
- self.state = state
- self.animator:Play(state and showAni or closeAni, 0, 0)
- self:ChangeRefreshCombineServerBtn()
- end
- end
- function MainTopView:Resume()
- if self.mCanvas == nil then return end
- self.mCanvas.sortingOrder = self.defaultSortingOrder
- self.state = false
- self.animator:Play(closeAni)
- end
- function MainTopView:Update()
- if self.limitState and self.root and curLimitedTime then
- curLimitedTime = curLimitedTime + Time.deltaTime
- if curLimitedTime >= interLimitedTime then
- curLimitedTime = 0
- self:RefreshLimitEndTime()
- end
- end
- end
- function MainTopView:RefreshTopBtns(state)
- self.root.topRoot.topBtns:SetActive(state)
- if state then
- local _unlockState = ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(34);
- if _unlockState then
- self.root.topRoot.btnTask.gameObject:SetActive(state);
- end
- if Constant.OpenPay then
- local limitRechargeData = ManagerContainer.DataMgr.ActsDataMgr:GetLimitRechargeItem()
- if limitRechargeData then
- local isExist = limitRechargeData:IsLimitRechargeExist()
- self.root.topRoot.btnLimitedGift:SetActive(isExist)
- self.limitState = true
- else
- self.root.topRoot.btnLimitedGift:SetActive(false)
- self.limitState = false
- end
- else
- self.root.topRoot.btnLimitedGift:SetActive(false)
- self.limitState = false
- end
- _unlockState = ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(59);
- if _unlockState then
- local rewardState = ManagerContainer.DataMgr.UserData:GetQuestionRewardState()
- self.root.topRoot.btnQuestionnaire:SetActive(not rewardState)
- else
- self.root.topRoot.btnQuestionnaire:SetActive(false)
- end
- else
- self.root.topRoot.btnLimitedGift:SetActive(false)
- self.limitState = false
- end
- end
- function MainTopView:OpenLimitRecharge()
- --local _unlockState = ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(34);
- --if not _unlockState then
- -- self.root.topRoot.btnTask.gameObject:SetActive(false);
- -- self.limitState = false
- -- return
- --end
- if not Constant.OpenPay then
- self.root.topRoot.btnLimitedGift:SetActive(false)
- self.limitState = false
- return
- end
- local limitRechargeData = ManagerContainer.DataMgr.ActsDataMgr:GetLimitRechargeItem()
- if not limitRechargeData then
- self.limitState = false
- self.root.topRoot.btnLimitedGift:SetActive(false)
- return
- end
- local isExist = limitRechargeData:IsLimitRechargeExist()
- self.root.topRoot.btnLimitedGift:SetActive(isExist)
- if not isExist then
- self.limitState = false
- return
- else
- self.limitState = true
- end
- end
- function MainTopView:RefreshLimitEndTime()
- local limitRechargeData = ManagerContainer.DataMgr.ActsDataMgr:GetLimitRechargeItem()
- if not limitRechargeData then return end
- local isExist = limitRechargeData:IsLimitRechargeExist()
- if not isExist then
- self.limitState = false
- self.root.topRoot.btnLimitedGift:SetActive(false)
- return
- end
- end
- function MainTopView:RefreshAirShipActivityEnter(state)
- if state then
- local unlockState = ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(54)
- if not unlockState then
- state = false
- end
- end
- if not Constant.OpenPay then
- state = false
- end
- --LogError('222'..tostring(state))
- self.root.topRoot.btnAirshipRewards:SetActive(state)
- if not state then
- return
- end
- self:RefreshAirShipActivityEndTime()
- end
- function MainTopView:RefreshAirShipActivityEndTime()
- local endTime = ManagerContainer.DataMgr.RuneShopDataMgr:GetCurAirShipActivityEndTime()
- if not endTime then
- return
- end
- local text
- text = self.root.topRoot.btnAirshipRewards.textTime
- -- text.text.text = ManagerContainer.LuaTimerMgr:ParseEndTimeStamp2TimeWithUInt64(endTime)
- local remains = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(endTime, false)
- --LogError("时间"..remains)
- if remains > 0 then
- if remains <= 60 then
- text.text.text = I18N.T("LessOneMinu")
- else
- local time = DateTimeUtil.convertSeconds2TimeStr1(remains, true, false)
- text.text.text = time
- end
- end
- end
- function MainTopView:RefreshRankActivityEnter(type, state)
- if type == Enum.RankActivitiesType.ClimbingTower then
- if state then
- local unlockState = ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(60)
- if not unlockState then
- state = false
- end
- end
- self.root.topRoot.btnActivityTower:SetActive(state)
- elseif type == Enum.RankActivitiesType.Dojo then
- if state then
- local unlockState = ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(61)
- if not unlockState then
- state = false
- end
- end
- self.root.topRoot.btnActivityDojo:SetActive(state)
- elseif type == Enum.RankActivitiesType.MapProgress then
- if state then
- local unlockState = ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(64)
- if not unlockState then
- state = false
- end
- end
- self.root.topRoot.btnActivityMap:SetActive(state)
- elseif type == Enum.RankActivitiesType.Pet then
- if state then
- local unlockState = ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(71)
- if not unlockState then
- state = false
- end
- end
- self.root.topRoot.btnActivityPet:SetActive(state)
- elseif type == Enum.RankActivitiesType.Skill then
- if state then
- local unlockState = ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(71)
- if not unlockState then
- state = false
- end
- end
- self.root.topRoot.btnActivitySkill:SetActive(state)
- end
- self:RefreshRankActivityEndTime()
- end
- function MainTopView:RefreshRankActivityEndTime()
- for k,v in pairs(Enum.RankActivitiesType) do
- local type = v
- local stage, endTime, inRush = ManagerContainer.DataMgr.RankActivitiesMgr:GetCurRankActivityStageEndTime(type)
- if inRush then
- local text
- if type == Enum.RankActivitiesType.ClimbingTower then
- text = self.root.topRoot.btnActivityTower.textTime
- elseif type == Enum.RankActivitiesType.Dojo then
- text = self.root.topRoot.btnActivityDojo.textTime
- elseif type == Enum.RankActivitiesType.MapProgress then
- text = self.root.topRoot.btnActivityMap.textTime
- elseif type == Enum.RankActivitiesType.Pet then
- text = self.root.topRoot.btnActivityPet.textTime
- elseif type == Enum.RankActivitiesType.Skill then
- text = self.root.topRoot.btnActivitySkill.textTime
- end
- local remainS = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(endTime, false)
- if stage == 1 then
- if remainS <= 0 then
- ManagerContainer.DataMgr.RankActivitiesMgr:QueryRankActivitiesData()
- elseif remainS <= 60 then
- text.text.text = I18N.T("LessOneMinu")
- else
- local time = DateTimeUtil.convertSeconds2TimeStr1(remainS, true, false)
- text.text.text = time
- end
- elseif stage == 2 then
- text.text.text = I18N.T("RushBtnEnd")
- end
- end
- end
- end
- function MainTopView:InsertGMNotice(notice)
- if scrollNoticeView then
- scrollNoticeView:InsertGMNotice(notice)
- end
- end
- function MainTopView:ChangeRefreshCombineServerBtn()
- local nextTime = ManagerContainer.DataMgr.CombineServerDataMgr:GetNextTime()
- self.root.topRoot.btnCombineService:SetActive(nextTime and nextTime > 0)
- if not self.state then
- if self.combineServerTimer and self.combineServerTimer.running then
- self.combineServerTimer:Stop()
- end
- else
- self:RefreshCombineServerBtn()
- end
- end
- function MainTopView:DisposeRefreshCombineServerBtn()
- if self.combineServerTimer then
- if self.combineServerTimer.running then
- self.combineServerTimer:Stop()
- end
- self.combineServerTimer = nil
- end
- end
- function MainTopView:RefreshCombineServerBtn()
- local nextTime = ManagerContainer.DataMgr.CombineServerDataMgr:GetNextTime()
- if not nextTime or nextTime <= 0 then
- self:DisposeRefreshCombineServerBtn()
- self.root.topRoot.btnCombineService.textTime.text.text = string.formatbykey('CombinedServiceTips', 1)
- return
- end
- local remainS = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(nextTime)
- if remainS < 86400 then
- self:DisposeRefreshCombineServerBtn()
- self.root.topRoot.btnCombineService.textTime.text.text = string.formatbykey('CombinedServiceTips', 1)
- return
- end
- if not self.combineServerTimer then
- self.combineServerTimer = Timer.New(slot(self.RefreshCombineServerBtn, self), 86400, -1, true)
- end
- self.combineServerTimer.time = remainS % 86400 + 1
- if not self.combineServerTimer.running then
- self.combineServerTimer:Start()
- end
- self.root.topRoot.btnCombineService.textTime.text.text = string.formatbykey('CombinedServiceTips', Mathf.Ceil(remainS / 86400))
- end
- function MainTopView:Dispose()
- self:EndUpdate()
- self:DisposeRefreshCombineServerBtn()
- scrollNoticeView:Dispose()
- scrollNoticeView = nil
- self.animator = nil
- self.mCanvas = nil
- self.trans = nil
- end
- return MainTopView
|