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

173 lines
6.7 KiB
Lua
Raw Normal View History

----- 神应属性弹窗 -----
local this = {}
local HeroRankupGroup = ConfigManager.GetConfig(ConfigName.HeroRankupGroup)
local HeroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
--传入父脚本模块
local parent
local sortingOrder=0
local itemList = {}
function this:InitComponent(gameObject)
this.spLoader = SpriteLoader.New()
self.bg =Util.GetGameObject(gameObject, "bg")
self.pre =Util.GetGameObject(gameObject, "pre")
self.upStarPre =Util.GetGameObject(gameObject, "upStarPre")
self.close =Util.GetGameObject(gameObject, "close")
end
function this:BindEvent()
Util.AddClick(self.close,function()
parent:ClosePanel()
end)
end
function this:AddListener()
end
function this:RemoveListener()
end
2021-09-18 17:58:28 +08:00
function this:OnShow(_parent,_Data)
parent=_parent
sortingOrder = _parent.sortingOrder
parent.BG:SetActive(false)
2021-09-18 17:58:28 +08:00
local args = _Data
local curHeroData = args[1]
if not curHeroData or not HeroConfig[curHeroData.heroConfig.Id] or #HeroConfig[curHeroData.heroConfig.Id].RankupConsumeMaterial < 1 then
parent:ClosePanel()
return
end
if not itemList then
itemList = {}
end
local data = {}
local oldIndex = 0
local oldIndexType = 0
local index = 0
for k,v in ipairs(curHeroData.heroConfig.RankupConsumeMaterial) do
if v[1] <= 10 then
if oldIndexType ~= v[1] then
oldIndexType = v[1]
oldIndex = oldIndex + 1
index = 1
data[oldIndex] = {}
data[oldIndex].sort = v[1]
data[oldIndex][index] = {}
data[oldIndex][index].id = curHeroData.heroConfig.Id
data[oldIndex][index].star = v[1]
data[oldIndex][index].property = curHeroData.heroConfig.PropertyName
2021-06-16 15:14:36 +08:00
data[oldIndex][index].num = 0
index = index + 1
data[oldIndex][index] = {}
data[oldIndex][index].id = curHeroData.heroConfig.Id
data[oldIndex][index].star = v[1] - 1
data[oldIndex][index].property = curHeroData.heroConfig.PropertyName
2021-06-16 15:14:36 +08:00
data[oldIndex][index].num = 0
end
index = index + 1
if not data[oldIndex][index] then
data[oldIndex][index] = {}
end
local config = HeroRankupGroup[v[3]]
if config.Issame == 1 then
data[oldIndex][index].id = curHeroData.heroConfig.Id
elseif config.IsId > 0 then
data[oldIndex][index].id = config.IsId
else
data[oldIndex][index].id = 0
end
data[oldIndex][index].star = config.StarLimit
if config.IsSameClan == 1 then
data[oldIndex][index].property = curHeroData.heroConfig.PropertyName
else
data[oldIndex][index].property = 0
end
data[oldIndex][index].num = v[4]
end
end
table.sort(data,function(a,b)
return a.sort < b.sort
end)
local index = 0
2021-06-18 11:03:51 +08:00
for k,m in pairs(itemList) do
itemList[k].item.gameObject:SetActive(false)
end
for k,m in pairs(data) do
index = index + 1
if not itemList[k] then
itemList[k] = {}
itemList[k].item = newObjToParent(self.pre,self.bg)
itemList[k].k= {}
itemList[k].k[1] = Util.GetGameObject(itemList[k].item, "k1")
itemList[k].k[2] = Util.GetGameObject(itemList[k].item, "k2")
itemList[k].k[3] = Util.GetGameObject(itemList[k].item, "k3")
end
2021-06-18 11:03:51 +08:00
itemList[k].item.gameObject:SetActive(true)
if index == LengthOfTable(data) then
Util.GetGameObject(itemList[k].item, "Image (4)").gameObject:SetActive(false)
else
Util.GetGameObject(itemList[k].item, "Image (4)").gameObject:SetActive(true)
end
for n,v in ipairs(m) do
if not itemList[k][n] then
if n < 3 then
itemList[k][n] = newObjToParent(self.upStarPre,itemList[k].k[n])
else
itemList[k][n] = newObjToParent(self.upStarPre,itemList[k].k[3])
end
end
itemList[k][n].transform.localScale = Vector3.New(0.8,0.8,0.8)
local proImage = Util.GetGameObject(itemList[k][n], "iconbg/proImage"):GetComponent("Image")
local iconDefault = Util.GetGameObject(itemList[k][n],"iconDefault")
local icon = Util.GetGameObject(itemList[k][n],"icon"):GetComponent("Image")
local frame = Util.GetGameObject(itemList[k][n],"frame"):GetComponent("Image")
local num = Util.GetGameObject(itemList[k][n],"num"):GetComponent("Text")
local starGrid = Util.GetGameObject(itemList[k][n], "iconbg/starGrid")
local name = Util.GetGameObject(itemList[k][n], "name"):GetComponent("Text")
proImage.gameObject:SetActive(false)
if v.id > 0 then
iconDefault:SetActive(false)
icon.gameObject:SetActive(true)
proImage.gameObject:SetActive(true)
proImage.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(v.property))
icon.sprite=this.spLoader:LoadSprite(GetResourcePath(HeroConfig[v.id].Icon))
frame.sprite=this.spLoader:LoadSprite(GetHeroQuantityImageByquality(HeroConfig[v.id].Quality, v.star))
proImage.sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(HeroConfig[v.id].PropertyName))
name.text = HeroConfig[v.id].ReadingName
else
if v.property > 0 then
proImage.gameObject:SetActive(true)
proImage.sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(v.property))
end
name.text = string.format("%s%s星",PropertyType[v.property],v.star)
iconDefault:SetActive(true)
icon.gameObject:SetActive(false)
frame.sprite=this.spLoader:LoadSprite(GetHeroQuantityImageByquality(nil,v.star))
end
2021-06-16 15:14:36 +08:00
num.text = v.num > 0 and v.num or ""
SetHeroStars(this.spLoader, starGrid, v.star,1,nil,-15.3)
end
end
end
-- local heroData = {
-- id = 0,
-- star = 0,
-- property = 0,
-- num = 0,
-- }
function this:OnClose()
end
function this:OnDestroy()
Util.ClearChild(self.bg.transform)
itemList = {}
end
return this