require("Base/BasePanel") RankingListMainPanel = Inherit(BasePanel) local this = RankingListMainPanel local curIndex = 1 local rankKingListGo = {} local TabBox = require("Modules/Common/TabBox") local _TabData={ [1] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001",lock = "r_hero_xuanze_002", name = "本服排行" }, [2] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001",lock = "r_hero_xuanze_002", name = "跨服排行" }, } local _TabFontColor = { default = Color.New(130 / 255, 128 / 255, 120 / 255, 1), select = Color.New(243 / 255, 235 / 255, 202 / 255, 1), lock = Color.New(130 / 255, 128 / 255, 120 / 255, 1), } local ranks = {} local proud = {} this.playerScrollHead = {}--排行第一头像 --初始化组件(用于子类重写) function RankingListMainPanel:InitComponent() this.tabBox = Util.GetGameObject(self.gameObject, "TabBox") this.TabCtrl = TabBox.New() this.BackBtn = Util.GetGameObject(self.gameObject, "bg/btnBack") this.ItemPre = Util.GetGameObject(self.gameObject, "bg/panel/ItemPre") this.grid = Util.GetGameObject(self.gameObject, "bg/panel/ScrollParentView/grid") end --绑定事件(用于子类重写) function RankingListMainPanel:BindEvent() Util.AddClick(this.BackBtn, function() self:ClosePanel() end) end --添加事件监听(用于子类重写) function RankingListMainPanel:AddListener() end --移除事件监听(用于子类重写) function RankingListMainPanel:RemoveListener() end --界面打开时调用(用于子类重写) function RankingListMainPanel:OnOpen(msg) ranks = msg.ranks end --界面打开或者重新打开后,界面刷新时调用(用于子类重写) function RankingListMainPanel:OnShow() this.TabCtrl:SetTabAdapter(this.TabAdapter) this.TabCtrl:SetChangeTabCallBack(this.SwitchView) this.TabCtrl:SetTabIsLockCheck(this.PageTabIsLockCheck) this.TabCtrl:Init(this.tabBox, _TabData, curIndex) end -- tab节点显示自定义 function this.TabAdapter(tab, index, status) local tabLab = Util.GetGameObject(tab, "Text") Util.GetGameObject(tab,"Image"):GetComponent("Image").sprite = Util.LoadSprite(_TabData[index][status]) tabLab:GetComponent("Text").text = _TabData[index].name tabLab:GetComponent("Text").color = _TabFontColor[status] Util.GetGameObject(tab, "LockImage"):SetActive(status == "lock" ) end-- tab可用性检测 function this.PageTabIsLockCheck(index) if index == 2 then return true ,"服务器未划分跨服分组!" else return false end end --切换视图 function this.SwitchView(index) curIndex = index proud = RankingManager.GetRankProud() --先执行上一面板关闭逻辑 for i = 1, math.max(#rankKingListGo, #rankKingList) do if rankKingList[i].isRankingMainPanelShow then local go = rankKingListGo[i] if not go then go=newObject(this.ItemPre) go.transform:SetParent(this.grid.transform) go.transform.localScale = Vector3.one go.transform.localPosition=Vector3.zero; rankKingListGo[i] = go end go.gameObject:SetActive(false) end end for i = 1, #rankKingList do if rankKingList[i].isRankingMainPanelShow then rankKingListGo[i]:SetActive(true) this.SingleRankKingListShow(i) end end end function this.SingleRankKingListShow(index) local go = rankKingListGo[index] local sData = rankKingList[index] local dData = ranks[index] local proud = proud[sData.rankType] Util.GetGameObject(go,"BG"):GetComponent("Image").sprite = Util.LoadSprite(sData.bgImage) Util.GetGameObject(go,"heor"):SetActive(dData.uid ~= 0 ) if dData.uid ~= 0 then this.SetInfoShow(Util.GetGameObject(go,"heor/infoGo"),dData,sData.rankType,Util.GetGameObject(go,"heor/nameText")) --头像 local headObj=Util.GetGameObject(go,"heor/Head") if not this.playerScrollHead[go] then this.playerScrollHead[go]=CommonPool.CreateNode(POOL_ITEM_TYPE.PLAYER_HEAD,headObj) end this.playerScrollHead[go]:Reset() this.playerScrollHead[go]:SetHead(dData.head) this.playerScrollHead[go]:SetFrame(dData.headFrame) this.playerScrollHead[go]:SetLevel(dData.level) this.playerScrollHead[go]:SetScale(Vector3.one*0.6) this.playerScrollHead[go]:SetLayer(this.sortingOrder) this.playerScrollHead[go]:SetEffectScale(0.7) end --膜拜 local clickBtn = Util.GetGameObject(go,"clickBtn") local getRewardBtn = Util.GetGameObject(go,"getRewardBtn") local getRewardBtnText = Util.GetGameObject(go,"getRewardBtn/Text"):GetComponent("Text") getRewardBtn:SetActive(dData.uid ~= 0 ) Util.SetGray(getRewardBtn,proud ~= 0) Util.AddOnceClick(clickBtn, function() UIManager.OpenPanel(UIName.RankingSingleListPanel,sData) end) if proud == 0 then--没有膜拜过 getRewardBtn:GetComponent("Button").enabled = true Util.GetGameObject(go,"getRewardBtn/redPoint"):SetActive(true) getRewardBtnText.text = "膜 拜" Util.AddOnceClick(getRewardBtn, function() NetManager.RankProudRequest(sData.rankType,function () RankingManager.SetSingleRankProud(sData.rankType,1) local spFata = ConfigManager.GetConfigData(ConfigName.SpecialConfig,50) local itemData = string.split(spFata.Value, "#") PopupTipPanel.ShowTip("膜拜成功,获得"..ConfigManager.GetConfigData(ConfigName.ItemConfig,tonumber(itemData[1])).Name.."×"..itemData[2].."!") this.SwitchView(curIndex) CheckRedPointStatus(RedPointType.RankingSort) end) end) else getRewardBtn:GetComponent("Button").enabled = false getRewardBtnText.text = "已膜拜" Util.GetGameObject(go,"getRewardBtn/redPoint"):SetActive(false) end end --界面关闭时调用(用于子类重写) function RankingListMainPanel:OnClose() end --界面销毁时调用(用于子类重写) function RankingListMainPanel:OnDestroy() for _, playerHead in ipairs(this.playerScrollHead) do playerHead:Recycle() end this.playerScrollHead = {} rankKingListGo = {} end function this.SetInfoShow(go,data,rankType,nameText) local fight = Util.GetGameObject(go,"fight") local warPower = Util.GetGameObject(go,"warPower") local trial = Util.GetGameObject(go,"trial") fight:SetActive(false) warPower:SetActive(false) trial:SetActive(false) if rankType == RANK_TYPE.FIGHT_LEVEL_RANK then fight:SetActive(true) if nameText then nameText:GetComponent("Text").text = data.userName end Util.GetGameObject(go,"fight"):GetComponent("Text").text = ConfigManager.GetConfigData(ConfigName.MainLevelConfig,data.rankInfo.param1).Name elseif rankType == RANK_TYPE.FORCE_CURR_RANK then warPower:SetActive(true) if nameText then nameText:GetComponent("Text").text = data.userName end Util.GetGameObject(go,"warPower/Text"):GetComponent("Text").text = data.rankInfo.param1--data.force elseif rankType == RANK_TYPE.GUILD_FORCE_RANK then warPower:SetActive(true) if nameText then nameText:GetComponent("Text").text = data.guildName end Util.GetGameObject(go,"warPower/Text"):GetComponent("Text").text = data.rankInfo.param1 elseif rankType == RANK_TYPE.MONSTER_RANK then trial:SetActive(true) if nameText then nameText:GetComponent("Text").text = data.userName end Util.GetGameObject(go,"trial/Text"):GetComponent("Text").text = data.rankInfo.param1 end end return RankingListMainPanel