PGRData/Script/matrix/xui/xuifubenbabeltower/XUiGridRankRewardItem.lua

48 lines
1.6 KiB
Lua
Raw Normal View History

local XUiGridRankRewardItem = XClass(nil, "XUiGridRankRewardItem")
function XUiGridRankRewardItem:Ctor(ui)
self.GameObject = ui.gameObject
self.Transform = ui.transform
self.MailRewardList = {}
XTool.InitUiObject(self)
end
function XUiGridRankRewardItem:Init(uiRoot)
self.UiRoot = uiRoot
end
-- 刷新排名奖励
function XUiGridRankRewardItem:Refresh(rewardInfo)
local minRank = rewardInfo.MinRank * 100
local maxRank = rewardInfo.MaxRank * 100
if minRank <= 0 then
self.TxtScore.text = string.format("%d%%", maxRank)
else
self.TxtScore.text = string.format("%d%%-%d%%", minRank, maxRank)
end
local _, curRank, totalRank = XDataCenter.FubenBabelTowerManager.GetScoreInfos()
local playerRank = (curRank * 1.0) / totalRank * 100
self.PanelCurRank.gameObject:SetActiveEx(playerRank > minRank and playerRank <= maxRank)
2024-09-01 20:49:41 +00:00
---@type XMailAgency
local mailAgency = XMVCA:GetAgency(ModuleId.XMail)
local rewardList = mailAgency:GetRewardList(rewardInfo.MailId)
for i, reward in pairs(rewardList or {}) do
if not self.MailRewardList[i] then
local ui = CS.UnityEngine.Object.Instantiate(self.GridReward)
ui.transform:SetParent(self.PanelRewardContent, false)
local common = XUiGridCommon.New(self.UiRoot, ui)
self.MailRewardList[i] = common
end
self.MailRewardList[i]:Refresh(reward)
end
for i = #rewardList + 1, #self.MailRewardList do
self.MailRewardList[i].GameObject:SetActiveEx(false)
end
end
return XUiGridRankRewardItem