miduo_client/Assets/ManagedResources/~Lua/Modules/ArenaTopMatch/View/ATM_RankView.lua

440 lines
17 KiB
Lua

local ATM_RankView={}
local this=ATM_RankView
--头名
-- local TitleName={
-- "r_jingjichang_tiao01","r_jingjichang_tiao02","r_jingjichang_tiao03","r_jingjichang_tiao04"
-- }
--头描述
-- local TitleDesc={
-- "冠 军","亚 军","4 强","8 强","16 强","32 强","128 强"
-- }
--空信息提示
local EmptyTip={[1]=Language[10175],[2]=Language[10176]}
-- local TitleColor={
-- Color.New(177/255,91/255,90/255,1),Color.New(169/255,132/255,105/255,1),
-- Color.New(161/255,105/255,168/255,1),Color.New(97/255,124/255,154/255,1)
-- }
local battleStage=0
local battleTurn=0
local battleState=0
-- 排行显示类型
local showTip={
Four=5,
Two=3,
One=1
}
-- local TitleIndex={
-- [1]=17,
-- [2]=9,
-- [3]=5,
-- [4]=3,
-- [5]=2,
-- }
-- local TurnIndex={
-- [1]=5,
-- [2]=4,
-- [3]=3,
-- [4]=2,
-- [5]=1
-- }
--排名预设列表
local itemList={}
---巅峰战排名
--初始化组件(用于子类重写)
function ATM_RankView:InitComponent()
-- this.itemPre=Util.GetGameObject(self.gameObject,"ItemPre")
this.empty=Util.GetGameObject(self.gameObject,"Empty")
this.emptyText=Util.GetGameObject(this.empty,"Text"):GetComponent("Text")
this.panel=Util.GetGameObject(self.gameObject,"Panel")
for i=1,8 do
itemList[i]=Util.GetGameObject(this.panel,"ItemPre"..i)
end
-- this.myRankContent=Util.GetGameObject(self.gameObject,"MyRank")
-- this.myRank=Util.GetGameObject(this.myRankContent,"Rank"):GetComponent("Text")
-- this.myPower=Util.GetGameObject(this.myRankContent,"Power"):GetComponent("Text")
-- this.scorllRoot=Util.GetGameObject(self.gameObject,"ScorllRoot")
--[[
if not this.scrollView then
this.scrollView = SubUIManager.Open(SubUIConfig.ScrollFitterView, this.scorllRoot.transform,
this.itemPre, Vector2.New(rootWidth, rootHight), 1, 10)
this.scrollView.moveTween.MomentumAmount = 1
this.scrollView.moveTween.Strength = 2
end]]
this.playerHead={}--玩家头像列表
-- this.istop=true
end
--绑定事件(用于子类重写)
function ATM_RankView:BindEvent()
end
--添加事件监听(用于子类重写)
function ATM_RankView:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.ATM_RankView.OnRankChange,this.RefreshRankInfo)
-- Game.GlobalEvent:AddEvent(GameEvent.TopMatch.OnTopMatchDataUpdate,this.OnOpen, this)
end
--移除事件监听(用于子类重写)
function ATM_RankView:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.ATM_RankView.OnRankChange, this.RefreshRankInfo)
-- Game.GlobalEvent:RemoveEvent(GameEvent.TopMatch.OnTopMatchDataUpdate, this.OnOpen, this)
end
--界面打开时调用(用于子类重写)
function ATM_RankView:OnOpen(...)
this.RefreshRankInfo()
end
function ATM_RankView:OnSortingOrderChange(sortingOrder)
end
--界面关闭时调用(用于子类重写)
function ATM_RankView:OnClose()
-- ArenaTopMatchManager.CurPage=0
end
--界面销毁时调用(用于子类重写)
function ATM_RankView:OnDestroy()
this.scrollView=nil
end
--刷新排名信息
function this.RefreshRankInfo()
for i = 1, #itemList do
Util.GetGameObject(itemList[i],"Name"):GetComponent("Text").text = ""
end
local isActive = ArenaTopMatchManager.IsTopMatchActive()
battleStage = ArenaTopMatchManager.GetBaseData().battleStage
battleTurn = ArenaTopMatchManager.GetBaseData().battleTurn
battleState = ArenaTopMatchManager.GetBaseData().battleState
-- ArenaTopMatchManager.CurPage=0
LogGreen(Language[10156]..battleStage..Language[10157]..battleTurn..Language[10158]..battleState.."</color>".." isActive "..tostring(isActive).." battleStage == TOP_MATCH_STAGE.ELIMINATION "..tostring(battleStage == TOP_MATCH_STAGE.ELIMINATION))
local isShowRank = isActive and battleStage == TOP_MATCH_STAGE.ELIMINATION and battleTurn>=3--当处于淘汰赛 处于8强(battleStage == TOP_MATCH_STAGE.ELIMINATION or battleStage == TOP_MATCH_STAGE.CHOOSE or battleState == TOP_MATCH_TIME_STATE.OVER)
this.panel:SetActive(isShowRank)
this.empty:SetActive(not isShowRank)
if battleStage==TOP_MATCH_STAGE.OVER or battleStage==TOP_MATCH_STAGE.CLOSE then --当处于活动已结束 显示赛程尚未开启
this.emptyText.text=EmptyTip[1]
elseif battleStage==TOP_MATCH_STAGE.CHOOSE then --当处于选拔赛 显示尚未决出8强
this.emptyText.text=EmptyTip[2]
end
--后加的结束了 也要显示八强数据
if battleStage == TOP_MATCH_STAGE.OVER and battleTurn==-2 and battleState==TOP_MATCH_TIME_STATE.OVER then
this.panel:SetActive(true)
this.empty:SetActive(false)
end
LogGreen("isShowRank "..tostring(isShowRank))
-- if not isShowRank then return end
ArenaTopMatchManager.RequestRankData(1,function()
local rankData,madata=ArenaTopMatchManager.GetRankData()
if battleStage == TOP_MATCH_STAGE.ELIMINATION and battleTurn==4 and battleState==TOP_MATCH_TIME_STATE.OPEN_IN_END and isShowRank then
this.RefreshRankData(rankData,showTip.Four)
elseif battleStage == TOP_MATCH_STAGE.ELIMINATION and battleTurn==5 and battleState==TOP_MATCH_TIME_STATE.OPEN_IN_END and isShowRank then
this.RefreshRankData(rankData,showTip.Two)
elseif battleStage == TOP_MATCH_STAGE.ELIMINATION and battleTurn==6 and battleState==TOP_MATCH_TIME_STATE.OPEN_IN_END and isShowRank then
this.RefreshRankData(rankData,showTip.One)
elseif battleStage == TOP_MATCH_STAGE.OVER and battleTurn==-2 and battleState==TOP_MATCH_TIME_STATE.OVER then--后加的结束了 也要显示八强数据
this.RefreshRankData(rankData,showTip.Four)
this.RefreshRankData(rankData,showTip.Two)
this.RefreshRankData(rankData,showTip.One)
end
end)
-- this.istop = true
-- this.InitUnRollingInfo()
-- local rankData,myRankData=ArenaTopMatchManager.GetRankData()
--我的排名数据
-- this.myRank.text= "我的排名:"..(myRankData.rank <= 0 and "未上榜" or myRankData.rank)
-- this.myPower.text= "战力:"..(myRankData.totalForce <= 0 and "未上榜" or myRankData.totalForce)
--滚动区数据
-- if not this.scrollView then
-- local rootHight = this.scorllRoot.transform.rect.height
-- local rootWidth=this.scorllRoot.transform.rect.width
-- this.scrollView = SubUIManager.Open(SubUIConfig.ScrollFitterView, this.scorllRoot.transform,
-- this.itemPre, Vector2.New(rootWidth, rootHight), 1, 10)
-- this.scrollView.moveTween.MomentumAmount = 1
-- this.scrollView.moveTween.Strength = 2
-- end
-- if this.istop then
-- this.scrollView:SetData(rankData, function(index,root)
-- this.SetNodeShow(root,rankData[index],myRankData.rank)
-- --分页请求
-- if index==#rankData then
-- ArenaTopMatchManager.GetNextRankData()
-- return
-- end
-- end, 1)
-- this.istop = false
-- else
-- this.scrollView:SetData(rankData,function(index,root)
-- this.SetNodeShow(root,rankData[index],myRankData.rank)
-- --分页请求
-- if index==#rankData then
-- ArenaTopMatchManager.GetNextRankData()
-- return
-- end
-- end)
-- end
--this.CheckIsTop()
end
--刷新显示排行
function this.RefreshRankData(data,type)
-- 虚位以待
if type~=ShowType.One then
for i=1,type-1 do
this.SetItemData(i)
end
end
--输的玩家
for i=type,8 do
this.SetItemData(i,data[i])
end
end
--设置排行Item数据
function this.SetItemData(...)
local args={...}
local root=itemList[args[1]]
local head= Util.GetGameObject(root,"Head")
local info=Util.GetGameObject(root,"Info"):GetComponent("Image")
local name=Util.GetGameObject(root,"Name"):GetComponent("Text")
name.text=""
if args[2] then
if not this.playerHead[root] then
this.playerHead[root] = CommonPool.CreateNode(POOL_ITEM_TYPE.PLAYER_HEAD,head)
end
this.playerHead[root]:Reset()
this.playerHead[root]:SetScale(Vector3.one)
this.playerHead[root]:SetHead(args[2].head)
this.playerHead[root]:SetFrame(args[2].headFrame)
this.playerHead[root]:SetLevel(args[2].level)
info.enabled=false
name.text=args[2].name
Util.AddOnceClick(head,function()
UIManager.OpenPanel(UIName.PlayerInfoPopup, args[2].uid)
end)
else
if this.playerHead[root] then
this.playerHead[root] = nil
end
info.enabled=true
-- name.text=""
end
end
-- █████▒█ ██ ▄████▄ ██ ▄█▀ ██████╗ ██╗ ██╗ ██████╗
-- ▓██ ▒ ██ ▓██▒▒██▀ ▀█ ██▄█▒ ██╔══██╗██║ ██║██╔════╝
-- ▒████ ░▓██ ▒██░▒▓█ ▄ ▓███▄░ ██████╔╝██║ ██║██║ ███╗
-- ░▓█▒ ░▓▓█ ░██░▒▓▓▄ ▄██▒▓██ █▄ ██╔══██╗██║ ██║██║ ██║
-- ░▒█░ ▒▒█████▓ ▒ ▓███▀ ░▒██▒ █▄ ██████╔╝╚██████╔╝╚██████╔╝
-- ▒ ░ ░▒▓▒ ▒ ▒ ░ ░▒ ▒ ░▒ ▒▒ ▓▒ ╚═════╝ ╚═════╝ ╚═════╝
-- ░ ░░▒░ ░ ░ ░ ▒ ░ ░▒ ▒░
-- ░ ░ ░░░ ░ ░ ░ ░ ░░ ░
-- ░ ░ ░ ░ ░
--设置每条节点显示
-- function this.SetNodeShow(root,data,myRank)
-- local selfBg=Util.GetGameObject(root,"Content/Base/SelfBg")
-- selfBg.gameObject:SetActive(myRank==data[1].rank)
-- this.SetTitle(root,data[1].rank)
-- this.SetHeadInfo(root,data)
-- this.SetTeamInfo(root,data)
-- local name,power= this.InitRollingInfo(root)
-- this.SetShowInfo(name,power,data[1].name,data[1].totalForce)
-- end
--玩家信息弹窗
--function this.AddPlayerInfoClick(root,uid)
-- local bg=Util.GetGameObject(root,"Content/Base/Bg")
-- Util.AddOnceClick(bg,function()
-- UIManager.OpenPanel(UIName.PlayerInfoPopup, uid)
-- end)
--end
--设置名次
--function this.SetRankingNum(root,rank)
-- local rankImage=Util.GetGameObject(root,"Content/Base/SortNum/SortBg"):GetComponent("Image")
-- local rankText=Util.GetGameObject(root,"Content/Base/SortNum/SortBg/SortText"):GetComponent("Text")
--
-- rankImage.sprite=SetRankNumFrame(rank)
-- rankText.text = rank > 3 and rank or ""
--end
--设置排名头标签
-- function this.SetTitle(root,rank)
-- local title=Util.GetGameObject(root,"Title")
-- this.CheckInfo(battleStage,root,rank)
-- title:SetActive(this.CheckActive(battleStage,battleTurn,battleState,rank))
-- end
--名次标签内容检测
-- function this.CheckInfo(stage,root,rank)
-- local titleBg=Util.GetGameObject(root,"Title/Bg"):GetComponent("Image")
-- local titleText=Util.GetGameObject(root,"Title/Bg/Text"):GetComponent("Text")
-- local f=function()
-- for i = 1, 7 do
-- if rank==i and i<=3 then
-- titleBg.sprite=Util.LoadSprite(TitleName[i])
-- titleText.text=TitleDesc[i]
-- titleText.color=TitleColor[i]
-- end
-- if rank>=5 then
-- titleBg.sprite=Util.LoadSprite(TitleName[4])
-- titleText.color=TitleColor[4]
-- end
-- end
-- if rank==5 then
-- titleText.text=TitleDesc[4]
-- elseif rank==9 then
-- titleText.text=TitleDesc[5]
-- elseif rank==17 then
-- titleText.text=TitleDesc[6]
-- elseif rank==33 then
-- titleText.text=TitleDesc[7]
-- end
-- end
-- if stage==TOP_MATCH_STAGE.CHOOSE then--1选拔赛阶段
-- if rank==1 then--直接显示128
-- titleBg.sprite=Util.LoadSprite(TitleName[4])
-- titleText.text=TitleDesc[7]
-- titleText.color=TitleColor[4]
-- end
-- elseif stage==TOP_MATCH_STAGE.ELIMINATION then--2 32强淘汰赛阶段
-- if rank == 1 then -- 第一个特殊处理
-- local curTurn = battleTurn
-- local maxTurn = ArenaTopMatchManager.GetEliminationMaxRound()
-- if curTurn <= 0 then curTurn = maxTurn end
-- local opTurn = maxTurn - curTurn + 1 --- 将服务器发过来的轮数倒序,方便计算
-- local groupNum = math.pow(2, opTurn)
-- if opTurn <= 3 then
-- titleBg.sprite = Util.LoadSprite(TitleName[opTurn])
-- titleText.color = TitleColor[opTurn]
-- else
-- titleBg.sprite = Util.LoadSprite(TitleName[4])
-- titleText.color = TitleColor[4]
-- end
-- titleText.text = groupNum .. " 强"
-- else
-- f()
-- end
-- elseif stage==TOP_MATCH_STAGE.OVER then --活动结束-2 仍显示名次标签
-- f()
-- end
-- end
--名次标签显隐状态检测
-- function this.CheckActive(stage,turn,state,rank)
-- -- 第一名永远显示
-- if rank == 1 then
-- return true
-- end
-- --
-- local open=false
-- local _turn
-- local f=function()
-- --若状态为3 控制数据结算时表现的及时性
-- if state==TOP_MATCH_TIME_STATE.OPEN_IN_END then
-- turn=turn+1
-- end
-- for j = 1, turn do
-- for i = 1, #TurnIndex do
-- if j==i then
-- _turn=TurnIndex[j]--返回唯一
-- end
-- end
-- if rank==math.pow(2,_turn)+1 then--显示4-128
-- open=true
-- break
-- elseif turn==6 and rank<=2 and state==3 then--显示1-2
-- open=rank==math.pow(2,0) or rank==math.pow(2,1)
-- break
-- else
-- open=false
-- end
-- end
-- end
-- if stage==TOP_MATCH_STAGE.CHOOSE then--1选拔赛阶段
-- open=rank==1
-- elseif stage==TOP_MATCH_STAGE.ELIMINATION then--2 32强淘汰赛阶段
-- f()
-- elseif stage==TOP_MATCH_STAGE.OVER then --活动结束-2 仍显示名次标签
-- turn=5
-- state=3
-- f()
-- end
-- return open
-- end
--设置头像
-- function this.SetHeadInfo(root,data)
-- local headObj=Util.GetGameObject(root,"Content/Base/Head")
-- if not this.playerHead[root] then
-- this.playerHead[root] = CommonPool.CreateNode(POOL_ITEM_TYPE.PLAYER_HEAD,headObj)
-- end
-- this.playerHead[root]:Reset()
-- this.playerHead[root]:SetScale(Vector3.one * 0.7)
-- this.playerHead[root]:SetHead(data[1].head)
-- this.playerHead[root]:SetFrame(data[1].headFrame)
-- this.playerHead[root]:SetLevel(data[1].level)
-- end
--设置出战阵容
-- function this.SetTeamInfo(root,teamData)
-- --设置出战角色头像
-- for i = 1, 5 do
-- local heroHeadBg = Util.GetGameObject(root, "Content/Base/Demons/Head_"..i)
-- local hearIcon = Util.GetGameObject(heroHeadBg, "Icon")
-- local heroTId = teamData[2].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.SetShowInfo(name,power,info1,info2)
-- name.text="<size=35%>玩家名:"..info1.."</size>"
-- power.text="<size=35%>战斗力:"..info2.."</size>"
-- end
--初始化滚动区信息
-- function this.InitRollingInfo(root)
-- local name= Util.GetGameObject(root,"Content/Base/Name"):GetComponent("Text")
-- local power= Util.GetGameObject(root,"Content/Base/Power"):GetComponent("Text")
-- name.text=""
-- power.text=""
-- return name,power
-- end
--初始化非滚动区信息
-- function this.InitUnRollingInfo()
-- this.myRank.text=""
-- this.myPower.text=""
-- end
--检查是否显示第一页 当切换页签时切换到第一页 当请求下一页时不跳转第一页
-- function this.CheckIsTop()
-- if this.istop then
-- this.scrollView:SetIndex(1)
-- this.istop =false
-- end
-- end
return ATM_RankView