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

268 lines
8.9 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)
2021-09-09 23:01:23 +08:00
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()
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
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
2021-09-07 17:05:46 +08:00
this.titleObj.gameObject:SetActive(true)
else
this.titleObj.gameObject:SetActive(false)
2021-08-31 15:10:27 +08:00
end
2021-09-09 23:01:23 +08:00
lastScore=PlayerPrefs.GetInt(PlayerManager.uid.."yuxulundaoScore")
aaa, rankData=WorldArenaManager.GetRankImgByScore(lastScore)
2021-09-10 15:50:24 +08:00
currScore=WorldArenaManager.GetNewScore()
2021-09-09 23:01:23 +08:00
lastRankId=rankData.Id
2021-09-11 15:05:37 +08:00
newResore=WorldArenaManager.GetNewScore()
2021-09-10 15:50:24 +08:00
LogError("upwindow lastScore=="..lastScore.." newScore=="..newResore)
local grade, newRankData=WorldArenaManager.GetRankImgByScore(WorldArenaManager.GetNewScore())
2021-09-09 23:01:23 +08:00
currRankId=newRankData.Id
--rankData=RankConfig[lastRankId]
2021-09-07 17:05:46 +08:00
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
return
end
this.rankName.text=rankData.RankName
this.scoreTxt.text=lastScore.."/"..rankData.ScoreUp
this.progress.fillAmount=(lastScore-minScore)/(maxScore-minScore)
2021-10-15 20:32:35 +08:00
--currRank=rankData.RankGrade
2021-10-16 15:27:03 +08:00
this.SetStarShow(rankData.RankLevel,rankData.RankGrade+1,self.sortingOrder)
2021-09-09 11:48:09 +08:00
this.StartProgressChange(function()
local callList2 = Stack.New()
local itemRandomDataList={}
local aaa={}
aaa.itemlist={}
2021-09-10 15:50:24 +08:00
aaa.itemlist= WorldArenaManager.GetReward()
LogError("itemlist len=="..#WorldArenaManager.GetReward())
LogError("aaa.itemlist len=="..#aaa.itemlist)
2021-09-14 10:10:57 +08:00
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
--星级和段位图标显示
function this.SetStarShow(star,grade,layer)
-- 设置星级
WorldArenaManager.SetStarShow(this.starList, rankData.RankLevel)
if currRank~=grade then
2021-09-07 17:05:46 +08:00
if titleLive then
destroy(titleLive)
2021-09-10 15:50:24 +08:00
titleLive=nil
2021-09-07 17:05:46 +08:00
currRank=grade
titleLive = poolManager:LoadAsset("fx_duanwei_0"..grade, PoolManager.AssetType.GameObject)
titleLive.transform:SetParent(this.rankImg.transform)
2021-10-14 15:38:47 +08:00
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
-- 根据物品列表数据显示物品
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
2021-09-10 15:50:24 +08:00
if callList:Count()~=0 then
callList:Pop()()
end
2021-09-07 17:05:46 +08:00
end
2021-08-31 15:10:27 +08:00
2021-09-07 17:05:46 +08:00
function WorldArenaUpRewardPanel:OnSortingOrderChange()
layer=self.sortingOrder
if titleLive then
SetParticleSortLayer(titleLive,self.sortingOrder)
end
2021-09-07 17:05:46 +08:00
end
--滚动条数
local num=0
--走的条数
local walkNum=0
2021-10-15 20:32:35 +08:00
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
this.TimeCounter=nil
end
2021-09-09 23:01:23 +08:00
2021-09-07 17:05:46 +08:00
local function _TimeUpdate()
2021-10-15 20:32:35 +08:00
2021-09-07 17:05:46 +08:00
--降低
if lastScore<currScore then
2021-10-16 15:27:03 +08:00
if maxScore-lastScore>15 and currScore-lastScore>15 then
changeNum=12
2021-10-15 18:39:46 +08:00
else
changeNum=1
end
lastScore=lastScore+changeNum
2021-09-07 17:05:46 +08:00
--经验条走到头
2021-10-16 15:27:03 +08:00
if lastScore==maxScore+1 then
2021-09-07 17:05:46 +08:00
walkNum=walkNum+1
if RankConfig[lastRankId+1] then
2021-09-11 15:05:37 +08:00
lastRankId=lastRankId+1
2021-09-07 17:05:46 +08:00
rankData=RankConfig[lastRankId]
maxScore=rankData.ScoreUp
minScore=rankData.ScoreLow
this.SetStarShow(rankData.RankLevel,rankData.RankGrade+1,layer)
end
end
else
2021-10-16 15:27:03 +08:00
if lastScore-minScore>15 and lastScore-currScore>15 then
changeNum=12
2021-10-15 18:39:46 +08:00
else
changeNum=1
end
lastScore=lastScore-changeNum
2021-10-16 15:27:03 +08:00
if lastScore==minScore-1 then
2021-09-07 17:05:46 +08:00
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
2021-09-11 15:05:37 +08:00
this.scoreTxt.text=lastScore.."/"..maxScore
this.progress.fillAmount=(lastScore-minScore)/(maxScore-minScore)
2021-09-07 17:05:46 +08:00
--走完了所有条目走最后半截
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
2021-09-11 15:05:37 +08:00
2021-09-07 17:05:46 +08:00
end
2021-10-14 15:38:47 +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()
WorldArenaManager.ClearReward()
2021-09-11 15:05:37 +08:00
PlayerPrefs.SetInt(PlayerManager.uid.."yuxulundaoScore",newResore)
2021-09-07 17:05:46 +08:00
if this.TimeCounter then
this.TimeCounter:Stop()
this.TimeCounter = nil
2021-09-10 15:50:24 +08:00
end
if titleLive then
destroy(titleLive)
titleLive=nil
end
2021-09-07 17:05:46 +08:00
end
2021-08-31 15:10:27 +08:00
return WorldArenaUpRewardPanel