miduo_client/Assets/ManagedResources/~Lua/Modules/GeneralPanel/GeneralRankRewardPanel.lua

395 lines
15 KiB
Lua

require("Base/BasePanel")
GeneralRankRewardPanel = Inherit(BasePanel)
local this = GeneralRankRewardPanel
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 RewardConfig
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.ActivityRankingReward),--一般奖励表
[2] = ConfigManager.GetConfig(ConfigName.GodSacrificeConfig),--社稷大典奖励表
[3] = ConfigManager.GetConfig(ConfigName.ArenaReward),--竞技场奖励表
[4] = ConfigManager.GetConfig(ConfigName.QijieRanking),--七界试炼
}
local vec = {
[2] = Vector2.New(916,1002.7),
[3] = Vector2.New(916,841.6),
[4] = Vector2.New(916,944.9),
}
-- 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 = Language[10755]},
[2]= {txt = Language[10106]},
}
local _TabData2 = {
[1]= {txt = Language[10756]},
[2]= {txt = Language[10757]},
}
--初始化组件(用于子类重写)
function GeneralRankRewardPanel:InitComponent()
this.spLoader = SpriteLoader.New()
this.btnBack = Util.GetGameObject(self.gameObject, "btnBack")
this.bottom = Util.GetGameObject(self.gameObject, "bgImage/Bottom")
this.tabbox = Util.GetGameObject(this.bottom, "tabbox")
this.myRank = Util.GetGameObject(this.bottom, "MyRank")
this.myRankNum = Util.GetGameObject(this.myRank, "num"):GetComponent("Text")
this.myInfo = Util.GetGameObject(this.bottom, "MyInfo")
this.norank = Util.GetGameObject(this.bottom, "MyInfo/myrank")
this.tips = Util.GetGameObject(this.bottom, "Tips")
this.text = Util.GetGameObject(this.bottom, "Tips/Text"):GetComponent("Text")
this.text2 = Util.GetGameObject(this.bottom, "Tips/Text2"):GetComponent("Text")
this.scrollRect = Util.GetGameObject(self.gameObject, "bgImage/content1/scrollRect")
this.rankPre = Util.GetGameObject(self.gameObject, "itemPre")
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.scrollRect.transform,
this.rankPre, nil, Vector2.New(this.scrollRect.transform.sizeDelta.x, this.scrollRect.transform.sizeDelta.y), 1, 1, Vector2.New(10,10))
this.ScrollView.moveTween.MomentumAmount = 1
this.ScrollView.moveTween.Strength = 1
this.ScrollView.elastic = false
end
--绑定事件(用于子类重写)
function GeneralRankRewardPanel:BindEvent()
this.TabCtrl = TabBox.New()
this.TabCtrl:SetTabAdapter(this.TabAdapter)
this.TabCtrl:SetChangeTabCallBack(this.OnTabChange)
this.TabCtrl:Init(this.tabbox, _TabData)
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 == 2 then
txt:GetComponent("Text").text = _TabData2[index].txt
elseif 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
this.ShowRewardInfo()
local type = tabNum == 1 and RANK_TYPE.GOLD_EXPER or RANK_TYPE.CELEBRATION_GUILD
DynamicActivityManager.SheJiGetRankData(type,ActivityId,function(allRankData,myRankData)
local rank = myRankData.rank > 0 and myRankData.rank or Language[10036]
this.text.text = Language[10103]..rank
end)
if type == RANK_TYPE.GOLD_EXPER then
this.text2.text = string.format("前10名奖励需个人贡献值达到%s分才能获取", 2500)
this.text2.color = UIColor.RED
end
elseif curRankType == 3 then
this.ShowRewardInfo()
this.text.text = Language[10758]
this.RefreshMyInfo()
elseif curRankType == 4 then
this.ShowRewardInfo()
this.text.text = "排行奖励将在周日23:30后通过邮件发放"
this.RefreshMyInfo()
end
end
--添加事件监听(用于子类重写)
function GeneralRankRewardPanel:AddListener()
end
--移除事件监听(用于子类重写)
function GeneralRankRewardPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function GeneralRankRewardPanel:OnOpen(Type,myRank,activityId)
curRankType = Type
ActivityId = activityId or nil
myrank = tonumber(myRank)
RewardConfig = ConfigList[Type]
if curRankType == 2 then--社稷大典的特殊处理
-- this.arenaBottom:SetActive(true)
this.tabbox:SetActive(true)
this.TabCtrl:Init(this.tabbox, _TabData2)
this.myRank:SetActive(true)
this.myInfo:SetActive(false)
this.tips:SetActive(false)
this.scrollRect.transform.sizeDelta = vec[curRankType]
this.ScrollView.transform.sizeDelta = vec[curRankType]
this.SetMyRank()
elseif curRankType == 3 then--竞技场特殊处理
this.tabbox:SetActive(true)
this.TabCtrl:Init(this.tabbox, _TabData)
this.myRank:SetActive(false)
this.myInfo:SetActive(true)
this.tips:SetActive(true)
this.scrollRect.transform.sizeDelta = vec[curRankType]
this.ScrollView.transform.sizeDelta = vec[curRankType]
this.RefreshMyInfo()
elseif curRankType == 4 then
this.tabbox:SetActive(false)
this.myRank:SetActive(false)
this.myInfo:SetActive(true)
this.tips:SetActive(true)
this.scrollRect.transform.sizeDelta = vec[curRankType]
this.ScrollView.transform.sizeDelta = vec[curRankType]
this.RefreshMyInfo()
end
this.ShowRewardInfo()
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function GeneralRankRewardPanel:OnShow()
end
function GeneralRankRewardPanel: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 = {}
this.norank:SetActive(false)
for i = 1, 4 do
sortNumTabs[i] = Util.GetGameObject(this.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[curRankType]) do
if myrank <= 3 then
if tabNum == 1 then
rewardList = ConfigList[curRankType][myrank].DailyReward
elseif tabNum == 2 then
rewardList = ConfigList[curRankType][myrank].SeasonReward
end
elseif myrank > 3 then
if myrank >= value.MinRank and myrank <= value.MaxRank then
if tabNum == 1 then
rewardList = value.DailyReward
elseif tabNum == 2 then
rewardList = value.SeasonReward
end
end
end
end
elseif curRankType == 2 then--社稷大典排行
local configList = {}
configList = ConfigManager.GetAllConfigsDataByKey(ConfigName.GodSacrificeConfig,"RewardType",tabNum)
for i = 1, #configList do
if myrank <= 3 then
rewardList = configList[myrank].RankingReward
elseif myrank > 3 then
if myrank >= configList[i].MinRank and myrank <= configList[i].MaxRank then
rewardList = configList[i].RankingReward
end
end
end
elseif curRankType == 4 then--七界试炼
for k,value in ConfigPairs(ConfigList[curRankType]) do
if myrank <= 3 then
rewardList = ConfigList[curRankType][myrank].RankingReward
elseif myrank > 3 then
if myrank >= value.MinRank and myrank <= value.MaxRank then
rewardList = value.RankingReward
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(this.myInfo, "content").transform)
itemList2[i]:OnOpen(false, rewardList[i], 0.75,false,false,false,sorting)
end
itemList2[i].gameObject:SetActive(true)
end
else
this.norank:SetActive(true)
this.norank:GetComponent("Text").text = Language[10036]
end
end
function this.ShowRewardInfo()
RewardList = {}
if curRankType == 1 then--活动类的排行榜
for _, configInfo in ConfigPairs(RewardConfig) do
if configInfo.ActivityId == ActivityId then
table.insert(RewardList,configInfo)
end
end
this.ScrollView:SetData(RewardList, function (index, go)
this.ActivityRewardSingleShow(go, RewardList[index],index)
end)
elseif curRankType == 3 or curRankType == 4 then--非活动类的排行榜(竞技场)
for _, configInfo in ConfigPairs(RewardConfig) do
table.insert(RewardList,configInfo)
end
this.ScrollView:SetData(RewardList, function (index, go)
this.ActivityRewardSingleShow(go, RewardList[index],index)
end)
elseif curRankType == 2 then--设计大典
local configList = {}
configList = ConfigManager.GetAllConfigsDataByDoubleKey(ConfigName.GodSacrificeConfig,"ActivityId",ActivityId,"RewardType",tabNum)
this.ScrollView:SetData(configList, function (index, go)
this.ActivityRewardSingleShow(go, configList[index],index)
end)
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
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
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
for i = 1, #rewardData.DailyReward do
if itemList[activityRewardGo.name][i] then
itemList[activityRewardGo.name][i]:OnOpen(false, rewardData.DailyReward[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.DailyReward[i], 0.75,false,false,false,sorting)
end
itemList[activityRewardGo.name][i].gameObject:SetActive(true)
end
elseif tabNum == 2 then
for i = 1, #rewardData.SeasonReward do
if itemList[activityRewardGo.name][i] then
itemList[activityRewardGo.name][i]:OnOpen(false, rewardData.SeasonReward[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.SeasonReward[i], 0.75,false,false,false,sorting)
end
itemList[activityRewardGo.name][i].gameObject:SetActive(true)
end
end
else
for i = 1, #rewardData.RankingReward do
if itemList[activityRewardGo.name][i] then
itemList[activityRewardGo.name][i]:OnOpen(false, rewardData.RankingReward[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.RankingReward[i], 0.75,false,false,false,sorting)
end
itemList[activityRewardGo.name][i].gameObject:SetActive(true)
end
end
end
--界面关闭时调用(用于子类重写)
function GeneralRankRewardPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function GeneralRankRewardPanel:OnDestroy()
this.spLoader:Destroy()
itemList = {}
itemList2 = {}
end
return GeneralRankRewardPanel