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

369 lines
12 KiB
Lua

require("Base/BasePanel")
ArenaNewRewardPanel = Inherit(BasePanel)
local this = ArenaNewRewardPanel
local RewardList
local arenaReward = ConfigManager.GetConfig(ConfigName.ArenaReward)
local arenaRoom = ConfigManager.GetConfig(ConfigName.ArenaRoom)
local RewardConfig
local itemList = {} --优化itemView使用
local itemList2 = {} --优化itemView使用
local sorting = 0
local curRankType = 1
local tabNum = 1
local myrank = nil
local ActivityId = nil
local roomId = 1
local ConfigList = {
[3] = ConfigManager.GetConfig(ConfigName.ArenaReward), --竞技场奖励表
}
local vec = {
[2] = Vector2.New(916, 1002.7),
[3] = Vector2.New(916, 841.6),
[4] = Vector2.New(916, 944.9),
[5] = Vector2.New(916, 944.9),
}
-- Tab管理器
local TabBox = require("Modules/Common/TabBox")
local _TabImgData = { select = "r_tanchuang_button_003", default = "r_tanchuang_button_002", }
local _TabFontColor = {
default = Color.New(121 / 255, 76 / 255, 44 / 255, 1),
select = Color.New(121 / 255, 76 / 255, 44 / 255, 1)
}
local _TabData = {
[1] = { txt = Language[11019] },
[2] = { txt = Language[10121] },
}
local roomList = {}
for _, config in ConfigPairs(arenaRoom) do
if config.IsOpen == 1 then
local room = {}
room.default = "tab_img_norma"
room.select = "tab_img_select"
room.name = GetLanguageStrById(config.ArenaRoomName)
room.roomId = config.Id
--room.RankingSData =rankKingList[6]
table.insert(roomList, room)
end
end
local aaa = {}
aaa[1] = roomList
--初始化组件(用于子类重写)
function ArenaNewRewardPanel:InitComponent()
this.spLoader = SpriteLoader.New()
this.btnBack = Util.GetGameObject(self.gameObject, "Content/btnBack")
Util.GetGameObject(self.gameObject, "Content/Title"):GetComponent("Text").text = Language[10103]
this.maskImage = Util.GetGameObject(self.gameObject, "maskImage")
this.bottom = Util.GetGameObject(self.gameObject, "Content/bgImage/Bottom")
this.tabbox = Util.GetGameObject(this.bottom, "tabbox")
this.upTabBox = Util.GetGameObject(self.gameObject, "Content/bgImage/upTabBox")
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, "Content/bgImage/content1/scrollRect")
this.rankPre = Util.GetGameObject(self.gameObject, "Content/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 ArenaNewRewardPanel:BindEvent()
this.TabCtrl = TabBox.New()
this.TabCtrl:SetTabAdapter(this.TabAdapter)
this.TabCtrl:SetChangeTabCallBack(this.OnTabChange)
this.TabCtrl:Init(this.tabbox, _TabData)
this.upTabCtrl = TabBox.New()
this.upTabCtrl:SetTabAdapter(this.TabAdapter2)
this.upTabCtrl:SetChangeTabCallBack(this.OnTabChange2)
this.upTabCtrl:Init(this.upTabBox, roomList)
Util.AddClick(self.btnBack, function()
self:ClosePanel()
end)
Util.AddClick(self.maskImage, function()
self:ClosePanel()
end)
end
-- tab按钮自定义显示设置
function this.TabAdapter(tab, index, status)
local img = Util.GetGameObject(tab, "Image")
local txt = Util.GetGameObject(tab, "Text")
local red = Util.GetGameObject(tab, "redpot")
red:SetActive(false)
img:GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabImgData[status])
txt:GetComponent("Text").text = _TabData[index].txt
txt:GetComponent("Text").color = _TabFontColor[status]
end
-- tab改变回调事件
function this.OnTabChange(index)
tabNum = index
this.text2.text = ""
this.text2.color = UIColor.WRITE
if curRankType == 3 then
this.ShowRewardInfo()
this.text.text = Language[11020]
this.RefreshMyInfo()
end
end
-- tab按钮自定义显示设置
function this.TabAdapter2(tab, index, status)
local img = Util.GetGameObject(tab, "Image")
local txt = Util.GetGameObject(tab, "Text")
img:GetComponent("Image").sprite = this.spLoader:LoadSprite(roomList[index][status])
-- if status=="default" then
-- img:GetComponent("RectTransform").sizeDelta = Vector2.New(174,61)
-- elseif status=="select" then
-- img:GetComponent("RectTransform").sizeDelta = Vector2.New(174,74)
-- end
txt:GetComponent("Text").text = roomList[index].name
--txt:GetComponent("Text").color = _TabFontColor[status]
end
-- tab改变回调事件
function this.OnTabChange2(index)
this.text2.text = ""
this.text2.color = UIColor.WRITE
roomId = roomList[index].roomId
if curRankType == 3 then
this.ShowRewardInfo()
this.text.text = Language[11020]
this.RefreshMyInfo()
end
end
--添加事件监听(用于子类重写)
function ArenaNewRewardPanel:AddListener()
end
--移除事件监听(用于子类重写)
function ArenaNewRewardPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function ArenaNewRewardPanel:OnOpen(Type, myRank, activityId)
curRankType = Type
ActivityId = activityId or nil
myrank = tonumber(myRank)
RewardConfig = ConfigList[Type]
this.tabbox:SetActive(true)
this.TabCtrl:Init(this.tabbox, _TabData)
this.myRank:SetActive(false)
this.myInfo:SetActive(true)
this.tips:SetActive(false)
--this.scrollRect.transform.sizeDelta = vec[3]
--this.ScrollView.transform.sizeDelta = vec[3]
this.upTabCtrl:ChangeTab(activityId)
this.RefreshMyInfo()
this.ShowRewardInfo()
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function ArenaNewRewardPanel:OnShow()
end
function ArenaNewRewardPanel: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[10118] .. 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 not itemList2 then
itemList2 = {}
end
for i = 1, #itemList2 do
itemList2[i].gameObject: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
LogError("roomid==============" .. roomId .. " activityid==============" .. ActivityId)
--获取奖励
for k, value in ConfigPairs(arenaReward) do
if value.ArenaRoom == roomId then
if myrank <= 3 then
if myrank == value.MinRank then
if tabNum == 1 then
rewardList = value.DailyReward
elseif tabNum == 2 then
rewardList = value.SeasonReward
end
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
else
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 = {}
for _, configInfo in ConfigPairs(RewardConfig) do
if configInfo.ArenaRoom == roomId then
table.insert(RewardList, configInfo)
end
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
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 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
end
--界面关闭时调用(用于子类重写)
function ArenaNewRewardPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function ArenaNewRewardPanel:OnDestroy()
this.spLoader:Destroy()
itemList = {}
itemList2 = {}
end
return ArenaNewRewardPanel