2020-08-25 15:46:38 +08:00
|
|
|
|
----- 公会十绝阵排行弹窗 -----
|
2020-05-09 13:31:21 +08:00
|
|
|
|
require("Base/BasePanel")
|
|
|
|
|
local DeathPosRankPopup = Inherit(BasePanel)
|
|
|
|
|
local this = DeathPosRankPopup
|
|
|
|
|
|
|
|
|
|
--标签按钮
|
|
|
|
|
local TabBox = require("Modules/Common/TabBox")
|
|
|
|
|
local _TabImgData = {select = "r_tongyong_xiaanniu_01", default = "r_tongyong_xiaanniu_02",}
|
|
|
|
|
local _TabFontColor = { default = Color.New(130 / 255, 128 / 255, 120 / 255, 1),
|
|
|
|
|
select = Color.New(243 / 255, 235 / 255, 202 / 255, 1) }
|
|
|
|
|
local _TabData = {
|
2021-03-02 15:59:29 +08:00
|
|
|
|
[1]= {txt = "公会排行"},
|
|
|
|
|
[2]= {txt = "个人排行"},
|
2020-05-09 13:31:21 +08:00
|
|
|
|
}
|
|
|
|
|
function DeathPosRankPopup:InitComponent()
|
|
|
|
|
this.panel=Util.GetGameObject(this.gameObject,"Panel")
|
|
|
|
|
this.backBtn=Util.GetGameObject(this.panel,"BackBtn")
|
2020-05-11 09:38:52 +08:00
|
|
|
|
this.upName=Util.GetGameObject(this.panel,"Scroll/UpInfo/Grid/Name"):GetComponent("Text")
|
|
|
|
|
this.upNum=Util.GetGameObject(this.panel,"Scroll/UpInfo/Grid/Num")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
this.tabbox = Util.GetGameObject(this.panel, "TabBox")
|
|
|
|
|
|
|
|
|
|
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,"Scroll/MyInfo")
|
|
|
|
|
this.mRSortNum=Util.GetGameObject(this.panel,"Scroll/MyInfo/SortNum")
|
|
|
|
|
this.mRName=Util.GetGameObject(this.panel,"Scroll/MyInfo/Grid/Name"):GetComponent("Text")
|
|
|
|
|
this.mRNum=Util.GetGameObject(this.panel,"Scroll/MyInfo/Grid/Num"):GetComponent("Text")
|
|
|
|
|
this.mRHurt=Util.GetGameObject(this.panel,"Scroll/MyInfo/Hurt"):GetComponent("Text")
|
2020-05-15 16:52:35 +08:00
|
|
|
|
|
|
|
|
|
this.empty=Util.GetGameObject(this.panel,"Scroll/Empty")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DeathPosRankPopup:BindEvent()
|
|
|
|
|
Util.AddClick(this.backBtn,function()
|
|
|
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DeathPosRankPopup:AddListener()
|
2020-05-11 09:38:52 +08:00
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.Guild.RefreshDeathPosStatus, this.RefreshPanel)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DeathPosRankPopup:RemoveListener()
|
2020-05-11 09:38:52 +08:00
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Guild.RefreshDeathPosStatus, this.RefreshPanel)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
function DeathPosRankPopup:OnOpen(...)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DeathPosRankPopup:OnShow()
|
2020-05-11 09:38:52 +08:00
|
|
|
|
this.RefreshPanel()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DeathPosRankPopup:OnClose()
|
2020-05-15 16:52:35 +08:00
|
|
|
|
this.empty:SetActive(false)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DeathPosRankPopup:OnDestroy()
|
|
|
|
|
this.scrollView=nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2020-05-11 09:38:52 +08:00
|
|
|
|
function this.RefreshPanel()
|
|
|
|
|
if DeathPosManager.status==DeathPosStatus.Close then
|
|
|
|
|
this:ClosePanel()
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
this.TabCtrl = TabBox.New()
|
|
|
|
|
this.TabCtrl:SetTabAdapter(this.TabAdapter)
|
|
|
|
|
this.TabCtrl:SetChangeTabCallBack(this.OnTabChange)
|
|
|
|
|
this.TabCtrl:Init(this.tabbox, _TabData)
|
|
|
|
|
end
|
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- tab按钮自定义显示设置
|
|
|
|
|
function this.TabAdapter(tab, index, status)
|
|
|
|
|
local img = Util.GetGameObject(tab, "Image")
|
|
|
|
|
local txt = Util.GetGameObject(tab, "Text")
|
|
|
|
|
img:GetComponent("Image").sprite = Util.LoadSprite(_TabImgData[status])
|
|
|
|
|
txt:GetComponent("Text").text = _TabData[index].txt
|
|
|
|
|
txt:GetComponent("Text").color = _TabFontColor[status]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- tab改变回调事件
|
|
|
|
|
function this.OnTabChange(index, lastIndex)
|
|
|
|
|
this.RefreshRank(index)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--刷新排行榜 index当前排行类型索引
|
|
|
|
|
function this.RefreshRank(index)
|
2021-03-02 15:59:29 +08:00
|
|
|
|
this.upName.text=index==1 and "公会名称" or "玩家名称"
|
2020-05-11 09:38:52 +08:00
|
|
|
|
this.upNum:SetActive(index==1)
|
|
|
|
|
local curRankType=RANK_TYPE.GUILD_DEATHPOS_ALLGUILD --默认公会排行
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if index==1 then
|
2020-05-11 09:38:52 +08:00
|
|
|
|
curRankType=RANK_TYPE.GUILD_DEATHPOS_ALLGUILD --公会排行
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif index==2 then
|
2020-05-11 09:38:52 +08:00
|
|
|
|
curRankType=RANK_TYPE.GUILD_DEATHPOS_ALLPERSON --个人排行
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2021-02-03 14:45:32 +08:00
|
|
|
|
-- NetManager.RequestRankInfo(curRankType,function(msg)
|
|
|
|
|
-- this.empty:SetActive(#msg.ranks<=0)
|
|
|
|
|
-- this.scrollView:SetData(msg.ranks,function(index,root)
|
|
|
|
|
-- this.SetScrollPre(root,msg.ranks[index],curRankType)
|
|
|
|
|
-- end)
|
|
|
|
|
-- this.scrollView:SetIndex(1)
|
|
|
|
|
|
|
|
|
|
-- --当我的排名没数据时
|
|
|
|
|
-- this.mRSortNum:SetActive(msg.myRankInfo.rank~=-1)
|
|
|
|
|
-- this.mRNum.gameObject:SetActive(msg.myRankInfo.rank~=-1)
|
|
|
|
|
-- if msg.myRankInfo.rank==-1 then
|
2021-03-02 15:59:29 +08:00
|
|
|
|
-- this.mRName.text="未上榜"
|
2021-02-03 14:45:32 +08:00
|
|
|
|
-- this.mRHurt.text=""
|
|
|
|
|
-- return
|
|
|
|
|
-- end
|
|
|
|
|
-- this.SetMyRank(msg.myRankInfo,curRankType)
|
|
|
|
|
-- end)
|
2021-02-27 16:54:52 +08:00
|
|
|
|
RankingManager.InitData(RANK_TYPE.GUILD_DEATHPOS_ALLGUILD,function()
|
2021-02-03 14:45:32 +08:00
|
|
|
|
local ranks,myRankInfo = RankingManager.GetRankingInfo()
|
|
|
|
|
this.empty:SetActive(#ranks<=0)
|
|
|
|
|
this.SetScrollView(ranks,curRankType)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.scrollView:SetIndex(1)
|
2021-02-27 16:54:52 +08:00
|
|
|
|
--当我的排名没数据时
|
2021-02-03 14:45:32 +08:00
|
|
|
|
this.mRSortNum:SetActive(myRankInfo.rank~=-1)
|
|
|
|
|
this.mRNum.gameObject:SetActive(myRankInfo.rank~=-1)
|
|
|
|
|
if myRankInfo.rank==-1 then
|
2021-03-02 15:59:29 +08:00
|
|
|
|
this.mRName.text="未上榜"
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.mRHurt.text=""
|
|
|
|
|
return
|
|
|
|
|
end
|
2021-02-03 14:45:32 +08:00
|
|
|
|
this.SetMyRank(myRankInfo,curRankType)
|
|
|
|
|
end,nil,1)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-02-03 14:45:32 +08:00
|
|
|
|
function this.SetScrollView(ranks,curRankType)
|
|
|
|
|
this.scrollView:SetData(ranks,function(index,root)
|
|
|
|
|
this.SetScrollPre(root,ranks[index],curRankType)
|
|
|
|
|
if index==#ranks then
|
|
|
|
|
RankingManager.RequestNextWarPowerPageData(function()
|
|
|
|
|
local ranks,myRankInfo = RankingManager.GetRankingInfo()
|
|
|
|
|
this.SetScrollView(ranks)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--设置每条数据
|
|
|
|
|
function this.SetScrollPre(root,data,curRankType)
|
|
|
|
|
local name=Util.GetGameObject(root,"Grid/Name"):GetComponent("Text")
|
|
|
|
|
local num=Util.GetGameObject(root,"Grid/Num"):GetComponent("Text")
|
|
|
|
|
local hurt=Util.GetGameObject(root,"Hurt"):GetComponent("Text")
|
|
|
|
|
|
2020-05-15 16:52:35 +08:00
|
|
|
|
this.SetRankingNum(root,data.rankInfo.rank,false)
|
2020-05-11 09:38:52 +08:00
|
|
|
|
num.gameObject:SetActive(curRankType==RANK_TYPE.GUILD_DEATHPOS_ALLGUILD)
|
|
|
|
|
if curRankType==RANK_TYPE.GUILD_DEATHPOS_ALLGUILD then
|
2021-03-02 15:59:29 +08:00
|
|
|
|
name.text=string.format("%s(%s人)",data.guildName,data.rankInfo.param3) --公会名称 人数
|
2020-05-09 13:31:21 +08:00
|
|
|
|
num.text=data.rankInfo.param2 -- param2 挑战人数
|
2020-05-11 09:38:52 +08:00
|
|
|
|
elseif curRankType==RANK_TYPE.GUILD_DEATHPOS_ALLPERSON then
|
2020-05-09 13:31:21 +08:00
|
|
|
|
name.text=data.userName
|
|
|
|
|
end
|
2020-07-17 14:40:33 +08:00
|
|
|
|
hurt.text= DeathPosManager.ChangeDamageForm(data.rankInfo.param1)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
--设置我的名次
|
|
|
|
|
function this.SetMyRank(data,curRankType)
|
|
|
|
|
local guildData = MyGuildManager.GetMyGuildInfo()
|
2020-05-15 16:52:35 +08:00
|
|
|
|
this.SetRankingNum(this.mRRank,data.rank,true)
|
2020-05-11 09:38:52 +08:00
|
|
|
|
this.mRNum.gameObject:SetActive(curRankType==RANK_TYPE.GUILD_DEATHPOS_ALLGUILD)
|
|
|
|
|
if curRankType==RANK_TYPE.GUILD_DEATHPOS_ALLGUILD then
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.mRName.text=guildData.name
|
2021-03-02 15:59:29 +08:00
|
|
|
|
this.mRNum.text= data.param2.."个" --param2 个数
|
2020-05-11 09:38:52 +08:00
|
|
|
|
elseif curRankType==RANK_TYPE.GUILD_DEATHPOS_ALLPERSON then
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.mRName.text=PlayerManager.nickName
|
|
|
|
|
end
|
2020-07-17 14:40:33 +08:00
|
|
|
|
this.mRHurt.text= DeathPosManager.ChangeDamageForm(data.param1) --param1 伤害
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-05-15 16:52:35 +08:00
|
|
|
|
--设置名次 isMy 是否是设置我的名次
|
|
|
|
|
function this.SetRankingNum(root,rank,isMy)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
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)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
if rank>100 and isMy then
|
|
|
|
|
rank="100+"
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
Util.GetGameObject(sortNumTabs[4], "TitleText"):GetComponent("Text").text = rank
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return DeathPosRankPopup
|