----- 易经宝库奖励预览弹窗 -----
local this = {}
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder=0
local activityId = 0
local activityType = 0
local heroID =0
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local artResourcesConfig=ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local pool=ConfigManager.GetConfig(ConfigName.WishActivityPool)
function this:InitComponent(gameObject)
this.title = Util.GetGameObject(gameObject,"title"):GetComponent("Text")
this.tip = Util.GetGameObject(gameObject,"tip"):GetComponent("Text")
this.itemGrid=Util.GetGameObject(gameObject,"panel/itemGrid")
this.LookDetailBtn=Util.GetGameObject(gameObject,"panel/Image3/updetail")
this.content=Util.GetGameObject(gameObject,"panel/content/grid/Text"):GetComponent("Text")
this.time=Util.GetGameObject(gameObject,"tip"):GetComponent("Text")
this.grid = Util.GetGameObject(gameObject,"panel/rate/grid")
this.pre = Util.GetGameObject(gameObject,"panel/rate/rateprefab")
this.ratePreList = {}
for i = 1,this.grid.transform.childCount do
this.ratePreList[i] = {}
this.ratePreList[i].go = this.grid.transform:GetChild(i-1)
this.ratePreList[i].star = Util.GetGameObject(this.ratePreList[i].go,"star"):GetComponent("Text")
this.ratePreList[i].name = Util.GetGameObject(this.ratePreList[i].go,"name"):GetComponent("Text")
this.ratePreList[i].rate = Util.GetGameObject(this.ratePreList[i].go,"rate"):GetComponent("Text")
end
end
function this:BindEvent()
Util.AddClick(this.LookDetailBtn,function()
this:LookDetailBtnAction()
end)
end
function this:LookDetailBtnAction()
if activityType == ActivityTypeDef.FindFairy then
UIManager.OpenPanel(UIName.HeroPreviewPanel,true,false)
else
LogPurple("打开魂印奖励预览")
end
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnShow(_parent,...)
parent=_parent
sortingOrder = _parent.sortingOrder
local args = {...}
local helpType = args[1]
local str = ConfigManager.TryGetConfigData(ConfigName.QAConfig,helpType).content
str = string.gsub(str,"{","")
str = string.gsub(str,"}","")
str = string.gsub(str,"|","\n")--换行
this.content.text= str
activityType = args[2]
local str2 = ActivityGiftManager.GetTimeStartToEnd(activityType)
if activityType == ActivityTypeDef.FindFairy then
this.LookDetailBtn.gameObject:SetActive(true)
else
this.LookDetailBtn.gameObject:SetActive(false)
end
this.time.text="概率有效期:"..str2
local poolUpType = args[3] or 0
local poolType = args[4] or 0
heroID = args[5]
local activityId = args[6]
LogGreen("poolUpType:"..poolUpType.." poolType:"..poolType)
if activityType == ActivityTypeDef.LimitUpHero and heroID then
local heroConfig=ConfigManager.TryGetConfigData(ConfigName.HeroConfig,heroID)
if heroConfig then
this:ShowUpItem(heroConfig,activityId)
end
else
local UpItemList=RecruitManager.GetRewardPreviewData(poolUpType)
local itemList = RecruitManager.GetRewardPreviewData(poolType)
local _upRateList,rateList = this:BuildRateData(activityType,itemList,UpItemList)
this:ReFreshUpItem(UpItemList,_upRateList)
end
end
function this:ReFreshUpItem(UpItem,rateList)
if(not this.listUpPre) then
this.listUpPre={}
end
for k,v in ipairs(this.listUpPre) do
v.gameObject:SetActive(false)
end
local index = 0
for n,m in ipairs(UpItem) do
for k,v in ipairs(rateList) do
if m.Reward[1] == v.id then
index = index + 1
if not this.listUpPre[index] then
this.listUpPre[index] = SubUIManager.Open(SubUIConfig.ItemView,this.itemGrid.transform)
end
this.listUpPre[index]:OnOpen(false, {m.Reward[1], m.Reward[2]}, 1.1, true)
this.listUpPre[index].name:GetComponent("Text").text=""..string.format("%.2f", (v.value/100000)*100) .."%"
this.listUpPre[index].gameObject:SetActive(true)
end
end
end
end
--限时up英雄
function this:ShowUpItem(config,actId)
local hero=SubUIManager.Open(SubUIConfig.ItemView,this.itemGrid.transform)
local wishUpConfig=ConfigManager.TryGetConfigDataByKey(ConfigName.WishActivityUp,"ActivityId",actId)
local num=0
for i = 1, #wishUpConfig.UpList do
if wishUpConfig.UpList[i][1]==heroID then
num=wishUpConfig.UpList[i][3]
end
end
hero:OnOpen(false,{config.Id,1},1.1,true)
hero.name:GetComponent("Text").text=""..string.format("%.2f", (num/100000)*100) .."%"
hero.gameObject:SetActive(true)
for k,v in ipairs(this.ratePreList) do
v.go.gameObject:SetActive(false)
end
-- table.sort(pool,function(a,b)
-- return a.GetRate>b.GetRate
-- end)
local rateList={}
local hero={tag="5星神将UP",name=config.ReadingName,value=num,Color=1}
for key, value in ConfigPairs(pool) do
local id=value.ItemId[1]
local itemConfig=ConfigManager.TryGetConfigData(ConfigName.ItemConfig,id)
local data={tag=itemConfig.Name,name=value.ItemId[2],value=value.GetRate,Color=0,sort=value.Sort}
table.insert(rateList,data)
end
table.sort(rateList,function(a,b)
return a.sort