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

235 lines
7.7 KiB
Lua
Raw Normal View History

2021-08-31 15:10:27 +08:00
require("Base/BasePanel")
WorldArenaUpRewardPanel = Inherit(BasePanel)
local this = WorldArenaUpRewardPanel
2021-09-07 17:05:46 +08:00
local RankConfig=ConfigManager.GetConfig(ConfigName.MServerRankConfig)
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local lastRankId=10
local currRankId=12
local lastScore=180
local currScore=212
local rankData
local maxScore
local minScore
local layer
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()
2021-09-07 17:05:46 +08:00
this.titleImg=Util.GetGameObject(self.gameObject, "Bg/bg/title"):GetComponent("Image")
this.titleObj=Util.GetGameObject(self.gameObject, "Bg/bg")
2021-08-31 15:10:27 +08:00
this.titleImg.sprite=this.spLoader:LoadSprite("y_yuxulundao_duanweichongzhi_zh")
this.rankName=Util.GetGameObject(self.gameObject, "Bg/rankName"):GetComponent("Text")
2021-09-07 17:05:46 +08:00
this.rankImg=Util.GetGameObject(self.gameObject, "Bg/RankImg")
2021-08-31 15:10:27 +08:00
this.scoreTxt=Util.GetGameObject(self.gameObject, "Bg/hangOnTime"):GetComponent("Text")
this.text1=Util.GetGameObject(self.gameObject, "Bg/upRewardObj/userNameText"):GetComponent("Text")
this.text1.text="进阶奖励"
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)
this.grid=Util.GetGameObject(self.gameObject, "Bg/upRewardObj/scroll/grid")
2021-08-31 15:10:27 +08:00
this.progress=Util.GetGameObject(self.gameObject, "Bg/progressbar/progress"):GetComponent("Image")
2021-09-07 17:05:46 +08:00
this.btn_close=Util.GetGameObject(self.gameObject, "maskImage")
this.starList={}
for i = 1, 5 do
table.insert(this.starList,Util.GetGameObject(self.gameObject, "Bg/starPar/Image"..i))
end
2021-08-31 15:10:27 +08:00
end
2021-09-07 17:05:46 +08:00
--绑定事件(用于子类重写)
function WorldArenaUpRewardPanel:BindEvent()
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
function WorldArenaUpRewardPanel:OnOpen(...)
--赛季重制显示重置图标
if true then
this.titleObj.gameObject:SetActive(true)
else
this.titleObj.gameObject:SetActive(false)
2021-08-31 15:10:27 +08:00
end
2021-09-07 17:05:46 +08:00
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)
AddParticleSortLayer(titleLive,self.sortingOrder)
if not rankData then
return
end
this.rankName.text=rankData.RankName
this.scoreTxt.text=lastScore.."/"..rankData.ScoreUp
this.progress.fillAmount=(lastScore-minScore)/(maxScore-minScore)
currRank=rankData.RankGrade
this.SetStarShow(rankData.RankLevel,rankData.RankGrade,self.sortingOrder)
2021-09-09 11:48:09 +08:00
this.StartProgressChange(function()
local callList2 = Stack.New()
local itemRandomDataList={}
local aaa={}
aaa.itemlist={}
for i = 1, 10 do
local item={}
item.itemId=16
item.itemNum=100
table.insert(aaa.itemlist,item)
end
itemRandomDataList=BagManager.GetTableByBackDropData(aaa)
local baseContentList2={}
this.SetItemShow(aaa,itemRandomDataList,this.grid.transform,callList2,baseContentList2)
end)
2021-09-07 17:05:46 +08:00
end
--星级和段位图标显示
function this.SetStarShow(star,grade,layer)
for i = 1, #this.starList do
if i>rankData.RankLevel then
this.starList[i]:SetActive(false)
2021-08-31 15:10:27 +08:00
else
2021-09-07 17:05:46 +08:00
this.starList[i]:SetActive(true)
2021-08-31 15:10:27 +08:00
end
2021-09-07 17:05:46 +08:00
end
if currRank~=grade then
if titleLive then
destroy(titleLive)
LogError("grade=="..grade)
currRank=grade
titleLive = poolManager:LoadAsset("fx_duanwei_0"..grade, 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)
AddParticleSortLayer(titleLive,layer)
end
this.rankName.text=rankData.RankName
2021-08-31 15:10:27 +08:00
end
end
2021-09-07 17:05:46 +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
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
func()
end)
end
callList:Pop()()
end
2021-08-31 15:10:27 +08:00
2021-09-07 17:05:46 +08:00
function WorldArenaUpRewardPanel:OnSortingOrderChange()
layer=self.sortingOrder
end
--滚动条数
local num=0
--走的条数
local walkNum=0
--开始进度条滚动
2021-09-09 11:48:09 +08:00
function this.StartProgressChange(func)
2021-09-07 17:05:46 +08:00
if this.TimeCounter then
this.TimeCounter=nil
end
if lastRankId>currRankId then
num=lastRankId-currRankId
end
local function _TimeUpdate()
--降低
if lastScore<currScore then
lastScore=lastScore+1
--经验条走到头
if lastScore==maxScore 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
lastScore=lastScore-1
if lastScore==minScore 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
end
--走完了所有条目走最后半截
if lastScore==currScore then
if this.TimeCounter then
this.TimeCounter:Stop()
this.TimeCounter = nil
2021-09-09 11:48:09 +08:00
if func then
func()
end
2021-09-07 17:05:46 +08:00
end
end
this.scoreTxt.text=lastScore.."/"..maxScore
this.progress.fillAmount=(lastScore-minScore)/(maxScore-minScore)
end
this.TimeCounter = Timer.New(_TimeUpdate,0.05, -1, true)
this.TimeCounter:Start()
end
2021-08-31 15:10:27 +08:00
2021-09-07 17:05:46 +08:00
function this.OnClose()
if this.TimeCounter then
this.TimeCounter:Stop()
this.TimeCounter = nil
end
end
2021-08-31 15:10:27 +08:00
return WorldArenaUpRewardPanel