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

257 lines
9.5 KiB
Lua
Raw Normal View History

2025-03-14 11:58:20 +08:00
require("Base/BasePanel")
2021-08-31 15:10:27 +08:00
WorldArenaUpRewardPanel = Inherit(BasePanel)
local this = WorldArenaUpRewardPanel
2024-09-06 10:38:56 +08:00
local RankConfig = ConfigManager.GetConfig(ConfigName.MServerRankConfig)
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local lastRankId = 0
local currRankId = 0
local lastScore = 0
local currScore = 0
2021-09-07 17:05:46 +08:00
local rankData
local maxScore
local minScore
local layer
2021-09-09 23:01:23 +08:00
local aaa
2021-08-31 15:10:27 +08:00
--初始化组件(用于子类重写)
2021-09-07 17:05:46 +08:00
function WorldArenaUpRewardPanel:InitComponent()
2021-08-31 15:10:27 +08:00
this.spLoader = SpriteLoader.New()
2024-09-06 10:38:56 +08:00
this.titleImg = Util.GetGameObject(self.gameObject, "Bg/bg/title"):GetComponent("Image")
this.titleObj = Util.GetGameObject(self.gameObject, "Bg/bg")
this.titleImg.sprite = this.spLoader:LoadSprite("y_yuxulundao_duanweichongzhi_zh")
this.rankName = Util.GetGameObject(self.gameObject, "Bg/rankName"):GetComponent("Text")
this.rankImg = Util.GetGameObject(self.gameObject, "Bg/RankImg")
this.scoreTxt = Util.GetGameObject(self.gameObject, "Bg/hangOnTime"):GetComponent("Text")
this.text1 = Util.GetGameObject(self.gameObject, "Bg/upRewardObj/userNameText"):GetComponent("Text")
this.text1.text = Language[12988]
this.tipImg = Util.GetGameObject(self.gameObject, "tipImage"):GetComponent("Image")
this.tipImg.sprite = this.spLoader:LoadSprite("r_zhandou_rewardtap2_zh")
this.rewardObj = Util.GetGameObject(self.gameObject, "Bg/upRewardObj")
2021-09-07 17:05:46 +08:00
this.rewardObj:SetActive(false)
2024-09-06 10:38:56 +08:00
this.grid = Util.GetGameObject(self.gameObject, "Bg/upRewardObj/scroll/grid")
this.progress = Util.GetGameObject(self.gameObject, "Bg/progressbar/progress"):GetComponent("Image")
this.btn_close = Util.GetGameObject(self.gameObject, "maskImage")
this.starList = {}
2021-09-07 17:05:46 +08:00
for i = 1, 5 do
2024-09-06 10:38:56 +08:00
table.insert(this.starList, Util.GetGameObject(self.gameObject, "Bg/starPar/Image" .. i))
2021-09-07 17:05:46 +08:00
end
2021-08-31 15:10:27 +08:00
end
2024-09-06 10:38:56 +08:00
2021-09-07 17:05:46 +08:00
--绑定事件(用于子类重写)
function WorldArenaUpRewardPanel:BindEvent()
2024-09-06 10:38:56 +08:00
Util.AddClick(self.btn_close, function()
self:ClosePanel()
end)
2021-08-31 15:10:27 +08:00
end
2021-09-07 17:05:46 +08:00
local titleLive
local currRank
2021-09-11 15:05:37 +08:00
local newResore
2021-09-10 15:50:24 +08:00
function WorldArenaUpRewardPanel:OnOpen(data)
2021-09-07 17:05:46 +08:00
--赛季重制显示重置图标
2021-09-10 15:50:24 +08:00
if data then
2024-09-06 10:38:56 +08:00
this.titleObj.gameObject:SetActive(true)
2021-09-07 17:05:46 +08:00
else
2024-09-06 10:38:56 +08:00
this.titleObj.gameObject:SetActive(false)
2021-08-31 15:10:27 +08:00
end
2024-09-06 10:38:56 +08:00
lastScore = PlayerPrefs.GetInt(PlayerManager.uid .. "yuxulundaoScore")
aaa, rankData = WorldArenaManager.GetRankImgByScore(lastScore)
currScore = WorldArenaManager.GetNewScore()
lastRankId = rankData.Id
newResore = WorldArenaManager.GetNewScore()
LogError("upwindow lastScore==" .. lastScore .. " newScore==" .. newResore)
local grade, newRankData = WorldArenaManager.GetRankImgByScore(WorldArenaManager.GetNewScore())
currRankId = newRankData.Id
--rankData=RankConfig[lastRankId]
minScore = rankData.ScoreLow
maxScore = rankData.ScoreUp
currRank = rankData.RankGrade + 1
titleLive = poolManager:LoadAsset("fx_duanwei_0" .. currRank, PoolManager.AssetType.GameObject)
titleLive.transform:SetParent(this.rankImg.transform)
titleLive.transform.localPosition = Vector3.New(0, -600, 0)
titleLive.transform.localScale = Vector3.New(1, 1, 1)
SetParticleSortLayer(titleLive, self.sortingOrder)
2021-09-07 17:05:46 +08:00
if not rankData then
2024-09-06 10:38:56 +08:00
return
2021-09-07 17:05:46 +08:00
end
2024-09-20 17:32:50 +08:00
this.rankName.text = GetLanguageStrById(rankData.RankName)
2024-09-06 10:38:56 +08:00
this.scoreTxt.text = lastScore .. "/" .. rankData.ScoreUp
this.progress.fillAmount = (lastScore - minScore) / (maxScore - minScore)
2021-10-15 20:32:35 +08:00
--currRank=rankData.RankGrade
2024-09-06 10:38:56 +08:00
this.SetStarShow(rankData.RankLevel, rankData.RankGrade + 1, self.sortingOrder)
2021-09-09 11:48:09 +08:00
this.StartProgressChange(function()
2024-09-06 10:38:56 +08:00
local callList2 = Stack.New()
local itemRandomDataList = {}
local aaa = {}
aaa.itemlist = {}
aaa.itemlist = WorldArenaManager.GetReward()
LogError("itemlist len==" .. #WorldArenaManager.GetReward())
LogError("aaa.itemlist len==" .. #aaa.itemlist)
if aaa.itemlist and #aaa.itemlist > 0 then
itemRandomDataList = BagManager.GetTableByBackDropData(aaa)
local baseContentList2 = {}
this.SetItemShow(aaa, itemRandomDataList, this.grid.transform, callList2, baseContentList2)
end
2021-09-09 11:48:09 +08:00
end)
2021-09-07 17:05:46 +08:00
end
--星级和段位图标显示
2024-09-06 10:38:56 +08:00
function this.SetStarShow(star, grade, layer)
-- 设置星级
WorldArenaManager.SetStarShow(this.starList, rankData.RankLevel)
if currRank ~= grade then
if titleLive then
destroy(titleLive)
titleLive = nil
currRank = grade
titleLive = poolManager:LoadAsset("fx_duanwei_0" .. grade, PoolManager.AssetType.GameObject)
titleLive.transform:SetParent(this.rankImg.transform)
if grade == 5 then
titleLive.transform.localPosition = Vector3.New(0, -500, 0)
titleLive.transform.localScale = Vector3.New(0.8, 0.8, 1)
else
titleLive.transform.localPosition = Vector3.New(0, -600, 0)
titleLive.transform.localScale = Vector3.New(1, 1, 1)
end
SetParticleSortLayer(titleLive, layer)
end
this.rankName.text = rankData.RankName
end
2021-08-31 15:10:27 +08:00
end
2021-09-07 17:05:46 +08:00
-- 根据物品列表数据显示物品
2024-09-06 10:38:56 +08:00
function this.SetItemShow(drop, dataList, transform, callList, baseContentList)
this.rewardObj:SetActive(true)
BagManager.OnShowTipDropNumZero(drop)
if drop == nil then return end
for i = 1, #dataList do
dataList[i].itemConfig = itemConfig[dataList[i].sId]
end
--self:ItemDataListSort(dataList)
for i = 1, math.max(#dataList, #baseContentList) do
local go = baseContentList[i]
if not go then
go = SubUIManager.Open(SubUIConfig.ItemView, transform)
go.gameObject.name = "frame" .. i
baseContentList[i] = go
end
go.gameObject:SetActive(false)
end
2021-08-31 15:10:27 +08:00
2024-09-06 10:38:56 +08:00
callList:Clear()
for i = #dataList, 1, -1 do
local view = baseContentList[i]
local curItemData = dataList[i]
view:OnOpen(true, curItemData, 1.15, true, true, false, layer)
--view.gameObject:SetActive(false)
callList:Push(function()
local func = function()
view.gameObject:SetActive(true)
local btn = Util.GetGameObject(view.gameObject, "item/frame"):GetComponent("Button")
btn.enabled = false
PlayUIAnim(view.gameObject, function()
btn.enabled = true
end)
Timer.New(function()
isPopGetSSR = false
if callList:Count() ~= 0 then
callList:Pop()()
end
end, 0.1):Start()
end
2021-08-31 15:10:27 +08:00
2024-09-06 10:38:56 +08:00
func()
end)
end
if callList:Count() ~= 0 then
callList:Pop()()
end
end
2021-08-31 15:10:27 +08:00
2021-09-07 17:05:46 +08:00
function WorldArenaUpRewardPanel:OnSortingOrderChange()
2024-09-06 10:38:56 +08:00
layer = self.sortingOrder
if titleLive then
SetParticleSortLayer(titleLive, self.sortingOrder)
end
2021-09-07 17:05:46 +08:00
end
--滚动条数
2024-09-06 10:38:56 +08:00
local num = 0
--走的条数
local walkNum = 0
local changeNum = 1
2021-09-07 17:05:46 +08:00
--开始进度条滚动
2021-09-09 11:48:09 +08:00
function this.StartProgressChange(func)
2021-09-07 17:05:46 +08:00
if this.TimeCounter then
2024-09-06 10:38:56 +08:00
this.TimeCounter = nil
2021-09-07 17:05:46 +08:00
end
2021-09-09 23:01:23 +08:00
2021-09-07 17:05:46 +08:00
local function _TimeUpdate()
2024-09-06 10:38:56 +08:00
--降低
if lastScore < currScore then
if maxScore - lastScore > 15 and currScore - lastScore > 15 then
changeNum = 12
else
changeNum = 1
end
lastScore = lastScore + changeNum
--经验条走到头
if lastScore == maxScore + 1 then
walkNum = walkNum + 1
if RankConfig[lastRankId + 1] then
lastRankId = lastRankId + 1
rankData = RankConfig[lastRankId]
maxScore = rankData.ScoreUp
minScore = rankData.ScoreLow
this.SetStarShow(rankData.RankLevel, rankData.RankGrade + 1, layer)
end
end
else
if lastScore - minScore > 15 and lastScore - currScore > 15 then
changeNum = 12
else
changeNum = 1
2021-09-07 17:05:46 +08:00
end
2024-09-06 10:38:56 +08:00
lastScore = lastScore - changeNum
if lastScore == minScore - 1 then
walkNum = walkNum + 1
if RankConfig[lastRankId - 1] then
lastRankId = lastRankId - 1
rankData = RankConfig[lastRankId]
maxScore = rankData.ScoreUp
minScore = rankData.ScoreLow
this.SetStarShow(rankData.RankLevel, rankData.RankGrade + 1, layer)
end
2021-09-09 11:48:09 +08:00
end
2024-09-06 10:38:56 +08:00
end
this.scoreTxt.text = lastScore .. "/" .. maxScore
this.progress.fillAmount = (lastScore - minScore) / (maxScore - minScore)
--走完了所有条目走最后半截
if lastScore == currScore then
if this.TimeCounter then
this.TimeCounter:Stop()
this.TimeCounter = nil
if func then
func()
end
end
end
2021-09-07 17:05:46 +08:00
end
2024-09-06 10:38:56 +08:00
this.TimeCounter = Timer.New(_TimeUpdate, 0.005, -1, true)
2021-09-07 17:05:46 +08:00
this.TimeCounter:Start()
end
2021-08-31 15:10:27 +08:00
2021-09-10 15:50:24 +08:00
function this:OnClose()
2024-09-06 10:38:56 +08:00
WorldArenaManager.ClearReward()
PlayerPrefs.SetInt(PlayerManager.uid .. "yuxulundaoScore", newResore)
if this.TimeCounter then
this.TimeCounter:Stop()
this.TimeCounter = nil
end
if titleLive then
destroy(titleLive)
titleLive = nil
end
end
2021-08-31 15:10:27 +08:00
2024-09-06 10:38:56 +08:00
return WorldArenaUpRewardPanel