local XUiPanelBossRankInfo = XClass(nil, "XUiPanelBossRankInfo") local XUiPanelMyBossRank = require("XUi/XUiFubenBossSingle/XUiPanelMyBossRank") local XUiPanelRankReward = require("XUi/XUiFubenBossSingle/XUiPanelRankReward") local XUiGridBossRank = require("XUi/XUiFubenBossSingle/XUiGridBossRank") function XUiPanelBossRankInfo:Ctor(rootUi, ui) self.GameObject = ui.gameObject self.Transform = ui.transform self.RootUi = rootUi XTool.InitUiObject(self) self:AutoAddListener() self.PanelRankReward.gameObject:SetActive(false) self.GridRankList = {} self.GridRankLevel.gameObject:SetActive(false) self.GridBossRank.gameObject:SetActive(false) self.TxtCurTime.text = "" self:Init() end function XUiPanelBossRankInfo:RegisterClickEvent(uiNode, func) if func == nil then XLog.Error("XUiPanelBossRankInfo:RegisterClickEvent函数参数错误:参数func不能为空") return end if type(func) ~= "function" then XLog.Error("XUiPanelBossRankInfo:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) end local listener = function(...) func(self, ...) end CsXUiHelper.RegisterClickEvent(uiNode, listener) end function XUiPanelBossRankInfo:AutoAddListener() self:RegisterClickEvent(self.BtnRankReward, self.OnBtnRankRewardClick) end function XUiPanelBossRankInfo:Init() if self.TabBtnGroup then self.TabBtnGroup:Dispose() end self.TabBtnGroup = nil self.BtnTabList = {} self.BtnIndexDic = {} local Cfgs = XDataCenter.FubenBossSingleManager.GetRankLevelCfgs() for i = 1, #Cfgs do if XDataCenter.FubenBossSingleManager.GetRankIsOpenByType(Cfgs[i].LevelType) then local grid = CS.UnityEngine.Object.Instantiate(self.GridRankLevel) grid.transform:SetParent(self.PanelTags, false) grid.gameObject:SetActive(true) table.insert(self.BtnTabList, grid) self.BtnIndexDic[#self.BtnIndexDic + 1] = Cfgs[i].LevelType end end self.TabBtnGroup = XUiTabBtnGroup.New(self.BtnTabList, function(levelType) self:RefreshRankInfo(levelType) end) for k, btn in ipairs(self.TabBtnGroup.TabBtnList) do local type = self.BtnIndexDic[k] local text = CS.XTextManager.GetText("BossSingleRankDesc", Cfgs[type].MinPlayerLevel, Cfgs[type].MaxPlayerLevel) btn:SetName(Cfgs[type].LevelName, text) local icon = btn.Transform:Find("RImgIcon"):GetComponent("RawImage") icon:SetRawImage(Cfgs[type].Icon) self.TabBtnGroup:UnLockIndex(k) end self.MyBossRank = XUiPanelMyBossRank.New(self.RootUi, self.PanelMyBossRank) self.MyBossRank:HidePanel() self.RankReward = XUiPanelRankReward.New(self.RootUi, self.PanelRankReward) end function XUiPanelBossRankInfo:ShowPanel(levelType, rankPlatform) local index = 1 self.CurLevelType = levelType self.RankPlatform = rankPlatform for i = 1, #self.BtnIndexDic do if self.BtnIndexDic[i] == levelType then index = i end end self.TabBtnGroup:SelectIndex(index) self.GameObject:SetActive(true) self.RootUi:PlayAnimation("AnimRankInfolEnable") self:RefreshTime() end function XUiPanelBossRankInfo:HidePanel() self:RemoveTimer() self.GameObject:SetActive(false) end function XUiPanelBossRankInfo:RefreshRankInfo(levelType) local type = self.BtnIndexDic[levelType] or 1 self.CurLevelType = type self.RootUi:PlayAnimation("AnimInfoQieHuan") self:RefreshRank() end function XUiPanelBossRankInfo:RemoveTimer() if self.Timer then XScheduleManager.UnSchedule(self.Timer) self.Timer = nil end end function XUiPanelBossRankInfo:RefreshRank() local func = function(rankData) self:SetRankInfo(rankData) self:RefreshMyRankInfo(rankData) end XDataCenter.FubenBossSingleManager.GetRankData(func, self.CurLevelType) end function XUiPanelBossRankInfo:RefreshTime() local func = function(rankData) self:SetLeftTime(rankData) end XDataCenter.FubenBossSingleManager.GetRankData(func, self.CurLevelType) end function XUiPanelBossRankInfo:SetLeftTime(rankData) local leftTime = rankData.LeftTime if self.Timer then self:RemoveTimer() end self.TxtIos.gameObject:SetActiveEx(false) self.Timer = XScheduleManager.ScheduleForever(function() if XTool.UObjIsNil(self.GameObject) then return end local desc = "BossSingleLeftTimeIos" if self.RankPlatform == XFubenBossSingleConfigs.Platform.Win then desc = "BossSingleLeftTimeWin" elseif self.RankPlatform == XFubenBossSingleConfigs.Platform.Android then desc = "BossSingleLeftTimeAndroid" elseif self.RankPlatform == XFubenBossSingleConfigs.Platform.IOS then desc = "BossSingleLeftTimeIos" elseif self.RankPlatform == XFubenBossSingleConfigs.Platform.All then desc = "BossSingleLeftTimeAll" end self.TxtIos.text = CS.XTextManager.GetText(desc) leftTime = leftTime - 1 if leftTime <= 0 then local dataTime = XUiHelper.GetTime(0) self.TxtCurTime.text = CS.XTextManager.GetText("BossSingleLeftTime", dataTime) self:RemoveTimer() else local dataTime = XUiHelper.GetTime(leftTime) self.TxtCurTime.text = CS.XTextManager.GetText("BossSingleLeftTime", dataTime) end end, 1000) end function XUiPanelBossRankInfo:SetRankInfo(rankData) local count = #rankData.rankData local maxCount = XDataCenter.FubenBossSingleManager.MAX_RANK_COUNT if #rankData.rankData > maxCount then count = maxCount end for i = 1, count do local grid = self.GridRankList[i] if not grid then local ui = CS.UnityEngine.Object.Instantiate(self.GridBossRank) grid = XUiGridBossRank.New(self.RootUi, ui) grid.Transform:SetParent(self.PanelRankContent, false) self.GridRankList[i] = grid end grid:Refresh(rankData.rankData[i], self.CurLevelType) grid.GameObject:SetActive(true) end for i = count + 1, #self.GridRankList do self.GridRankList[i].GameObject:SetActive(false) end self.PanelNoRank.gameObject:SetActive(count <= 0) end function XUiPanelBossRankInfo:RefreshMyRankInfo(rankData) local myLevelType = XDataCenter.FubenBossSingleManager.GetBoosSingleData().LevelType self.MyRankData = { MylevelType = myLevelType, MineRankNum = rankData.MineRankNum, HistoryMaxRankNum = rankData.HistoryMaxRankNum, TotalCount = rankData.TotalCount, } if self.CurLevelType == myLevelType then self.MyBossRank:ShowPanel() self.MyBossRank:Refresh(self.MyRankData) else self.MyBossRank:HidePanel() end end function XUiPanelBossRankInfo:OnBtnRankRewardClick() self.RankReward:ShowPanel(self.CurLevelType, self.MyRankData) end return XUiPanelBossRankInfo