miduo_client/Assets/ManagedResources/~Lua/Modules/WorldArena/WorldArenaRankRewardPanel.lua

343 lines
13 KiB
Lua

require("Base/BasePanel")
WorldArenaRankRewardPanel = Inherit(BasePanel)
local this = WorldArenaRankRewardPanel
local RewardList
local GloActConfig = ConfigManager.GetConfig(ConfigName.GlobalActivity)
local arenaReward = ConfigManager.GetConfig(ConfigName.ArenaReward)
local godSetting = ConfigManager.GetConfig(ConfigName.GodSacrificeSetting)
local godRewardConfig = ConfigManager.GetConfig(ConfigName.GodSacrificeConfig)
local itemList = {}--优化itemView使用
local itemList2 = {}--优化itemView使用
local sorting = 0
local curRankType = 1
local tabNum = 1
local myrank = nil
local ActivityId = nil
local ConfigList = {
[1] = ConfigManager.GetConfig(ConfigName.MServerRankConfig),--段位奖励
[2] = ConfigManager.GetConfig(ConfigName.MServerRankReward),--排行奖励
}
-- Tab管理器
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 = {
[1]= {txt = "段位奖励"},
[2]= {txt = "排名奖励"},
}
--初始化组件(用于子类重写)
function WorldArenaRankRewardPanel:InitComponent()
this.spLoader = SpriteLoader.New()
this.arenaBottom = Util.GetGameObject(self.gameObject, "ArenaBottom")
this.tabbox = Util.GetGameObject(self.gameObject, "tabbox")
this.btnBack = Util.GetGameObject(self.gameObject, "btnBack")
this.Title = Util.GetGameObject(self.gameObject, "Title"):GetComponent("Text")
this.Title.text="奖励"
this.tipText = Util.GetGameObject(self.gameObject, "content1/tipText"):GetComponent("Text")
this.myRank = Util.GetGameObject(self.gameObject, "content1/myRank")
this.myRankNum = Util.GetGameObject(self.gameObject, "content1/myRank/num"):GetComponent("Text")
this.rankTitle= Util.GetGameObject(self.gameObject, "content1/bg (1)/Rank"):GetComponent("Text")
this.text = Util.GetGameObject(this.arenaBottom, "tips/Text"):GetComponent("Text")
this.text2 = Util.GetGameObject(this.arenaBottom, "tips/Text2"):GetComponent("Text")
local v2 = Util.GetGameObject(self.gameObject, "content1/scrollRect"):GetComponent("RectTransform").rect
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(self.gameObject, "content1/scrollRect").transform,
Util.GetGameObject(self.gameObject, "content1/itemPre"), nil, Vector2.New(-v2.x*2, -v2.y*2), 1, 1, Vector2.New(10,10))
this.ScrollView.moveTween.MomentumAmount = 1
this.ScrollView.moveTween.Strength = 1
end
--绑定事件(用于子类重写)
function WorldArenaRankRewardPanel:BindEvent()
this.TabCtrl = TabBox.New()
this.TabCtrl:SetTabAdapter(this.TabAdapter)
this.TabCtrl:SetChangeTabCallBack(this.OnTabChange)
this.TabCtrl:Init(this.tabbox, _TabData,1)
this.rankTitle.text="段位"
Util.AddClick(self.btnBack, function()
self:ClosePanel()
end)
end
-- tab按钮自定义显示设置
function this.TabAdapter(tab, index, status)
local img = Util.GetGameObject(tab, "Image")
local txt = Util.GetGameObject(tab, "Text")
img:GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabImgData[status])
if curRankType == 3 then
txt:GetComponent("Text").text = _TabData[index].txt
end
txt:GetComponent("Text").color = _TabFontColor[status]
end
-- tab改变回调事件
function this.OnTabChange(index)
tabNum = index
this.text2.text = ""
this.text2.color = UIColor.WRITE
if curRankType == 2 then
elseif curRankType == 3 then
this.ShowRewardInfo()
this.text.text = Language[10758]
this.RefreshMyInfo()
end
end
--添加事件监听(用于子类重写)
function WorldArenaRankRewardPanel:AddListener()
end
--移除事件监听(用于子类重写)
function WorldArenaRankRewardPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function WorldArenaRankRewardPanel:OnOpen(myRank,activityId)
curRankType = 3
ActivityId = activityId or nil
myrank = tonumber(myRank)
this.arenaBottom:SetActive(false)--如果是竞技场的话显示一堆零碎
this.ShowRewardInfo()
this.SetMyRank()
this.rankTitle.text="段位"
--竞技场和社稷大典的特殊处理
if curRankType == 3 then
this.TabCtrl:Init(this.tabbox, _TabData)
Util.GetGameObject(this.arenaBottom, "mask"):SetActive(true)
Util.GetGameObject(this.arenaBottom, "Image1"):SetActive(true)
Util.GetGameObject(this.arenaBottom, "myInfo"):SetActive(true)
this.RefreshMyInfo()
end
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function WorldArenaRankRewardPanel:OnShow()
end
function WorldArenaRankRewardPanel:OnSortingOrderChange()
for i, v in pairs(itemList) do
for j = 1, #v do
v[j]:SetEffectLayer(self.sortingOrder)
end
end
for i, v in pairs(itemList2) do
for j = 1, #v do
v[j]:SetEffectLayer(self.sortingOrder)
end
end
sorting = self.sortingOrder
end
function this.SetMyRank()
if myrank and myrank > 0 then
this.myRank:SetActive(true)
this.myRankNum.text = Language[10103]..myrank
else
this.myRank:SetActive(false)
end
end
--如果是竞技场的话显示下面一堆的东西
function this.RefreshMyInfo()
local sortNumTabs = {}
local rewardList = {}
local myInfo = Util.GetGameObject(this.arenaBottom, "myInfo")
local norank = Util.GetGameObject(this.arenaBottom, "myInfo/myrank")
norank:SetActive(false)
for i = 1, 4 do
sortNumTabs[i] = Util.GetGameObject(myInfo, "sortNum/sortNum ("..i..")")
sortNumTabs[i]:SetActive(false)
end
if myrank and myrank > 0 then
if myrank < 4 then
sortNumTabs[myrank]:SetActive(true)
else
sortNumTabs[4]:SetActive(true)
Util.GetGameObject(sortNumTabs[4], "rankNumberText"):GetComponent("Text").text = myrank
end
if not itemList2 then
itemList2 = {}
end
for i = 1, #itemList2 do
itemList2[i].gameObject:SetActive(false)
end
--获取奖励
--if curRankType == 3 then--竞技场
for k,value in ConfigPairs(ConfigList[2]) do
-- if myrank > 3 then
if myrank >= value.MinRank and myrank <= value.MaxRank then
if tabNum == 1 then
rewardList = value.SeasonRewardShow
elseif tabNum == 2 then
rewardList = value.SeasonRewardShow
end
end
-- end
end
--end
--显示奖励
for i = 1, #rewardList do
if itemList2[i] then
itemList2[i]:OnOpen(false, rewardList[i], 0.75,false,false,false,sorting)
else
itemList2[i] = SubUIManager.Open(SubUIConfig.ItemView, Util.GetGameObject(myInfo, "content").transform)
itemList2[i]:OnOpen(false, rewardList[i], 0.75,false,false,false,sorting)
end
itemList2[i].gameObject:SetActive(true)
end
else
norank:SetActive(true)
norank:GetComponent("Text").text = Language[10036]
end
end
function this.ShowRewardInfo()
RewardList = {}
if tabNum==1 then
this.rankTitle.text="段位"
for _, configInfo in ConfigPairs(ConfigList[tabNum]) do
if configInfo.Id~=1 then
table.insert(RewardList,configInfo)
end
end
table.sort(RewardList,function(a,b)
return a.RankId>b.RankId
end)
this.arenaBottom.gameObject:SetActive(false)
this.ScrollView:SetRectTransform(Vector2.New(916,1040))
this.ScrollView:SetRectPosition(Vector3.New(0,0,0))
elseif tabNum==2 then
this.rankTitle.text="排名"
for _, configInfo in ConfigPairs(ConfigList[tabNum]) do
table.insert(RewardList,configInfo)
end
this.arenaBottom.gameObject:SetActive(true)
this.ScrollView:SetRectTransform(Vector2.New(916,850))
this.ScrollView:SetRectPosition(Vector3.New(0,100,0))
end
this.ScrollView:SetData(RewardList, function (index, go)
this.ActivityRewardSingleShow(go, RewardList[index],index)
end)
end
--一般奖励-单列
function this.ActivityRewardSingleShow(activityRewardGo,rewardData,index)
local sortNumTabs = {}
for i = 1, 4 do
sortNumTabs[i] = Util.GetGameObject(activityRewardGo, "sortNum/sortNum ("..i..")")
sortNumTabs[i]:SetActive(false)
end
local rankImg=Util.GetGameObject(activityRewardGo, "RankImg"):GetComponent("Image")
local rankTxt=Util.GetGameObject(activityRewardGo, "RankImg/Text"):GetComponent("Text")
local starPar=Util.GetGameObject(activityRewardGo, "RankImg/GameObject")
local starTabs={}
--段位排行榜
local star=0
if tabNum==1 then
rankImg.gameObject:SetActive(true)
rankImg.sprite=this.spLoader:LoadSprite("y_yuxulundao_xiaobiao_0"..rewardData.RankGrade+1)
star=rewardData.RankLevel
local scoreLow=rewardData.ScoreLow
if scoreLow<0 then
scoreLow=0
end
rankTxt.text=scoreLow.."-"..rewardData.ScoreUp
local starList={}
for i = 1, 5 do
table.insert(starList,Util.GetGameObject(activityRewardGo, "RankImg/GameObject/Image"..i))
end
for i = 1, #starList do
if i>star then
starList[i].gameObject:SetActive(false)
else
starList[i].gameObject:SetActive(true)
end
end
else
--排名排行榜
rankImg.gameObject:SetActive(false)
if rewardData.MaxRank == rewardData.MinRank then
if rewardData.MinRank < 4 then
sortNumTabs[ rewardData.MaxRank]:SetActive(true)
else
sortNumTabs[4]:SetActive(true)
Util.GetGameObject(sortNumTabs[4], "rankNumberText"):GetComponent("Text").text = rewardData.MinRank
end
else
sortNumTabs[4]:SetActive(true)
--if rewardData.MaxRank > 100 then
-- Util.GetGameObject(sortNumTabs[4], "rankNumberText"):GetComponent("Text").text =rewardData.MinRank-1 .."+"
-- else
Util.GetGameObject(sortNumTabs[4], "rankNumberText"):GetComponent("Text").text =rewardData.MinRank .."-".. rewardData.MaxRank
--end
end
end
if not itemList[activityRewardGo.name] then
itemList[activityRewardGo.name] = {}
end
for i = 1, #itemList[activityRewardGo.name] do
itemList[activityRewardGo.name][i].gameObject:SetActive(false)
end
if curRankType == 3 then--判断是否是竞技场
if tabNum == 1 then
if rewardData.FirstReward then
for i = 1, #rewardData.FirstReward do
if itemList[activityRewardGo.name][i] then
itemList[activityRewardGo.name][i]:OnOpen(false, rewardData.FirstReward[i], 0.75,false,false,false,sorting)
else
itemList[activityRewardGo.name][i] = SubUIManager.Open(SubUIConfig.ItemView, Util.GetGameObject(activityRewardGo, "content").transform)
itemList[activityRewardGo.name][i]:OnOpen(false, rewardData.FirstReward[i], 0.75,false,false,false,sorting)
end
itemList[activityRewardGo.name][i].gameObject:SetActive(true)
end
end
elseif tabNum == 2 then
for i = 1, #rewardData.SeasonRewardShow do
if itemList[activityRewardGo.name][i] then
itemList[activityRewardGo.name][i]:OnOpen(false, rewardData.SeasonRewardShow[i], 0.75,false,false,false,sorting)
else
itemList[activityRewardGo.name][i] = SubUIManager.Open(SubUIConfig.ItemView, Util.GetGameObject(activityRewardGo, "content").transform)
itemList[activityRewardGo.name][i]:OnOpen(false, rewardData.SeasonRewardShow[i], 0.75,false,false,false,sorting)
end
itemList[activityRewardGo.name][i].gameObject:SetActive(true)
end
end
end
end
--界面关闭时调用(用于子类重写)
function WorldArenaRankRewardPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function WorldArenaRankRewardPanel:OnDestroy()
this.spLoader:Destroy()
itemList = {}
itemList2 = {}
end
return WorldArenaRankRewardPanel