miduo_client/Assets/ManagedResources/~Lua/Modules/Ranking/RankingListPanel.lua

517 lines
20 KiB
Lua

require("Base/BasePanel")
RankingListPanel = Inherit(BasePanel)
local this = RankingListPanel
--Tab
local TabBox = require("Modules/Common/TabBox")
local _tabImageData={select="r_tongyong_xiaanniu_01",default="r_tongyong_xiaanniu_02",lock="r_Dungeon_lockon"}
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)}
--头像
this.heads={}
this.playerHeadList = {}--背景前三头像
this.playerScrollHead={}--滚动条头像
--初始化组件(用于子类重写)
function RankingListPanel:InitComponent()
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft })
this.backBtn=Util.GetGameObject(self.gameObject,"BackBtn")
this.tabBox = Util.GetGameObject(self.gameObject, "TabBox")
for i = 1, 3 do
this.heads[i]=Util.GetGameObject(self.gameObject,"Heads/Name"..i)
end
this.name1=Util.GetGameObject(self.gameObject,"Heads/Name1/Text"):GetComponent("Text")
this.name2=Util.GetGameObject(self.gameObject,"Heads/Name2/Text"):GetComponent("Text")
this.name3=Util.GetGameObject(self.gameObject,"Heads/Name3/Text"):GetComponent("Text")
this.scrollParentView=Util.GetGameObject(self.gameObject,"RankList/ScrollParentView")
this.itemPre=Util.GetGameObject(self.gameObject,"RankList/ScrollParentView/ItemPre")
this.scrollView=SubUIManager.Open(SubUIConfig.ScrollCycleView,this.scrollParentView.transform,this.itemPre,
nil,Vector2.New(903,911),1,1,Vector2.New(0,0))
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.titleName=Util.GetGameObject(self.gameObject,"RankList/ScrollTitleRoot/Name"):GetComponent("Text")
this.titleInfo=Util.GetGameObject(self.gameObject,"RankList/ScrollTitleRoot/Info"):GetComponent("Text")
this.record=Util.GetGameObject(self.gameObject,"RankList/Record")
this.info0=Util.GetGameObject(this.record,"Info0"):GetComponent("Text")
this.rank0=Util.GetGameObject(this.record,"Rank0"):GetComponent("Text")
this.info1=Util.GetGameObject(this.record,"Info1"):GetComponent("Text")
this.rank1=Util.GetGameObject(this.record,"Rank1"):GetComponent("Text")
this.noneImage=Util.GetGameObject(self.gameObject,"RankList/NoneImage")--无信息图片
end
--绑定事件(用于子类重写)
function RankingListPanel:BindEvent()
--返回按钮
Util.AddClick(this.backBtn,function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function RankingListPanel:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.RankingList.OnWarPowerChange, this.SetWarPowerInfo)
Game.GlobalEvent:AddEvent(GameEvent.RankingList.OnArenaChange, this.SetArenaInfo)
Game.GlobalEvent:AddEvent(GameEvent.RankingList.OnTrialChange, this.SetTrialInfo)
Game.GlobalEvent:AddEvent(GameEvent.RankingList.OnMonsterChange, this.SetMonsterInfo)
Game.GlobalEvent:AddEvent(GameEvent.RankingList.OnAdventureChange, this.SetAdventureInfo)
Game.GlobalEvent:AddEvent(GameEvent.RankingList.OnCustomsPassChange,this.SetCustomsPassInfo)
end
--移除事件监听(用于子类重写)
function RankingListPanel:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.RankingList.OnWarPowerChange, this.SetWarPowerInfo)
Game.GlobalEvent:RemoveEvent(GameEvent.RankingList.OnArenaChange, this.SetArenaInfo)
Game.GlobalEvent:RemoveEvent(GameEvent.RankingList.OnTrialChange, this.SetTrialInfo)
Game.GlobalEvent:RemoveEvent(GameEvent.RankingList.OnMonsterChange, this.SetMonsterInfo)
Game.GlobalEvent:RemoveEvent(GameEvent.RankingList.OnAdventureChange, this.SetAdventureInfo)
Game.GlobalEvent:RemoveEvent(GameEvent.RankingList.OnCustomsPassChange, this.SetCustomsPassInfo)
end
--界面打开时调用(用于子类重写)
function RankingListPanel:OnOpen(...)
SoundManager.PlayMusic(SoundConfig.BGM_Rank)
--设置信息方法的列表
this.SetInfoFuncList ={
[FUNCTION_OPEN_TYPE.ALLRANKING] = this.SetWarPowerInfo,
[FUNCTION_OPEN_TYPE.ARENA] = this.SetArenaInfo,
[FUNCTION_OPEN_TYPE.TRIAL] = this.SetTrialInfo,
[FUNCTION_OPEN_TYPE.MONSTER_COMING] = this.SetMonsterInfo,
[FUNCTION_OPEN_TYPE.FIGHT_ALIEN] = this.SetAdventureInfo,
[FUNCTION_OPEN_TYPE.CUSTOMSPASS] = this.SetCustomsPassInfo,
}
this.tabCtrl=TabBox.New()
this.tabCtrl:SetTabAdapter(this.TabAdapter)
this.tabCtrl:SetTabIsLockCheck(this.CheckTabCtrlIsLockP)
this.tabCtrl:SetChangeTabCallBack(this.GetRankInfo)
this.tabCtrl:Init(this.tabBox, RankingManager.GetTabTextData())
RankingManager.ClearData()
--默认打开
if this.tabCtrl then
this.tabCtrl:ChangeTab(1)
end
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function RankingListPanel:OnShow()
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main })
end
--界面关闭时调用(用于子类重写)
function RankingListPanel:OnClose()
RankingManager.ClearData()
RankingManager.isRequest=0
this.noneImage:SetActive(false)
end
--界面销毁时调用(用于子类重写)
function RankingListPanel:OnDestroy()
SubUIManager.Close(this.UpView)
for _, playerHead in ipairs(this.playerHeadList) do
playerHead:Recycle()
end
this.playerHeadList = {}
this.scrollView=nil
end
--点击获取对应排行信息
function this.GetRankInfo(index)
--Util.GetGameObject(this.gameObject,"Heads"):GetComponent("PlayFlyAnim"):PlayAnim(true)
RankingManager.CurPage=0
local key = RankingManager.GetCurRankingInfo("Id",index)
this.istop=true
RankingManager.InitData(key, this.SetInfoFuncList[key])--算是半个策略模式吧
end
---设置战力排名信息
function this.SetWarPowerInfo()
local warPowerData,myRankData=RankingManager.GetWarPowerInfo()
this.noneImage:SetActive(#warPowerData==0)
-- 没有排行数据需要立刻刷新,只在打开界面时有用
if #warPowerData == 0 then
this.isRefreshNow = true
end
this.InitNotRollingInfo()
this.SetNotRollingInfo(Language[11678],Language[11679],Language[11680],Language[11681],myRankData.myRank,Language[10036],FormationManager.GetFormationPower(1),myRankData.myRank,myRankData.myForce)
--设置滚动区信息
this.scrollView:SetData(warPowerData,function(index,root)
this.ShowWarPowerInfo(root,warPowerData[index],myRankData)
if index==#warPowerData then
RankingManager.RequestNextWarPowerPageData()
end
if index>3 then
return
end
this.SetHeadsInfo(warPowerData[index],root,index,warPowerData[index].userName,warPowerData[index].level)
end, not this.istop)
this.CheckIsTop()
end
--显示每条数据
function this.ShowWarPowerInfo(root,data,myRankData)
local info1,info2=this.InitRollingInfo(root)
this.AddPlayerInfoClick(root,data.uid)
this.SetSelfBG(root,myRankData.myRank, data.rankInfo.rank)
this.SetRankingNum(root, data.rankInfo.rank)
this.SetHeadInfo(root,data.head, data.headFrame,data.level)
this.SetShowInfo(info1,info2,data.userName,data.force)
end
---设置逐胜场排名信息
function this.SetArenaInfo()
local arenaData,myRankData=RankingManager.GetArenaInfo()
this.noneImage:SetActive(#arenaData==0)
if #arenaData == 0 then
this.isRefreshNow = true
end
this.InitNotRollingInfo()
this.SetNotRollingInfo(Language[11678],Language[11682],Language[11680],Language[11683],myRankData.myRank,Language[10036],"",myRankData.myRank,myRankData.myScore)
--设置滚动区信息
this.scrollView:SetData(arenaData,function(index,root)
this.ShowArenaInfo(root,arenaData[index],myRankData)
if index==#arenaData then
RankingManager.RequestNextArenaPageData()
end
if index>3 then
return
end
this.SetHeadsInfo(arenaData[index].personInfo,root,index,JingJiShouWeiToEn(arenaData[index].personInfo.name),arenaData[index].personInfo.level)
end, not this.istop)
this.CheckIsTop()
end
--显示每条数据
function this.ShowArenaInfo(root,data,myRankData)
local info1,info2=this.InitRollingInfo(root)
this.AddPlayerInfoClick(root,data.personInfo.uid)
this.SetSelfBG(root,myRankData.myRank,data.personInfo.rank)
this.SetRankingNum(root,data.personInfo.rank)
this.SetHeadInfo(root,data.personInfo.head,data.personInfo.headFrame,data.personInfo.level)
this.SetShowInfo(info1,info2,JingJiShouWeiToEn(data.personInfo.name),data.personInfo.score)
--设置出战角色头像
--for i = 1, 5 do
-- local heroHeadBg = Util.GetGameObject(root, "Demons/Head_"..i)
-- local hearIcon = Util.GetGameObject(heroHeadBg, "Icon")
-- local heroTId = data.team.heroTid[i]
-- if heroTId then
-- heroHeadBg:SetActive(true)
-- local demonData = ConfigManager.GetConfigData(ConfigName.HeroConfig, heroTId)
-- heroHeadBg:GetComponent("Image").sprite = Util.LoadSprite(GetQuantityImageByquality(demonData.Star))
-- hearIcon:GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(demonData.Icon))
-- else
-- heroHeadBg:SetActive(false)
-- end
--end
end
---设置试炼排名信息
function this.SetTrialInfo()
local trialData,myRankData=RankingManager.GetTrialInfo()
this.noneImage:SetActive(#trialData==0)
if #trialData == 0 then
this.isRefreshNow = true
end
this.InitNotRollingInfo()
this.SetNotRollingInfo(Language[11678],Language[11684],Language[11680],Language[11685],myRankData.rank,Language[10036],myRankData.highestTower,myRankData.rank,myRankData.highestTower..Language[10269])
this.scrollView:SetData(trialData,function(index,root)
this.ShowTrialInfo(root,trialData[index],myRankData)
if index>3 then
return
end
this.SetHeadsInfo(trialData[index],root,index,trialData[index].userName,trialData[index].level)
end, not this.istop)
this.CheckIsTop()
end
--显示每条数据
function this.ShowTrialInfo(root,data,myRankData)
local info1,info2=this.InitRollingInfo(root)
this.AddPlayerInfoClick(root,data.uid)
this.SetSelfBG(root,myRankData.rank,data.rankInfo.rank)
this.SetRankingNum(root,data.rankInfo.rank)
this.SetHeadInfo(root,data.head,data.headFrame,data.level)
this.SetShowInfo(info1,info2,data.userName,data.rankInfo.param1..Language[10269])
end
---设置兽潮玩家排名信息
function this.SetMonsterInfo()
local monsterData,myRankData=RankingManager.GetMonsterInfo()
this.noneImage:SetActive(#monsterData==0)
if #monsterData == 0 then
this.isRefreshNow = true
end
this.InitNotRollingInfo()
this.SetNotRollingInfo(Language[11678],Language[11684],Language[11680],Language[11686],myRankData.myRank,Language[10036],"0",myRankData.myRank,Language[10262] .. myRankData.myScore .. Language[10266])
this.scrollView:SetData(monsterData,function(index,root)
this.ShowMonsterInfo(root,monsterData[index],myRankData)
if index>3 then
return
end
this.SetHeadsInfo(monsterData[index],root,index,monsterData[index].userName,monsterData[index].level)
end, not this.istop)
this.CheckIsTop()
end
--显示每条数据
function this.ShowMonsterInfo(root,data,myRankData)
local info1,info2=this.InitRollingInfo(root)
this.AddPlayerInfoClick(root,data.uid)
this.SetSelfBG(root,myRankData.myRank,data.rankInfo.rank)
this.SetRankingNum(root,data.rankInfo.rank)
this.SetHeadInfo(root,data.head,data.headFrame,data.level)
this.SetShowInfo(info1,info2,data.userName,Language[10262]..data.rankInfo.param1..Language[10266])
end
---设置外敌排名信息
function this.SetAdventureInfo()
local adventureData,myRankData=RankingManager.GetAdventureInfo()
this.noneImage:SetActive(#adventureData==0)
if #adventureData == 0 then
this.isRefreshNow = true
end
this.InitNotRollingInfo()
this.SetNotRollingInfo(Language[11678],Language[11687],Language[11680],Language[11687],myRankData.rank,Language[10036],myRankData.hurt,myRankData.rank,myRankData.hurt)
this.scrollView:SetData(adventureData,function(index,root)
this.ShowAdventureInfo(root,adventureData[index],myRankData)
if index==#adventureData then
RankingManager.RequestNextAdventurePageData()
end
if index>3 then
return
end
this.SetHeadsInfo(adventureData[index],root,index,adventureData[index].name,adventureData[index].level)
end, not this.istop)
this.CheckIsTop()
end
--显示每条数据
function this.ShowAdventureInfo(root,data,myRankData)
local info1,info2=this.InitRollingInfo(root)
this.AddPlayerInfoClick(root,data.uid)
this.SetSelfBG(root,myRankData.rank,data.rank)
this.SetRankingNum(root,data.rank)
this.SetHeadInfo(root,data.head,data.headFrame,data.level)
this.SetShowInfo(info1,info2,data.name,data.hurt)
end
---设置关卡排名信息
function this.SetCustomsPassInfo()
local data,myData=RankingManager.GetCustomsPassInfo()
this.noneImage:SetActive(#data==0)
if #data==0 then
this.isRefreshNow = true
end
this.InitNotRollingInfo()
local myRankText = ""
if myData.fightId < 0 then
myRankText = Language[10036]
else
myRankText = RankingManager.mainLevelConfig[myData.fightId].Name
end
this.SetNotRollingInfo(Language[11678],Language[11185],Language[11680],Language[11688], myData.myRank,Language[10036],"",myData.myRank, myRankText)
this.scrollView:SetData(data,function(index,root)
this.ShowCustomsPassInfo(root,data[index],myData)
if index>3 then
return
end
this.SetHeadsInfo(data[index],root,index,data[index].userName,data[index].level)
end, not this.istop)
this.CheckIsTop()
end
--显示每条数据
function this.ShowCustomsPassInfo(root,data,myRankData)
if data.rankInfo.param1 > 0 then
local info1,info2=this.InitRollingInfo(root)
this.AddPlayerInfoClick(root,data.uid)
this.SetSelfBG(root,myRankData.myRank,data.rankInfo.rank)
this.SetRankingNum(root,data.rankInfo.rank)
this.SetHeadInfo(root,data.head,data.headFrame,data.level)
this.SetShowInfo(info1,info2,data.userName,RankingManager.mainLevelConfig[data.rankInfo.param1].Name)
end
end
--设置前三名背景头像
function this.SetHeadsInfo(data,root,index,name,level)
if not this.playerHeadList[root] then
this.playerHeadList[root]=CommonPool.CreateNode(POOL_ITEM_TYPE.PLAYER_HEAD,this.heads)
end
this.heads[index]:SetActive(true)
this.playerHeadList[root]:Reset()
this.playerHeadList[root]:SetHead(data.head)
this.playerHeadList[root]:SetFrame(data.headFrame)
this.playerHeadList[root]:SetLevel(level)
this.playerHeadList[root]:SetParent(this.heads[index])
this.playerHeadList[root]:SetLayer(this.sortingOrder)
if index==1 then
this.playerHeadList[root]:SetPosition(Vector3(0,126,0))
this.playerHeadList[root]:SetScale(Vector3.one*1.4)
this.playerScrollHead[root]:SetEffectScale(1.5)
this.name1.text=name
elseif index==2 then
this.playerHeadList[root]:SetPosition(Vector3(0,100,0))
this.playerHeadList[root]:SetScale(Vector3.one*1)
this.name2.text=name
elseif index==3 then
this.playerHeadList[root]:SetPosition(Vector3(0,100,0))
this.playerHeadList[root]:SetScale(Vector3.one*1)
this.name3.text=name
end
end
--初始化非滚动区信息
function this.InitNotRollingInfo()
for i = 1, 3 do
this.heads[i]:SetActive(false)
end
this.name1.text=""
this.name2.text=""
this.name3.text=""
this.titleName.text=""
this.titleInfo.text=""
this.info0.text=""
this.info1.text=""
this.rank0.text=""
this.rank1.text=""
end
--设置非滚动区信息
function this.SetNotRollingInfo(...)
local args={...}
this.titleName.text=args[1]--顶部信息
this.titleInfo.text=args[2]
this.info0.text=args[3]--底部信息
this.info1.text=args[4]
if not args[5] or args[5]<1 then--排名对比 <0未上榜
this.rank0.text = args[6] --未上榜
this.rank1.text = args[7] --显示内容
else
this.rank0.text = args[8] --上榜
this.rank1.text = args[9] --显示内容
end
end
--初始化滚动区信息
function this.InitRollingInfo(_root)
local info0= Util.GetGameObject(_root,"Value0"):GetComponent("Text")
local info1= Util.GetGameObject(_root,"Value1"):GetComponent("Text")
info0.text=""
info1.text=""
return info0,info1
end
--玩家信息弹窗
function this.AddPlayerInfoClick(root,uid)
local clickBtn=Util.GetGameObject(root,"ClickBtn")
Util.AddOnceClick(clickBtn,function()
UIManager.OpenPanel(UIName.PlayerInfoPopup, uid)
end)
end
--设置自身背景
function this.SetSelfBG(root,myRank,rank)
if myRank==rank then
Util.GetGameObject(root,"SelfBG").gameObject:SetActive(true)
else
Util.GetGameObject(root,"SelfBG").gameObject:SetActive(false)
end
end
--设置名次
function this.SetRankingNum(root,rank)
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)
Util.GetGameObject(sortNumTabs[4], "TitleText"):GetComponent("Text").text = rank
end
end
--设置头像
function this.SetHeadInfo(root,head,frame,level)
local headObj=Util.GetGameObject(root,"Head")
if not this.playerScrollHead[root] then
this.playerScrollHead[root]=CommonPool.CreateNode(POOL_ITEM_TYPE.PLAYER_HEAD,headObj)
end
this.playerScrollHead[root]:Reset()
this.playerScrollHead[root]:SetHead(head)
this.playerScrollHead[root]:SetFrame(frame)
this.playerScrollHead[root]:SetLevel(level)
this.playerScrollHead[root]:SetScale(Vector3.one*0.7)
this.playerScrollHead[root]:SetLayer(this.sortingOrder)
this.playerScrollHead[root]:SetEffectScale(0.75)
end
--设置显示信息
function this.SetShowInfo(info1,info2,str1,str2)
info1.text="<size=40%>"..str1.."</size>"
info2.text="<size=40%>"..str2.."</size>"
end
-- tab按钮自定义显示设置
function this.TabAdapter(tab, index, status)
local img = Util.GetGameObject(tab, "Image")
local lockImage=Util.GetGameObject(tab,"LockImage")
local txt = Util.GetGameObject(tab, "Text")
if status=="lock" then
lockImage:SetActive(true)
lockImage:GetComponent("Image").sprite = Util.LoadSprite(_tabImageData[status])
txt:GetComponent("Text").text = RankingManager.GetTabTextData()[index].txt
txt:GetComponent("Text").color = _tabFontColor[status]
else
lockImage:SetActive(false)
img:GetComponent("Image").sprite = Util.LoadSprite(_tabImageData[status])
txt:GetComponent("Text").text = RankingManager.GetTabTextData()[index].txt
txt:GetComponent("Text").color = _tabFontColor[status]
end
end
--检查是否显示第一页 当切换页签时切换到第一页 当请求下一页时不跳转第一页
function this.CheckIsTop()
if this.istop then
-- this.scrollView:SetIndex(1)
this.istop =false
end
end
--检查Tab是否解锁
function this.CheckTabCtrlIsLockP(index)
local type = RankingManager.GetCurRankingInfo("Id",index)
local des=RankingManager.GetCurRankingInfo("Des",index)
local b,str= this.CheckTabCtrlIsLockS(type,des)
if b then
return b,str
end
return false
end
function this.CheckTabCtrlIsLockS(type,des)
if type==8 then
if not ActTimeCtrlManager.IsQualifiled(type) then
return true, des..ActTimeCtrlManager.GetFuncTip(type)
end
else
if not ActTimeCtrlManager.SingleFuncState(type) then
return true, des..ActTimeCtrlManager.GetFuncTip(type)
end
end
end
return RankingListPanel