miduo_client/Assets/ManagedResources/~Lua/Modules/GeneralPanel/View/GeneralBigPopup_RecrutDetai...

390 lines
17 KiB
Lua

----- 固定活动抽卡详情 -----
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.LookDetailBtn:SetActive(false)
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.secondTitle=Util.GetGameObject(gameObject,"panel/Image1/Text"):GetComponent("Text")
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()
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnShow(_parent,_Data)
parent=_parent
sortingOrder = _parent.sortingOrder
local args = _Data
local helpType = args[1]
local str = ConfigManager.TryGetConfigData(ConfigName.QAConfig,helpType).content
str = string.gsub(str,"{","<color=#D48A07>")
str = string.gsub(str,"}","</color>")
str = string.gsub(str,"|","\n")--换行
this.content.text= str
activityType = args[2]
local str2 = ActivityGiftManager.GetTimeStartToEnd(activityType)
this.time.text="概率有效期:"..str2
local poolUpType = args[3] or 0
local poolType = args[4] or 0
heroID = args[5]
local activityId = args[6]
local UpItemList = {}
local itemList = {}
--限时英雄up
this.secondTitle.text="本期UP内容"
if activityType == ActivityTypeDef.LimitUpHero then
local heroConfig=ConfigManager.TryGetConfigData(ConfigName.HeroConfig,heroID)
local wishUpConfig=ConfigManager.TryGetConfigDataByKey(ConfigName.WishActivityUp,"ActivityId",activityId)
local num,pro = 0,0
for i = 1, #wishUpConfig.UpList do
if wishUpConfig.UpList[i][1]==heroID then
num = wishUpConfig.UpList[i][3]
pro = wishUpConfig.UpList[i][5]
break
end
end
UpItemList = {[1] = {Reward = {heroConfig.Id,1},Weight = num}}
for k, v in ConfigPairs(pool) do
if v.Camp == pro or v.Camp == 0 then
local data = {Reward = v.ItemId,Weight = v.GetRate,sort = v.Sort}
table.insert(itemList,data)
end
end
table.sort(itemList,function(a,b)
return a.sort < b.sort
end)
else
UpItemList = RecruitManager.GetRewardPreviewData(poolUpType)
local dic={}
--乾坤宝盒特殊处理
if activityType == ActivityTypeDef.QianKunBox then
this.secondTitle.text="心愿魂印"
local souls=RecruitManager.GetWishEquipData()
local newList={}
for i = 1, #souls do
local value=UpItemList[i]
dic[value.Reward[1]]=souls[i]
value.Reward[1]=souls[i]
table.insert(newList,value)
end
UpItemList=newList
itemList = RecruitManager.GetRewardPreviewData(poolType)
for i = 1, #itemList do
if dic[itemList[i].Reward[1]] then
itemList[i].Reward[1]=dic[itemList[i].Reward[1]]
end
end
elseif activityType == ActivityTypeDef.LingShouBaoGe then
local rewardData,showData,curScore = DynamicActivityManager.LingShouBuildData()
local origiUpMonster = DynamicActivityManager.LingShouOrigiUpData()
itemList = RecruitManager.GetRewardPreviewData(poolType)
for i = 1,#itemList do
if itemList[i].Reward[1] == origiUpMonster.monsterId then
UpItemList = {[1] = {Reward = {showData.monsterId,1},WeightShow = itemList[i].WeightShow}}
break
end
end
elseif activityType == ActivityTypeDef.tiandihonglu then
local newList = {}
itemList = RecruitManager.GetRewardPreviewData(poolType)
local souls = RecruitManager.GetWishTailsManSoulChips()
for i = 1,#itemList do
for k,v in pairs(souls) do
if itemList[i].Reward[1] == v then
table.insert(newList,itemList[i])
break
end
end
end
UpItemList = newList
else
UpItemList = RecruitManager.GetRewardPreviewData(poolUpType)
itemList = RecruitManager.GetRewardPreviewData(poolType)
end
end
local _upRateList,rateList = this:BuildRateData(activityType,itemList,UpItemList)
this:ReFreshUpItem(UpItemList,_upRateList)
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="<color=#EDB64C>"..string.format("%.2f", (v.value/100000)*100) .."%</color>"
this.listUpPre[index].gameObject:SetActive(true)
end
end
end
end
local hero
function this:BuildRateData(actType,UpItem,upItemList)
local rateList = {}
local _upRateList = {}
if actType == ActivityTypeDef.QianKunBox then
_upRateList = this:ReculateUpHeroRate(UpItem,upItemList,"魂印UP!",ConfigName.EquipConfig)
rateList = this:RefreshSoulRate(UpItem,_upRateList,ItemType.HunYin)
elseif actType == ActivityTypeDef.LingShouBaoGe then
local rewardData,showData,curScore = DynamicActivityManager.RecrutDetailData(activityType)
for n,m in ipairs(upItemList) do
if m and m.Reward[1] == showData.monsterId then
local _config = ConfigManager.GetConfigData(ConfigName.SpiritAnimal,m.Reward[1])
local readingName = _config.ReadingName or _config.Name
table.insert(_upRateList,{id = m.Reward[1],tag="灵兽UP!",name = readingName,value = m.WeightShow,color = "AD4152"})
break
end
end
rateList = this:RefreshMonsterRate(UpItem,_upRateList)
elseif actType == ActivityTypeDef.XiangYaoDuoBao then
local rewardData,showData,curScore = DynamicActivityManager.XiangYaoBuildData(activityType)
for n,m in ipairs(upItemList) do
if m and m.Reward[1] == showData.monsterId then
local _config = ConfigManager.GetConfigData(ConfigName.HeroConfig,m.Reward[1])
local readingName = _config.ReadingName or _config.Name
table.insert(_upRateList,{id = m.Reward[1],tag="5星UP!",name = readingName,value = m.WeightShow,color = "AD4152"})
break
end
end
rateList = this:RefreshNewHeroRate(upItemList,_upRateList,"5星UP!",ConfigName.HeroConfig)
elseif actType == ActivityTypeDef.LimitUpHero then
for n,m in ipairs(upItemList) do
local itemConfig=ConfigManager.TryGetConfigData(ConfigName.ItemConfig, m.Reward[1])
table.insert(rateList,{id = m.Reward[1],tag = "5星神将UP!", name=itemConfig.Name,value = m.Weight,color = "AD4152"})
table.insert(_upRateList,{id = m.Reward[1],tag = "5星神将UP!", name=itemConfig.Name,value = m.Weight})
end
for n,m in ipairs(UpItem) do
local itemConfig=ConfigManager.TryGetConfigData(ConfigName.ItemConfig, m.Reward[1])
table.insert(rateList,{id = m.Reward[1],tag = itemConfig.Name, name=m.Reward[2],value = m.Weight,color = "BDB69C" })
end
elseif actType == ActivityTypeDef.tiandihonglu then
for n,m in ipairs(upItemList) do
local itemConfig=ConfigManager.TryGetConfigData(ConfigName.ItemConfig, m.Reward[1])
table.insert(_upRateList,{id = m.Reward[1],tag = "法宝碎片UP!", name=itemConfig.Name,value = m.Weight,color = "AD4152"})
end
rateList = this:RefreshSoulRate(UpItem,_upRateList,ItemType.talismanSoulChip)
end
for k,v in ipairs(this.ratePreList) do
v.go.gameObject:SetActive(false)
end
for n,m in ipairs(rateList) do
if not this.ratePreList[n] then
this.ratePreList[n] = {}
this.ratePreList[n].go = newObjToParent(this.pre,this.grid)
this.ratePreList[n].star = Util.GetGameObject(this.ratePreList[n].go,"star"):GetComponent("Text")
this.ratePreList[n].name = Util.GetGameObject(this.ratePreList[n].go,"name"):GetComponent("Text")
this.ratePreList[n].rate = Util.GetGameObject(this.ratePreList[n].go,"rate"):GetComponent("Text")
end
this.ratePreList[n].go.gameObject:SetActive(true)
this.ratePreList[n].star.text=string.format("<color=#%s>%s</color>",m.color,m.tag)
this.ratePreList[n].name.text=string.format("<color=#%s>%s</color>",m.color,m.name)
this.ratePreList[n].rate.text=string.format("<color=#%s>",m.color)..string.format("%.2f",(m.value/100000)*100).."%</color>"
end
return _upRateList,rateList
end
--通用计算权重功能
function this:ReculateRate(list)
local weight=0
for index, v in ipairs(list) do
weight=v.WeightShow+weight
end
return weight
end
function this:ReculateUpHeroRate(itemList,UpItemList,_tag,config)
local rateList = {}
for k,v in ipairs(UpItemList) do
for n,m in ipairs(itemList) do
if v.Reward[1] == m.Reward[1] then
local _config = ConfigManager.GetConfigData(config,v.Reward[1])
local readingName = _config.ReadingName or _config.Name
table.insert(rateList,{id = m.Reward[1],tag=_tag,name = readingName,value = m.WeightShow,color = "AD4152"})
break
end
end
end
return rateList
end
function this:RefreshHeroRate(hero,_rateList)
local list3={}
local list4={}
local list5={}
local list2={}
for index, v in ipairs(hero) do
if itemConfig[v.Reward[1]].HeroStar[2]==3 then
table.insert(list3,v)
elseif itemConfig[v.Reward[1]].HeroStar[2]==4 then
table.insert(list4,v)
elseif itemConfig[v.Reward[1]].HeroStar[2]==5 then
table.insert(list5,v)
elseif itemConfig[v.Reward[1]].HeroStar[2]==2 then
table.insert(list2,v)
end
end
local rateList = {}
local valueList5 = this:ReculateRate(list5)
for i = 1 , #_rateList do
valueList5 = valueList5 - _rateList[i].value
table.insert(rateList,_rateList[i])
end
table.insert(rateList,{tag="5星",name="其他5星",value = valueList5,color = "BDB69C"})
table.insert(rateList,{tag="4星",name="4星神将",value = this:ReculateRate(list4),color = "BDB69C"})
table.insert(rateList,{tag="3星",name="3星神将",value = this:ReculateRate(list3),color = "BDB69C"})
table.insert(rateList,{tag="2星",name="2星神将",value = this:ReculateRate(list2),color = "BDB69C"})
return rateList
end
function this:RefreshSoulRate(soul,_rateList,itemType)
local list4={}
local list5={}
local list6={}
local list7={}
for index, v in ipairs(soul) do
if itemConfig[v.Reward[1]].Quantity==4 and itemConfig[v.Reward[1]].ItemType==itemType then
table.insert(list4,v)--紫色
elseif itemConfig[v.Reward[1]].Quantity==5 and itemConfig[v.Reward[1]].ItemType==itemType then
table.insert(list5,v)--金色
elseif itemConfig[v.Reward[1]].Quantity==6 and itemConfig[v.Reward[1]].ItemType==itemType then
table.insert(list6,v)--红色
else
table.insert(list7,v)--其他
end
end
local rateList = {}
local valueList6 = this:ReculateRate(list6)
for i = 1 , #_rateList do
valueList6 = valueList6 - _rateList[i].value
table.insert(rateList,_rateList[i])
end
if valueList6 > 0 then
table.insert(rateList,{tag="红色",name="其他".."红色",value = valueList6,color = "BDB69C"})
end
if #list5 > 0 then
table.insert(rateList,{tag="金色",name="金色",value=this:ReculateRate(list5),color = "BDB69C"})
end
if #list4 > 0 then
table.insert(rateList,{tag="紫色",name="紫色",value=this:ReculateRate(list4),color = "BDB69C"})
end
if #list7 > 0 then
table.insert(rateList,{tag="其他",name="其他",value=this:ReculateRate(list7),color = "BDB69C"})
end
return rateList
end
function this:RefreshMonsterRate(UpMonster,_rateList)
local list1={}
local list2={}
local list3={}
local list4={}
for index, v in ipairs(UpMonster) do
if itemConfig[v.Reward[1]].Quantity==5 and (itemConfig[v.Reward[1]].ItemType==22 or itemConfig[v.Reward[1]].ItemType==21) then
table.insert(list1,v)--金色灵兽碎片
elseif itemConfig[v.Reward[1]].Quantity==4 and (itemConfig[v.Reward[1]].ItemType==22 or itemConfig[v.Reward[1]].ItemType==21) then
table.insert(list2,v)--紫色灵兽碎片
elseif itemConfig[v.Reward[1]].Quantity==3 and (itemConfig[v.Reward[1]].ItemType==22 or itemConfig[v.Reward[1]].ItemType==21) then
table.insert(list3,v)--蓝色灵兽碎片
else
table.insert(list4,v)--其他
end
end
local rateList = {}
local valueList1 = this:ReculateRate(list1)
for i = 1 , #_rateList do
valueList1 = valueList1 - _rateList[i].value
table.insert(rateList,_rateList[i])
end
table.insert(rateList,{tag="金色",name="金色灵兽或碎片",value=valueList1,color = "BDB69C"})
table.insert(rateList,{tag="紫色",name="紫色灵兽或碎片",value=this:ReculateRate(list2),color = "BDB69C"})
table.insert(rateList,{tag="蓝色",name="蓝色灵兽或碎片",value=this:ReculateRate(list3),color = "BDB69C"})
table.insert(rateList,{tag="其他",name="其他奖励",value=this:ReculateRate(list4),color = "BDB69C"})
return rateList
end
function this:RefreshNewHeroRate(UpMonster,_rateList)
local list1={}
local list2={}
local list3={}
local allValue
for index, v in ipairs(UpMonster) do
if itemConfig[v.Reward[1]].HeroStar[2]==5 then
table.insert(list1,v)--五星应雄
elseif itemConfig[v.Reward[1]].HeroStar[2]==4 then
table.insert(list2,v)--四星应雄
elseif itemConfig[v.Reward[1]].HeroStar[2]==3 then
table.insert(list3,v)--三星应雄
end
end
local valueList1 = this:ReculateRate(list1)
for i = 1 , #_rateList do
valueList1 = valueList1 - _rateList[i].value
end
table.insert(_rateList,{tag="五星",name="其他五星英雄",value=valueList1,color = "BDB69C"})
table.insert(_rateList,{tag="四星",name="四星英雄",value=this:ReculateRate(list2),color = "BDB69C"})
table.insert(_rateList,{tag="三星",name="三星英雄",value=this:ReculateRate(list3),color = "BDB69C"})
for i = 1 , #_rateList do
allValue = _rateList[i].value
end
return _rateList
end
function this:OnClose()
end
function this:OnDestroy()
Util.ClearChild(this.grid.transform)
this.ratePreList = {}
this.listUpPre = {}
hero=nil
end
return this