----- 公会十绝阵排行弹窗 ----- require("Base/BasePanel") local XuanYuanMirrorRankPopup = Inherit(BasePanel) local this = XuanYuanMirrorRankPopup function XuanYuanMirrorRankPopup:InitComponent() this.spLoader = SpriteLoader.New() this.panel=Util.GetGameObject(this.gameObject,"Panel") this.backBtn=Util.GetGameObject(this.panel,"BackBtn") this.rankScroll=Util.GetGameObject(this.panel,"Scroll/Root") this.rankPre=Util.GetGameObject(this.panel,"Scroll/Root/Pre") this.scrollView=SubUIManager.Open(SubUIConfig.ScrollCycleView,this.rankScroll.transform,this.rankPre, nil, Vector2.New(this.rankScroll.transform.rect.width,this.rankScroll.transform.rect.height),1,1,Vector2.New(0,10)) this.scrollView.gameObject:GetComponent("RectTransform").anchoredPosition= Vector2.New(0,0) this.scrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5) this.scrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5) this.scrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5) this.scrollView.moveTween.MomentumAmount = 1 this.scrollView.moveTween.Strength = 2 --我的排名 this.mRRank=Util.GetGameObject(this.panel,"MyInfo") this.mRName=Util.GetGameObject(this.mRRank,"Grid/Name"):GetComponent("Text") this.mRNum=Util.GetGameObject(this.mRRank,"Grid/Num"):GetComponent("Text") this.empty=Util.GetGameObject(this.panel,"Scroll/Empty") end function XuanYuanMirrorRankPopup:BindEvent() Util.AddClick(this.backBtn,function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) self:ClosePanel() end) end function XuanYuanMirrorRankPopup:OnOpen(...) end function XuanYuanMirrorRankPopup:OnShow() this.RefreshRank() end function XuanYuanMirrorRankPopup:OnClose() this.empty:SetActive(false) end function XuanYuanMirrorRankPopup:OnDestroy() this.spLoader:Destroy() this.scrollView=nil end --刷新排行榜 index当前排行类型索引 function this.RefreshRank() -- NetManager.RequestRankInfo(RANK_TYPE.XUANYUANMIRROR_RANK,function(msg) -- this.empty:SetActive(#msg.ranks <= 0) -- for i=1,#msg.ranks do -- --LogGreen("msg.ranks[i].userName:"..msg.ranks[i].userName.."msg.ranks[i].rankInfo.rank:"..msg.ranks[i].rankInfo.rank.."msg.ranks[i].rankInfo.param1:"..msg.ranks[i].rankInfo.param1) -- end -- --LogGreen("msg.myRankInfo:"..PlayerManager.nickName.."msg.myRankInfo.rank:"..msg.myRankInfo.rank.."msg.myRankInfo.param1:"..msg.myRankInfo.param1) -- this.scrollView:SetData(msg.ranks,function(index,root) -- this.SetScrollPre(root,msg.ranks[index]) -- end) -- this.scrollView:SetIndex(1) -- this.mRRank.gameObject:SetActive((not msg.myRankInfo) or msg.myRankInfo.rank~=-1) -- if msg.myRankInfo and msg.myRankInfo.rank ~= -1 then -- this.SetMyRank(msg.myRankInfo) -- end -- end) RankingManager.InitData(RANK_TYPE.XUANYUANMIRROR_RANK,function() local ranks,myRankInfo = RankingManager.GetRankingInfo() this.empty:SetActive(#ranks <= 0) this.SetScrollView(ranks) this.scrollView:SetIndex(1) this.mRRank.gameObject:SetActive((not myRankInfo) or myRankInfo.rank~=-1) if myRankInfo and myRankInfo.rank ~= -1 then this.SetMyRank(myRankInfo) end end,nil,1) end function this.SetScrollView(ranks) this.scrollView:SetData(ranks,function(index,root) this.SetScrollPre(root,ranks[index]) if index==#ranks then RankingManager.RequestNextWarPowerPageData(function() local ranks,myRankInfo = RankingManager.GetRankingInfo() this.SetScrollView(ranks) end) end end) end --设置每条数据 function this.SetScrollPre(root,data) local name=Util.GetGameObject(root,"Grid/Name"):GetComponent("Text") local num=Util.GetGameObject(root,"Grid/Num"):GetComponent("Text") this.SetRankingNum(root,data.rankInfo.rank,false) name.text=data.userName num.text=data.rankInfo.param1 end --设置我的名次 function this.SetMyRank(data,curRankType) this.SetRankingNum(this.mRRank,data.rank,true) this.mRName.text = PlayerManager.nickName this.mRNum.text = data.param1 end --设置名次 isMy 是否是设置我的名次 function this.SetRankingNum(root,rank,isMy) local sortNumTabs={} for i = 1, 4 do sortNumTabs[i]=Util.GetGameObject(root,"SortNum/SortNum ("..i..")") sortNumTabs[i]:SetActive(false) end if rank < 4 then sortNumTabs[rank]:SetActive(true) else sortNumTabs[4]:SetActive(true) if rank > 100 and isMy then rank="100+" end Util.GetGameObject(sortNumTabs[4], "TitleText"):GetComponent("Text").text = rank end end return XuanYuanMirrorRankPopup