192 lines
7.6 KiB
Lua
192 lines
7.6 KiB
Lua
----- 神应属性弹窗 -----
|
|
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.title=Util.GetGameObject(gameObject, "bg/name/text"):GetComponent("Text")
|
|
self.pre =Util.GetGameObject(gameObject, "pre")
|
|
self.upStarPre =Util.GetGameObject(gameObject, "upStarPre")
|
|
end
|
|
|
|
function this:BindEvent()
|
|
|
|
end
|
|
|
|
function this:AddListener()
|
|
end
|
|
|
|
function this:RemoveListener()
|
|
end
|
|
local type=0
|
|
function this:OnShow(_parent,_Data)
|
|
parent=_parent
|
|
|
|
sortingOrder = _parent.sortingOrder
|
|
parent.BG:SetActive(false)
|
|
local args = _Data
|
|
local curHeroData = args[1]
|
|
if args[2] then
|
|
type=args[2]
|
|
self.title.text="飞升预览"
|
|
else
|
|
type=0
|
|
self.title.text="进阶预览"
|
|
end
|
|
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 (type==0 and v[1] <= 10) or (type~=0 and v[1]>11) 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.changeProId
|
|
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.changeProId
|
|
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.changeProId
|
|
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
|
|
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
|
|
itemList[k].item.gameObject:SetActive(true)
|
|
if index == LengthOfTable(data) then
|
|
Util.GetGameObject(itemList[k].item, "Image (4)").gameObject:SetActive(true)
|
|
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))
|
|
if HeroConfig[v.id] then
|
|
icon.sprite=this.spLoader:LoadSprite(GetResourcePath(HeroConfig[v.id].Icon))
|
|
frame.sprite=this.spLoader:LoadSprite(GetHeroQuantityImageByquality(HeroConfig[v.id].Quality, v.star))
|
|
name.text = HeroConfig[v.id].ReadingName
|
|
proImage.gameObject:SetActive(true)
|
|
proImage.sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(HeroConfig[v.id].PropertyName))
|
|
else
|
|
local itemConfig=ConfigManager.TryGetConfigData(ConfigName.ItemConfig,v.id)
|
|
if itemConfig then
|
|
proImage.gameObject:SetActive(false)
|
|
icon.sprite=this.spLoader:LoadSprite(GetResourcePath(itemConfig.ResourceID))
|
|
frame.sprite=this.spLoader:LoadSprite(GetHeroQuantityImageByquality(itemConfig.Quantity))
|
|
name.text = itemConfig.Name
|
|
end
|
|
end
|
|
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
|
|
num.text = v.num > 0 and v.num or ""
|
|
SetHeroStars(this.spLoader, starGrid, v.star,1,Vector2.New(40,40))
|
|
SetHeroFlyEffect(itemList[k][n],this.spLoader,v.star,sortingOrder,1,3,10)
|
|
Util.SetParticleSortLayer(starGrid, sortingOrder + 1)
|
|
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
|