429 lines
19 KiB
Lua
429 lines
19 KiB
Lua
require("Base/BasePanel")
|
|
RankingSingleListPanel = Inherit(BasePanel)
|
|
local this = RankingSingleListPanel
|
|
--头像
|
|
this.firsthead = nil
|
|
this.playerHeadList = {}--背景前三头像
|
|
this.playerScrollHead={}--滚动条头像
|
|
|
|
local mapNpc = "live2d_npc_map"
|
|
local mapNpc2 = "live2d_npc_map_nv"
|
|
local npc, scale
|
|
--初始化组件(用于子类重写)
|
|
function RankingSingleListPanel:InitComponent()
|
|
|
|
this.backBtn=Util.GetGameObject(self.gameObject,"bg/btnBack")
|
|
this.firsthead=Util.GetGameObject(self.gameObject,"firstHead")
|
|
this.firstheadClick=Util.GetGameObject(self.gameObject,"firstHead/click")
|
|
this.livePrefab=Util.GetGameObject(self.gameObject,"firstHead/livePrefab")
|
|
this.name=Util.GetGameObject(self.gameObject,"bg/name"):GetComponent("Text")
|
|
this.firstHeadName=Util.GetGameObject(self.gameObject,"firstHead/nameText"):GetComponent("Text")
|
|
this.firstHeadinfoGo=Util.GetGameObject(self.gameObject,"firstHead/infoGo")
|
|
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,571.1),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.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,"grid/Info0"):GetComponent("Text")
|
|
this.rank0=Util.GetGameObject(this.record,"grid/Rank0"):GetComponent("Text")
|
|
this.infoGo=Util.GetGameObject(this.record,"infoGo")
|
|
|
|
this.noneImage=Util.GetGameObject(self.gameObject,"RankList/NoneImage")--无信息图片
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function RankingSingleListPanel:BindEvent()
|
|
--返回按钮
|
|
Util.AddClick(this.backBtn,function()
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
|
self:ClosePanel()
|
|
end)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function RankingSingleListPanel:AddListener()
|
|
Game.GlobalEvent:AddEvent(GameEvent.RankingList.AllRankingList, this.SetRankingInfo)
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function RankingSingleListPanel:RemoveListener()
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.RankingList.AllRankingList, this.SetRankingInfo)
|
|
end
|
|
local sData = nil
|
|
--界面打开时调用(用于子类重写)
|
|
function RankingSingleListPanel:OnOpen(_sData)
|
|
SoundManager.PlayMusic(SoundConfig.BGM_Rank)
|
|
sData = _sData
|
|
this.name.text = sData.name
|
|
this.GetRankInfo(sData.rankType,1)
|
|
end
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
function RankingSingleListPanel:OnShow()
|
|
-- local asda = {}
|
|
-- this.scrollView:SetData(asda,function(index,root)
|
|
-- this.ShowTrialInfo(root,asda[index],nil)
|
|
-- end)
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function RankingSingleListPanel:OnClose()
|
|
this.scrollParentView:SetActive(false)
|
|
SoundManager.PlayOldMusic()
|
|
RankingManager.isRequest=0
|
|
this.noneImage:SetActive(false)
|
|
-- if this.liveNode then
|
|
-- --Log("==YSP== 删除立绘")
|
|
-- poolManager:UnLoadLive(npc, this.liveNode)
|
|
-- this.liveNode=nil
|
|
-- end
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function RankingSingleListPanel:OnDestroy()
|
|
if this.liveNode then
|
|
--Log("==YSP== 删除立绘")
|
|
poolManager:UnLoadLive(npc, this.liveNode)
|
|
this.liveNode=nil
|
|
end
|
|
for _, playerHead in ipairs(this.playerHeadList) do
|
|
playerHead:Recycle()
|
|
end
|
|
this.playerHeadList = {}
|
|
this.scrollView=nil
|
|
end
|
|
|
|
|
|
--点击获取对应排行信息
|
|
function this.GetRankInfo(rankType,rankIndex)
|
|
RankingManager.CurPage=0
|
|
this.istop=true
|
|
local curActivity = sData.activiteId > 0 and ActivityGiftManager.GetActivityIdByType(sData.activiteId) or nil
|
|
RankingManager.InitData(rankType,function()
|
|
this.SetRankingInfo()
|
|
end,curActivity,rankIndex)
|
|
end
|
|
|
|
---设置排名信息
|
|
function this.SetRankingInfo()
|
|
local rankingData,myRankData=RankingManager.GetRankingInfo()
|
|
-- LogGreen("#rankingData "..#rankingData)
|
|
this.noneImage:SetActive(#rankingData==0)
|
|
this.firsthead:SetActive(#rankingData~=0)
|
|
this.scrollParentView:SetActive(#rankingData~=0)
|
|
-- 没有排行数据需要立刻刷新,只在打开界面时有用
|
|
-- this.SetNotRollingInfo("角色信息","最高战力","我的排名:","我的战力",myRankData.myRank,"未上榜",FormationManager.GetFormationPower(1),myRankData.myRank,myRankData.myForce)
|
|
this.SetNotRollingInfo(myRankData)
|
|
local dData
|
|
if sData.rankType == RANK_TYPE.FIGHT_LEVEL_RANK then
|
|
dData = { rankInfo = {param1 = myRankData.param1},
|
|
force = myRankData.param1}
|
|
elseif sData.rankType == RANK_TYPE.FORCE_CURR_RANK then
|
|
dData = {rankInfo = {param1 = myRankData.param1},
|
|
force = myRankData.param1}
|
|
elseif sData.rankType == RANK_TYPE.GUILD_FORCE_RANK then
|
|
dData = {rankInfo = {rank = myRankData.rank ,param1= myRankData.param1},
|
|
guildName = PlayerManager.familyId == 0 and "" or MyGuildManager.GetMyGuildInfo().name}
|
|
elseif sData.rankType == RANK_TYPE.MONSTER_RANK then
|
|
dData = {rankInfo = {param1 = myRankData.param1},
|
|
force = myRankData.param1}
|
|
elseif sData.rankType == RANK_TYPE.GOLD_EXPER then
|
|
dData = {rankInfo = {rank = myRankData.rank ,param1= myRankData.param1},
|
|
userName = PlayerManager.nickName}
|
|
elseif sData.rankType == RANK_TYPE.ARENA_RANK then
|
|
dData = { rankInfo = {param1 = myRankData.param1},
|
|
score = myRankData.param1}
|
|
elseif sData.rankType == RANK_TYPE.CELEBRATION_GUILD then
|
|
dData = { rankInfo = {param1 = myRankData.param1},
|
|
score = myRankData.param1}
|
|
end
|
|
this.SetInfoShow(this.infoGo,dData,sData.rankType)
|
|
--数据拆分
|
|
if not rankingData or (rankingData and #rankingData <= 0) then
|
|
return
|
|
end
|
|
local dt,db=RankingManager.CutDate(rankingData)
|
|
if sData.rankType == RANK_TYPE.CELEBRATION_GUILD or sData.rankType == RANK_TYPE.GUILD_FORCE_RANK then
|
|
dt[1].userName = dt[1].guildName
|
|
end
|
|
this.SetHeadsInfo(dt[1],this.firstHeadinfoGo,1,dt[1].userName,dt[1].level)
|
|
--设置滚动区信息
|
|
this.scrollView:SetData(db,function(index,root)
|
|
this.ShowWarPowerInfo(root,db[index],myRankData,index)
|
|
LogGreen("#db "..#db.." index "..index)
|
|
if index==#db then
|
|
RankingManager.RequestNextWarPowerPageData(function()
|
|
this.SetRankingInfo()
|
|
end)
|
|
end
|
|
end,true,true)
|
|
end
|
|
--显示每条数据
|
|
function this.ShowWarPowerInfo(root,data,myRankData)
|
|
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.SetInfoShow(Util.GetGameObject(root,"infoGo"),data,sData.rankType,Util.GetGameObject(root,"Value0"))
|
|
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,Util.GetGameObject(this.firsthead,"Head"))
|
|
end
|
|
this.firsthead: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(Util.GetGameObject(this.firsthead,"Head"))
|
|
this.playerHeadList[root]:SetLayer(this.sortingOrder)
|
|
if index==1 then
|
|
this.playerHeadList[root]:SetPosition(Vector3(0,0,0))
|
|
this.playerHeadList[root]:SetScale(Vector3.one*0.6)
|
|
this.playerHeadList[root]:SetEffectScale(0.8)
|
|
this.firstHeadName.text = name
|
|
this.SetInfoShow(this.firstHeadinfoGo,data,sData.rankType)
|
|
--data.sex
|
|
--加载立绘
|
|
if this.liveNode then
|
|
--Log("==YSP== 删除立绘")
|
|
poolManager:UnLoadLive(npc, this.liveNode)
|
|
this.liveNode=nil
|
|
end
|
|
npc = data.sex == ROLE_SEX.BOY and mapNpc or mapNpc2
|
|
local scale = data.sex == ROLE_SEX.BOY and Vector3.one * 0.32 or Vector3.one * 0.19
|
|
this.liveNode = poolManager:LoadLive(npc, this.livePrefab.transform, scale, Vector3.New(0,-158.31,0))
|
|
local SkeletonGraphic = this.liveNode:GetComponent("SkeletonGraphic")
|
|
if SkeletonGraphic then
|
|
SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true)
|
|
end
|
|
Util.AddOnceClick(this.firstheadClick,function()
|
|
UIManager.OpenPanel(UIName.PlayerInfoPopup, data.uid)
|
|
end)
|
|
|
|
end
|
|
end
|
|
--设置非滚动区信息
|
|
function this.SetNotRollingInfo(myRankData)
|
|
-- optional int32 rank = 1;
|
|
-- optional int64 param1 = 2;
|
|
-- optional int32 param2 = 3;
|
|
-- optional int32 param3 = 4;
|
|
this.info0.text=Language[10103]
|
|
if not myRankData.rank or (myRankData.rank and myRankData.rank < 1) then--排名对比 <0未上榜
|
|
this.rank0.text = Language[10036] --未上榜
|
|
else
|
|
this.rank0.text = myRankData.rank --上榜
|
|
end
|
|
end
|
|
|
|
|
|
--初始化滚动区信息
|
|
function this.InitRollingInfo(_root)
|
|
local info0= Util.GetGameObject(_root,"Value0"):GetComponent("Text")
|
|
info0.text=""
|
|
return info0
|
|
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.8)
|
|
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
|
|
--检查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
|
|
function this.SetInfoShow(go,data,rankType,Value0)
|
|
local fight = Util.GetGameObject(go,"fight")
|
|
local warPower = Util.GetGameObject(go,"warPower")
|
|
local trial = Util.GetGameObject(go,"trial")
|
|
local goldExper = Util.GetGameObject(go,"goldExper")
|
|
local arenaScore = Util.GetGameObject(go,"arenaScore")
|
|
fight:SetActive(false)
|
|
warPower:SetActive(false)
|
|
trial:SetActive(false)
|
|
goldExper:SetActive(false)
|
|
arenaScore:SetActive(false)
|
|
-- LogGreen("rankType "..rankType)
|
|
if rankType == RANK_TYPE.FIGHT_LEVEL_RANK then
|
|
LogGreen("data.rankInfo.param1 "..data.rankInfo.param1)
|
|
if data.rankInfo.param1 and data.rankInfo.param1 > 0 then
|
|
fight:SetActive(true)
|
|
if Value0 then
|
|
Value0:GetComponent("Text").text = "<size=40%>"..data.userName.."</size>"
|
|
end
|
|
Util.GetGameObject(go,"fight"):GetComponent("Text").text = GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.MainLevelConfig,data.rankInfo.param1).Name)
|
|
end
|
|
elseif rankType == RANK_TYPE.FORCE_CURR_RANK then
|
|
if data.rankInfo.param1 and data.rankInfo.param1 >0 then
|
|
warPower:SetActive(true)
|
|
if Value0 then
|
|
Value0:GetComponent("Text").text = "<size=40%>"..data.userName.."</size>"
|
|
end
|
|
Util.GetGameObject(go,"warPower/Text"):SetActive(true)
|
|
Util.GetGameObject(go,"warPower/Text"):GetComponent("Text").text = data.rankInfo.param1--data.force
|
|
end
|
|
elseif rankType == RANK_TYPE.GUILD_FORCE_RANK then
|
|
if data.rankInfo.param1 and data.rankInfo.param1 > 0 then
|
|
warPower:SetActive(true)
|
|
if Value0 then
|
|
Value0:GetComponent("Text").text = "<size=40%>"..data.guildName.."</size>"
|
|
end
|
|
Util.GetGameObject(go,"warPower/Text"):SetActive(true)
|
|
Util.GetGameObject(go,"warPower/Text"):GetComponent("Text").text = data.rankInfo.param1
|
|
end
|
|
elseif rankType == RANK_TYPE.MONSTER_RANK then
|
|
if data.rankInfo.param1 and data.rankInfo.param1 > 0 then
|
|
trial:SetActive(true)
|
|
if Value0 then
|
|
Value0:GetComponent("Text").text = "<size=40%>"..data.userName.."</size>"
|
|
end
|
|
Util.GetGameObject(go,"trial/Text"):SetActive(false)
|
|
Util.GetGameObject(go,"trial/tip"):GetComponent("Text").text = Language[11689].. data.rankInfo.param1
|
|
end
|
|
elseif rankType == RANK_TYPE.GOLD_EXPER then
|
|
if GetCurLanguage() == 0 then
|
|
Util.GetGameObject(go,"goldExper/tip"):GetComponent("Text").fontSize = 38
|
|
else
|
|
Util.GetGameObject(go,"goldExper/tip"):GetComponent("Text").fontSize = 28
|
|
end
|
|
|
|
if data.rankInfo.param1 and data.rankInfo.param1 > 0 then
|
|
goldExper:SetActive(true)
|
|
if Value0 then
|
|
Value0:GetComponent("Text").text = "<size=40%>"..data.userName.."</size>"
|
|
end
|
|
Util.GetGameObject(go,"goldExper/Text"):GetComponent("Text").text = data.rankInfo.param1
|
|
end
|
|
if sData.activiteId == ActivityTypeDef.GoldExper then
|
|
Util.GetGameObject(go,"goldExper/tip"):GetComponent("Text").text = Language[11690]
|
|
elseif sData.activiteId == ActivityTypeDef.FastExplore then
|
|
Util.GetGameObject(go,"goldExper/tip"):GetComponent("Text").text = Language[11691]
|
|
elseif sData.activiteId == ActivityTypeDef.FindTreasureExper then
|
|
Util.GetGameObject(go,"goldExper/tip"):GetComponent("Text").text = Language[11692]
|
|
elseif sData.activiteId == ActivityTypeDef.ExpeditionExper then
|
|
Util.GetGameObject(go,"goldExper/tip"):GetComponent("Text").text = Language[11693]
|
|
elseif sData.activiteId == ActivityTypeDef.DemonSlayer then
|
|
Util.GetGameObject(go,"goldExper/tip"):GetComponent("Text").text = Language[11694]
|
|
elseif sData.activiteId == ActivityTypeDef.slhjExper then
|
|
Util.GetGameObject(go,"goldExper/tip"):GetComponent("Text").text = Language[11695]
|
|
elseif sData.activiteId == ActivityTypeDef.Celebration then
|
|
Util.GetGameObject(go,"goldExper/tip"):GetComponent("Text").text = Language[11696]
|
|
end
|
|
elseif rankType == RANK_TYPE.ARENA_RANK then
|
|
arenaScore:SetActive(true)
|
|
local str = ""
|
|
if Value0 then
|
|
Value0:GetComponent("Text").text = "<size=40%>"..data.userName .."</size>"
|
|
end
|
|
if data.rankInfo.param1 and data.rankInfo.param1 > 0 then
|
|
str = Language[11693] .. data.rankInfo.param1--data.param1
|
|
else
|
|
str = ""
|
|
end
|
|
Util.GetGameObject(go,"arenaScore"):GetComponent("Text").text = str
|
|
|
|
elseif rankType == RANK_TYPE.CELEBRATION_GUILD then
|
|
if data.rankInfo.param1 and data.rankInfo.param1 > 0 then
|
|
trial:SetActive(true)
|
|
if Value0 then
|
|
Value0:GetComponent("Text").text = "<size=40%>"..data.guildName.."</size>"
|
|
end
|
|
-- Util.GetGameObject(go,"trial/Text"):GetComponent("Text").text = Language[11697]..data.rankInfo.param1
|
|
Util.GetGameObject(go,"trial/Text"):SetActive(true)
|
|
if GetCurLanguage() == 2 then
|
|
Util.GetGameObject(go,"trial/tip"):GetComponent("Text").fontSize = 26
|
|
else
|
|
Util.GetGameObject(go,"trial/tip"):GetComponent("Text").fontSize = 38
|
|
end
|
|
Util.GetGameObject(go,"trial/tip"):GetComponent("Text").text = Language[11697]
|
|
Util.GetGameObject(go,"trial/Text"):GetComponent("Text").text = data.rankInfo.param1
|
|
end
|
|
end
|
|
end
|
|
return RankingSingleListPanel |