miduo_client/Assets/ManagedResources/~Lua/Modules/HandBook/HandBookHeroAndEquipListPan...

843 lines
35 KiB
Lua

require("Base/BasePanel")
HandBookHeroAndEquipListPanel = Inherit(BasePanel)
local OpenType = 0 --1 英雄 2装备 3 法宝
-- --英雄列表
-- local tenGridList = {}
-- local sexGridList = {}
-- local fiveGridList = {}
-- local fourGridList = {}
-- local threeGridList = {}
-- local twoGridList = {}
-- local oneGridList = {}
--装备列表
local chuanShuoGridList = {}
local shiShiGridList = {}
local youXiuGridList = {}
local jingLiangGridList = {}
--法宝列表
local orangeGridList = {}
local violetGridList = {}
local blueGridList = {}
local proId = 0 --0 全部 1 火 2风 3 水 4 地 5 光 6 暗
local tabs = {}
local orginLayer = 0
local orginLayer2 = 0
local gridListData = {}
local heroNumList = {}
--初始化组件(用于子类重写)
function HandBookHeroAndEquipListPanel:InitComponent()
self.spLoader = SpriteLoader.New()
self.btnBack = Util.GetGameObject(self.transform, "btnBack")
--英雄
self.heroScroll = Util.GetGameObject(self.transform, "heroScroll")
self.heroScrollbar = Util.GetGameObject(self.transform, "heroScrollbar")
self.heroScrollbar.gameObject:SetActive(false)
self.card = poolManager:LoadAsset("card", PoolManager.AssetType.GameObject)
self.card.transform:SetParent(self.transform)
--local particles1=starPre:GetComponentsInChildren(typeof(UnityEngine.ParticleSystem))
-- for key, value in pairs(particles1:ToTable()) do
-- local mat=value:GetComponent(typeof(UnityEngine.Renderer))
-- if mat.material.shader.name=="CGwell FX/Additive Lv1" then
-- mat.material.shader=poolManager:LoadAsset("Add Lv1_1",poolManager.AssetType.Other)
-- elseif mat.material.shader.name=="UI Particles/Additive" then
-- mat.material.shader=poolManager:LoadAsset("UI-Particle-Add_1",poolManager.AssetType.Other)
-- end
-- end
self.card:GetComponent("RectTransform").localScale = Vector3.New(1, 1, 1)
Util.GetGameObject(self.card, "choosed").gameObject:SetActive(false)
Util.GetGameObject(self.card, "redAndLock").gameObject:SetActive(false)
self.starNum = Util.GetGameObject(self.transform, "starNum")
self.heroprefab = Util.GetGameObject(self.transform, "heroprefab")
--[[
local particles = self.heroprefab:GetComponentsInChildren(typeof(UnityEngine.ParticleSystem))
for key, value in pairs(particles:ToTable()) do
local mat = value:GetComponent(typeof(UnityEngine.Renderer))
if mat.material.shader.name == "CGwell FX/Additive Lv1" then
mat.material.shader = poolManager:LoadAsset("Add Lv1_1", poolManager.AssetType.Other)
elseif mat.material.shader.name == "UI Particles/Additive" then
mat.material.shader = poolManager:LoadAsset("UI-Particle-Add_1", poolManager.AssetType.Other)
elseif mat.material.shader.name == "YXZ/Effect/Mix Masking(Without Moving)_alphablend" then
mat.material.shader = poolManager:LoadAsset("YXZ_MixMaskingWithoutMoving_alphablend_1",
poolManager.AssetType.Other)
end
end
]]
local meshs = self.heroprefab:GetComponentsInChildren(typeof(UnityEngine.MeshRenderer))
for key, value in pairs(meshs:ToTable()) do
if value.material.shader.name == "Custom/S_03_UV_alpha_add" then
value.material.shader = poolManager:LoadAsset("S_03_uv_alpha_add_1", poolManager.AssetType.Other)
end
end
local meshs2 = self.heroprefab:GetComponentsInChildren(typeof(UnityEngine.SkinnedMeshRenderer))
for key, value in pairs(meshs2:ToTable()) do
if value.material.shader.name == "YXZ/Effect/TransparentRim" then
value.material.shader = poolManager:LoadAsset("YXZ_Effect_TransparentRim_1", poolManager.AssetType.Other)
end
end
self.scrollRoot = Util.GetGameObject(self.transform, "heroScroll")
local rootHight = self.scrollRoot.transform.rect.height
local sv = SubUIManager.Open(SubUIConfig.ScrollFitterView, self.scrollRoot.transform,
self.heroprefab, Vector2.New(1080, rootHight - 10), 1, 0)
sv.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(0, -5)
-- 保存
sv.moveTween.MomentumAmount = 1
sv.moveTween.Strength = 2
self.SystemScrollView = sv
--装备
self.equipScroll = Util.GetGameObject(self.transform, "equipScroll")
self.equipScrollbar = Util.GetGameObject(self.transform, "equipScrollbar")
self.equip = Util.GetGameObject(self.transform, "equip")
self.chuanShuoGrid = Util.GetGameObject(self.equipScroll.transform, "grid/chuanShuoGrid")
self.shiShiGrid = Util.GetGameObject(self.equipScroll.transform, "grid/shiShiGrid")
self.youXiuGrid = Util.GetGameObject(self.equipScroll.transform, "grid/youXiuGrid")
self.jingLiangGrid = Util.GetGameObject(self.equipScroll.transform, "grid/jingLiangGrid")
self.chuanShuoNum = Util.GetGameObject(self.equipScroll.transform, "grid/chuanShuoNum/numInfo/numText/Text (1)")
:GetComponent("Text")
self.shiShiNum = Util.GetGameObject(self.equipScroll.transform, "grid/shiShiNum/numInfo/numText/Text (1)")
:GetComponent("Text")
self.youXiuNum = Util.GetGameObject(self.equipScroll.transform, "grid/youXiuNum/numInfo/numText/Text (1)")
:GetComponent("Text")
self.jingLiangNum = Util.GetGameObject(self.equipScroll.transform, "grid/jingLiangNum/numInfo/numText/Text (1)")
:GetComponent("Text")
--法宝
self.talismanScroll = Util.GetGameObject(self.transform, "TalismanScroll")
self.talismanScrollbar = Util.GetGameObject(self.transform, "TalismanScrollbar")
self.talismanPre = Util.GetGameObject(self.transform, "TalismanPre")
self.orangeGrid = Util.GetGameObject(self.talismanScroll.transform, "Grid/OrangeGrid")
self.violetGrid = Util.GetGameObject(self.talismanScroll.transform, "Grid/VioletGrid")
self.blueGrid = Util.GetGameObject(self.talismanScroll.transform, "Grid/BlueGrid")
self.orangeNum = Util.GetGameObject(self.talismanScroll.transform, "Grid/OrangeNum/NumInfo/NumText/Text")
:GetComponent("Text")
self.violetNum = Util.GetGameObject(self.talismanScroll.transform, "Grid/VioletNum/NumInfo/NumText/Text")
:GetComponent("Text")
self.blueNum = Util.GetGameObject(self.talismanScroll.transform, "Grid/BlueNum/NumInfo/NumText/Text"):GetComponent(
"Text")
chuanShuoGridList = {}
shiShiGridList = {}
youXiuGridList = {}
jingLiangGridList = {}
orangeGridList = {}
violetGridList = {}
blueGridList = {}
for i = 1, 1 do
chuanShuoGridList[i] = Util.GetGameObject(self.equipScroll.transform, "grid/chuanShuoGrid/equip (" .. i .. ")")
shiShiGridList[i] = Util.GetGameObject(self.equipScroll.transform, "grid/shiShiGrid/equip (" .. i .. ")")
youXiuGridList[i] = Util.GetGameObject(self.equipScroll.transform, "grid/youXiuGrid/equip (" .. i .. ")")
jingLiangGridList[i] = Util.GetGameObject(self.equipScroll.transform, "grid/jingLiangGrid/equip (" .. i .. ")")
orangeGridList[i] = Util.GetGameObject(self.orangeGrid.transform, "equip (" .. i .. ")")
violetGridList[i] = Util.GetGameObject(self.violetGrid.transform, "equip (" .. i .. ")")
blueGridList[i] = Util.GetGameObject(self.blueGrid.transform, "equip (" .. i .. ")")
end
self.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform)
self.selectBtn = Util.GetGameObject(self.gameObject, "Tabs/selectBtn")
Util.GetGameObject(self.transform, "Tabs/grid/Btn" .. 0):SetActive(false)
for i = 1, 6 do
tabs[i] = Util.GetGameObject(self.transform, "Tabs/grid/Btn" .. i)
end
for i = 1, 5 do
tabs[i]:SetActive(true)
end
self.Tabs = Util.GetGameObject(self.gameObject, "Tabs")
end
--绑定事件(用于子类重写)·
function HandBookHeroAndEquipListPanel:BindEvent()
Util.AddClick(self.btnBack, function()
self:ClosePanel()
end)
for i = 1, 6 do
Util.AddClick(tabs[i], function()
if i ~= proId then
proId = i
end
self:OnShowHeroFun()
end)
end
end
--添加事件监听(用于子类重写)
function HandBookHeroAndEquipListPanel:AddListener()
end
--移除事件监听(用于子类重写)
function HandBookHeroAndEquipListPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function HandBookHeroAndEquipListPanel:OnOpen(_type)
-- proId=ProIdConst.All
OpenType = _type
--self.BtView:OnOpen(self, { sortOrder = self.sortingOrder, panelType = PanelTypeView.RolePanel })
--self.BtView2:OnOpen({ sortOrder = self.sortingOrder, panelType = PanelTypeView2.HandBookPanel })
self.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main })
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function HandBookHeroAndEquipListPanel:OnShow()
proId = PlayerManager.headBookListTag
if OpenType == 1 then
self.heroScroll:SetActive(true)
self.heroScrollbar:SetActive(false)
self.equipScroll:SetActive(false)
self.equipScrollbar:SetActive(false)
self.talismanScroll:SetActive(false)
self.talismanScrollbar:SetActive(false)
self.Tabs:SetActive(true)
-- proId=ProIdConst.All
self:OnShowHeroFun()
elseif OpenType == 2 then
self.heroScroll:SetActive(false)
self.heroScrollbar:SetActive(false)
self.equipScroll:SetActive(true)
self.equipScrollbar:SetActive(true)
self.talismanScroll:SetActive(false)
self.talismanScrollbar:SetActive(false)
self.Tabs:SetActive(false)
self:OnShowEquipFun()
elseif OpenType == 3 then
self.heroScroll:SetActive(false)
self.heroScrollbar:SetActive(false)
self.equipScroll:SetActive(false)
self.equipScrollbar:SetActive(false)
self.talismanScroll:SetActive(true)
self.talismanScrollbar:SetActive(true)
self.Tabs:SetActive(false)
self:OnShowTalismanFun()
end
end
--界面关闭时调用(用于子类重写)
function HandBookHeroAndEquipListPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function HandBookHeroAndEquipListPanel:OnDestroy()
self.spLoader:Destroy()
SubUIManager.Close(self.UpView)
--SubUIManager.Close(self.BtView)
--SubUIManager.Close(self.BtView2)
end
function HandBookHeroAndEquipListPanel:OnSortingOrderChange()
orginLayer = self.sortingOrder
end
function HandBookHeroAndEquipListPanel:Clone(_t)
local res = {}
res = _t
return res
end
function HandBookHeroAndEquipListPanel:GetHeroData()
--得到所有的对应星级的英雄
local tenHeroList = {}
local sexHeroList = {}
local fiveHeroList = {}
local fourHeroList = {}
local threeHeroList = {}
local twoHeroList = {}
local oneHeroList = {}
for id, v in ConfigPairs(ConfigManager.GetConfig(ConfigName.HeroConfig)) do
if (not v.Hide or v.Hide == 0) and HeroManager.InVersion(id) then
if v.Natural == 7 and (proId == 0 or v.PropertyName == proId) then
table.insert(tenHeroList, v)
elseif v.Natural == 6 and (proId == 0 or v.PropertyName == proId) then
table.insert(sexHeroList, v)
-- if v.MaxRank==14 then
-- table.insert(tenHeroList,v)
-- end
elseif v.Natural == 5 and (proId == 0 or v.PropertyName == proId) then
table.insert(fiveHeroList, v)
elseif v.Natural == 4 and (proId == 0 or v.PropertyName == proId) then
table.insert(fourHeroList, v)
elseif v.Natural == 3 and (proId == 0 or v.PropertyName == proId) then
table.insert(threeHeroList, v)
elseif v.Natural == 2 and (proId == 0 or v.PropertyName == proId) then
table.insert(twoHeroList, v)
elseif v.Natural == 1 and (proId == 0 or v.PropertyName == proId) then
table.insert(oneHeroList, v)
end
end
end
self:SortHeroNatural(tenHeroList)
self:SortHeroNatural(sexHeroList)
self:SortHeroNatural(fiveHeroList)
self:SortHeroNatural(fourHeroList)
self:SortHeroNatural(threeHeroList)
self:SortHeroNatural(twoHeroList)
self:SortHeroNatural(oneHeroList)
--设置图鉴的循环列表
local herodatas = {}
herodatas[7] = tenHeroList
herodatas[6] = sexHeroList
herodatas[5] = fiveHeroList
herodatas[4] = fourHeroList
herodatas[3] = threeHeroList
herodatas[2] = twoHeroList
herodatas[1] = oneHeroList
PlayerManager.heroHandBookListData = herodatas
local heroScrolldatas = {}
self:HeroHaveNum()
local temp = 0
for k, v in pairs(herodatas) do
temp = 0
if v and #v > 0 then
--LogGreen("star:"..k.." heroCount:"..#v.." HeroHaveNum:"..heroNumList[k])
local str = "" --Language[11532]..heroNumList[k].."/"..#v
table.insert(heroScrolldatas, { type = 2, natural = k, star = k, index = 0, content = str })
for i = 1, #v do
if i % 5 == 0 or i == #v then
local tempData = {}
for n = temp + 1, i do
table.insert(tempData, v[n])
--LogBlue("v[n].id:"..v[n].Id)
end
local showStar = v[i].MaxRank
--if k == 6 then
--showStar = 11
--end
if i % 5 == 0 then
table.insert(heroScrolldatas,
{ type = 1, natural = k, star = showStar, index = math.floor(i / 5), content = tempData })
else
table.insert(heroScrolldatas,
{ type = 1, natural = k, star = showStar, index = math.floor(i / 5) + 1, content = tempData })
end
temp = i
end
end
end
end
table.sort(heroScrolldatas, function(a, b)
if a.natural == b.natural then
if a.type == b.type then
return a.index < b.index
else
return a.type > b.type
end
else
return a.natural > b.natural
end
end)
-- for k,v in ipairs(heroScrolldatas) do
-- if v.content and v.type ==1 then
-- LogPink("star:"..v.star.." heroCount:"..#v.content.." index:"..v.index)
-- for n,m in ipairs(v.content) do
-- LogYellow("m.Id:"..m.Id.."m.Star:"..m.Star)
-- end
-- end
-- end
return heroScrolldatas
end
function HandBookHeroAndEquipListPanel:HeroHaveNum()
local curelevenStarActiveNum = 0
local curtenStarActiveNum = 0
local cursexStarActiveNum = 0
local curfiveStarActiveNum = 0
local curfourStarActiveNum = 0
local curthreeStarActiveNum = 0
local curtwoStarActiveNum = 0
local curoneStarActiveNum = 0
--计算玩家拥有的英雄中对应星级的英雄的数量
for i, v in pairs(PlayerManager.heroHandBook) do
local conFig = ConfigManager.GetConfigData(ConfigName.HeroConfig, i)
if conFig then
if PlayerManager.GetHeroDataByStar(11, conFig.Id) and (proId == 0 or conFig.PropertyName == proId) then
curelevenStarActiveNum = curelevenStarActiveNum + 1
end
if PlayerManager.GetHeroDataByStar(10, conFig.Id) and (proId == 0 or conFig.PropertyName == proId) then
curtenStarActiveNum = curtenStarActiveNum + 1
end
if PlayerManager.GetHeroDataByStar(6, conFig.Id) and (proId == 0 or conFig.PropertyName == proId) then
cursexStarActiveNum = cursexStarActiveNum + 1
end
if conFig.Star == 5 and (proId == 0 or conFig.PropertyName == proId) then
curfiveStarActiveNum = curfiveStarActiveNum + 1
elseif conFig.Star == 4 and (proId == 0 or conFig.PropertyName == proId) then
curfourStarActiveNum = curfourStarActiveNum + 1
elseif conFig.Star == 3 and (proId == 0 or conFig.PropertyName == proId) then
curthreeStarActiveNum = curthreeStarActiveNum + 1
elseif conFig.Star == 2 and (proId == 0 or conFig.PropertyName == proId) then
curtwoStarActiveNum = curtwoStarActiveNum + 1
elseif conFig.Star == 1 and (proId == 0 or conFig.PropertyName == proId) then
curoneStarActiveNum = curoneStarActiveNum + 1
end
end
end
heroNumList[1] = curoneStarActiveNum
heroNumList[2] = curtwoStarActiveNum
heroNumList[3] = curthreeStarActiveNum
heroNumList[4] = curfourStarActiveNum
heroNumList[5] = curfiveStarActiveNum
heroNumList[6] = cursexStarActiveNum
heroNumList[10] = curtenStarActiveNum
heroNumList[11] = curelevenStarActiveNum
end
--英雄展示
function HandBookHeroAndEquipListPanel:OnShowHeroFun()
self:SetSelectBtn()
local data = self:GetHeroData()
self.SystemScrollView:SetData(data, function(dataIndex, go)
--LogYellow("dataIndex:"..dataIndex)
self:showData(go, data[dataIndex])
end, 1)
orginLayer2 = self.sortingOrder
orginLayer = self.sortingOrder
end
--装备展示
function HandBookHeroAndEquipListPanel:OnShowEquipFun()
local chuanShuoEquipList = {}
local shiShiEquipList = {}
local youXiuEquipList = {}
local jingLiangEquipList = {}
for id, v in ConfigPairs(ConfigManager.GetConfig(ConfigName.EquipConfig)) do
if v.IfShow == 1 then
if v.Quality == 5 then
table.insert(chuanShuoEquipList, v)
elseif v.Quality == 4 then
table.insert(shiShiEquipList, v)
elseif v.Quality == 3 then
table.insert(youXiuEquipList, v)
elseif v.Quality == 2 then
table.insert(jingLiangEquipList, v)
end
end
end
local curchaunShuoActiveNum = 0
local curshiShiActiveNum = 0
local curyouXiuActiveNum = 0
local curjingLiangActiveNum = 0
for i, v in pairs(PlayerManager.equipHandBook) do
local conFig = ConfigManager.GetConfigData(ConfigName.EquipConfig, v)
if conFig and conFig.IfShow == 1 then
if conFig.Quality == 5 then
curchaunShuoActiveNum = curchaunShuoActiveNum + 1
elseif conFig.Quality == 4 then
curshiShiActiveNum = curshiShiActiveNum + 1
elseif conFig.Quality == 3 then
curyouXiuActiveNum = curyouXiuActiveNum + 1
elseif conFig.Quality == 2 then
curjingLiangActiveNum = curjingLiangActiveNum + 1
end
end
end
--传说装备
if chuanShuoEquipList and #chuanShuoEquipList > 0 then
self.chuanShuoNum.text = Language[11532] .. curchaunShuoActiveNum .. "/" .. #chuanShuoEquipList
for i = 1, math.max(#chuanShuoEquipList, #chuanShuoGridList) do
local go = chuanShuoGridList[i]
if not go or (go and not go.gameObject) then
go = self:GeneralNewGoPre(2, i, self.chuanShuoGrid)
chuanShuoGridList[i] = go
end
go.gameObject:SetActive(false)
end
for i = 1, #chuanShuoEquipList do
chuanShuoGridList[i]:SetActive(true)
self:OnShowSingleEquipData(chuanShuoGridList[i], chuanShuoEquipList[i])
end
Util.GetGameObject(self.equipScroll.transform, "chuanShuoNum"):SetActive(true)
self.chuanShuoGrid:SetActive(true)
else
Util.GetGameObject(self.equipScroll.transform, "chuanShuoNum"):SetActive(false)
self.chuanShuoGrid:SetActive(false)
end
--史诗装备
if shiShiEquipList and #shiShiEquipList > 0 then
self.shiShiNum.text = Language[11532] .. curshiShiActiveNum .. "/" .. #shiShiEquipList
for i = 1, math.max(#shiShiEquipList, #shiShiGridList) do
local go = shiShiGridList[i]
if not go or (go and not go.gameObject) then
go = self:GeneralNewGoPre(2, i, self.shiShiGrid)
shiShiGridList[i] = go
end
go.gameObject:SetActive(false)
end
for i = 1, #shiShiEquipList do
shiShiGridList[i]:SetActive(true)
self:OnShowSingleEquipData(shiShiGridList[i], shiShiEquipList[i])
end
Util.GetGameObject(self.equipScroll.transform, "shiShiNum"):SetActive(true)
self.shiShiGrid:SetActive(true)
else
Util.GetGameObject(self.equipScroll.transform, "shiShiNum"):SetActive(false)
self.shiShiGrid:SetActive(false)
end
--优秀装备
if youXiuEquipList and #youXiuEquipList > 0 then
self.youXiuNum.text = Language[11532] .. curyouXiuActiveNum .. "/" .. #youXiuEquipList
for i = 1, math.max(#youXiuEquipList, #youXiuGridList) do
local go = youXiuGridList[i]
if not go or (go and not go.gameObject) then
go = self:GeneralNewGoPre(2, i, self.youXiuGrid)
youXiuGridList[i] = go
end
go.gameObject:SetActive(false)
end
for i = 1, #youXiuEquipList do
youXiuGridList[i]:SetActive(true)
self:OnShowSingleEquipData(youXiuGridList[i], youXiuEquipList[i])
end
Util.GetGameObject(self.equipScroll.transform, "youXiuNum"):SetActive(true)
self.youXiuGrid:SetActive(true)
else
Util.GetGameObject(self.equipScroll.transform, "youXiuNum"):SetActive(false)
self.youXiuGrid:SetActive(false)
end
--精良装备
if jingLiangEquipList and #jingLiangEquipList > 0 then
self.jingLiangNum.text = Language[11532] .. curjingLiangActiveNum .. "/" .. #jingLiangEquipList
for i = 1, math.max(#jingLiangEquipList, #jingLiangGridList) do
local go = jingLiangGridList[i]
if not go or (go and not go.gameObject) then
go = self:GeneralNewGoPre(2, i, self.jingLiangGrid)
jingLiangGridList[i] = go
end
go.gameObject:SetActive(false)
end
for i = 1, #jingLiangEquipList do
jingLiangGridList[i]:SetActive(true)
self:OnShowSingleEquipData(jingLiangGridList[i], jingLiangEquipList[i])
end
Util.GetGameObject(self.equipScroll.transform, "jingLiangNum"):SetActive(true)
self.jingLiangGrid:SetActive(true)
else
Util.GetGameObject(self.equipScroll.transform, "jingLiangNum"):SetActive(false)
self.jingLiangGrid:SetActive(false)
end
end
--法宝展示(脚本名该换了)
function HandBookHeroAndEquipListPanel:OnShowTalismanFun()
self:SetSelectBtn()
local orangeTalismanList = {}
local violetTalismanList = {}
local blueTalismanList = {}
for i, v in ConfigPairs(ConfigManager.GetConfig(ConfigName.ItemConfig)) do
if v.ItemType == 14 then
if v.Quantity == 5 then
table.insert(orangeTalismanList, v)
elseif v.Quantity == 4 then
table.insert(violetTalismanList, v)
elseif v.Quantity == 3 then
table.insert(blueTalismanList, v)
end
end
end
--搜集进度
local curOrangeActiveNum = 0
local curVioletActiveNum = 0
local curBlueActiveNum = 0
for i, v in pairs(PlayerManager.talismanHandBook) do
local conFig = {}
conFig = ConfigManager.GetConfigData(ConfigName.ItemConfig, v)
if conFig then
if conFig.Quantity == 5 then
curOrangeActiveNum = curOrangeActiveNum + 1
elseif conFig.Quantity == 4 then
curVioletActiveNum = curVioletActiveNum + 1
elseif conFig.Quantity == 3 then
curBlueActiveNum = curBlueActiveNum + 1
end
end
end
--橙色法宝
if orangeTalismanList and #orangeTalismanList > 0 then
self.orangeNum.text = Language[11532] .. curOrangeActiveNum .. "/" .. #orangeTalismanList
for i = 1, math.max(#orangeTalismanList, #orangeGridList) do
local go = orangeGridList[i]
if not go or (go and not go.gameObject) then
go = self:GeneralNewGoPre(3, i, self.orangeGrid)
orangeGridList[i] = go
end
go.gameObject:SetActive(false)
end
for i = 1, #orangeTalismanList do
orangeGridList[i]:SetActive(true)
self:OnShowSingleTalismanData(orangeGridList[i], orangeTalismanList[i])
end
Util.GetGameObject(self.talismanScroll.transform, "Grid/OrangeNum"):SetActive(true)
self.orangeGrid:SetActive(true)
else
Util.GetGameObject(self.talismanScroll.transform, "Grid/OrangeNum"):SetActive(false)
self.orangeGrid:SetActive(false)
end
--紫色法宝
if violetTalismanList and #violetTalismanList > 0 then
self.violetNum.text = Language[11532] .. curVioletActiveNum .. "/" .. #violetTalismanList
for i = 1, math.max(#violetTalismanList, #violetGridList) do
local go = violetGridList[i]
if not go or (go and not go.gameObject) then
go = self:GeneralNewGoPre(3, i, self.violetGrid)
violetGridList[i] = go
end
go.gameObject:SetActive(false)
end
for i = 1, #violetTalismanList do
violetGridList[i]:SetActive(true)
self:OnShowSingleTalismanData(violetGridList[i], violetTalismanList[i])
end
Util.GetGameObject(self.talismanScroll.transform, "Grid/VioletNum"):SetActive(true)
self.violetGrid:SetActive(true)
else
Util.GetGameObject(self.talismanScroll.transform, "Grid/VioletNum"):SetActive(false)
self.violetGrid:SetActive(false)
end
--蓝色法宝
if blueTalismanList and #blueTalismanList > 0 then
self.blueNum.text = Language[11532] .. curBlueActiveNum .. "/" .. #blueTalismanList
for i = 1, math.max(#blueTalismanList, #blueGridList) do
local go = blueGridList[i]
if not go or (go and not go.gameObject) then
go = self:GeneralNewGoPre(3, i, self.blueGrid)
blueGridList[i] = go
end
go.gameObject:SetActive(false)
end
for i = 1, #blueTalismanList do
blueGridList[i]:SetActive(true)
self:OnShowSingleTalismanData(blueGridList[i], blueTalismanList[i])
end
Util.GetGameObject(self.talismanScroll.transform, "Grid/BlueNum"):SetActive(true)
self.blueGrid:SetActive(true)
else
Util.GetGameObject(self.talismanScroll.transform, "Grid/BlueNum"):SetActive(false)
self.blueGrid:SetActive(false)
end
end
--生成不同类型图鉴预制的通用方法
function HandBookHeroAndEquipListPanel:GeneralNewGoPre(_type, _index, _grid)
local go
if _type == 1 then
go = newObject(self.card)
go.transform:SetParent(_grid.transform)
go.transform.localScale = Vector3.one
go.transform.localPosition = Vector3.zero;
go.gameObject.name = "card (" .. _index .. ")"
elseif _type == 2 then
go = newObject(self.equip)
go.transform:SetParent(_grid.transform)
go.transform.localScale = Vector3.one
go.transform.localPosition = Vector3.zero;
go.gameObject.name = "equip (" .. _index .. ")"
elseif _type == 3 then
go = newObject(self.talismanPre)
go.transform:SetParent(_grid.transform)
go.transform.localScale = Vector3.one
go.transform.localPosition = Vector3.zero
go.gameObject.name = "Talisman (" .. _index .. ")"
end
return go
end
function HandBookHeroAndEquipListPanel:showData(go, data)
local star = Util.GetGameObject(go.transform, "star")
star.gameObject:SetActive(false)
local item = Util.GetGameObject(go.transform, "singleItem")
item.gameObject:SetActive(false)
local image = Util.GetGameObject(go.transform, "Image"):GetComponent("Image")
image.gameObject:SetActive(false)
if data.type == 2 then
star.gameObject:SetActive(false)
image.gameObject:SetActive(true)
image.sprite = self.spLoader:LoadSprite(GetHeroHandBookNaturalImg(data.natural))
image:SetNativeSize()
SetHeroStars(self.spLoader, star, data.star, 1, Vector2.New(71, 71), -14, Vector2(0.5, 0.5))
Util.GetGameObject(go.transform, "star/Text"):GetComponent("Text").text = data.content
else
item.gameObject:SetActive(true)
for i = 1, 5 do
local _go = Util.GetGameObject(item, "card" .. i)
if i <= #data.content then
self:OnShowSingleHeroData(_go, data.content[i], data.natural, data.star)
_go.gameObject:SetActive(true)
else
_go.gameObject:SetActive(false)
end
end
end
end
--设置猎妖师数据
function HandBookHeroAndEquipListPanel:OnShowSingleHeroData(...)
local param = { ... }
local heroData = param[2]
local _go = param[1]
local star = heroData.MaxRank
local lv = 1
local natural = 0
if (param[3]) then
natural = param[3]
end
if (param[4]) then
star = param[4]
end
local rankUpConfig = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.HeroRankupConfig, "Type", 2, "OpenStar",
star)
if rankUpConfig then
lv = rankUpConfig.OpenLevel
else
-- rankUpConfig=ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.HeroRankupConfig,"Type",1,"OpenStar",star)
-- if rankUpConfig then
-- lv=rankUpConfig.OpenLevel
-- else
-- lv=1
-- end
if star == 1 then
lv = 40
elseif star == 2 then
lv = 50
elseif star == 3 then
lv = 60
elseif star == 4 then
lv = 80
else
lv = 1
end
end
heroData.curLv = lv
Util.GetGameObject(_go.transform, "card/choosed").gameObject:SetActive(false)
Util.GetGameObject(_go.transform, "card/flyImg").gameObject:SetActive(false)
Util.GetGameObject(_go.transform, "card/redAndLock").gameObject:SetActive(false)
if natural == 6 then
SetHeroBg(self.spLoader, Util.GetGameObject(_go.transform, "card"), Util.GetGameObject(_go.transform, "card/bg"),
11, heroData.Quality, orginLayer + 1)
else
SetHeroBg(self.spLoader, Util.GetGameObject(_go.transform, "card"), Util.GetGameObject(_go.transform, "card/bg"),
star, heroData.Quality, orginLayer + 1)
end
Util.GetGameObject(_go.transform, "card/lv/Text"):GetComponent("Text").text = lv
Util.GetGameObject(_go.transform, "card/name"):GetComponent("Text").text = GetLanguageStrById(heroData.ReadingName)
Util.GetGameObject(_go.transform, "card/icon"):GetComponent("Image").sprite = self.spLoader:LoadSprite(
GetResourcePath(heroData.Painting))
--SetHEeroLiveToward(Util.GetGameObject(_go.transform, "card/icon"),heroData.Toward)
Util.GetGameObject(_go.transform, "card/pro/Image"):GetComponent("Image").sprite = self.spLoader:LoadSprite(
GetProStrImageByProNum(heroData.PropertyName))
Util.GetGameObject(_go.transform, "card/heroStage"):SetActive(false)
local starGrid = Util.GetGameObject(_go.transform, "star")
local aaa = star
--if aaa == 11 then
--aaa = 16
--end
SetHeroStars(self.spLoader, starGrid, aaa, 1, nil, -15, nil, Vector3.New(0, 0, -15))
Util.SetParticleSortLayer(starGrid, orginLayer + 1)
Util.AddOnceClick(Util.GetGameObject(_go.transform, "card"), function()
UIManager.OpenPanel(UIName.HandBookHeroInfoPanel, heroData, proId, natural, lv, star)
end)
if PlayerManager.GetHeroDataByStar(0, heroData.Id) then
Util.SetGray(Util.GetGameObject(_go.transform, "card/icon"), false)
Util.SetGray(Util.GetGameObject(_go.transform, "card/pro/Image"), false)
Util.GetGameObject(_go.transform, "card"):GetComponent("Image").material = nil
else
Util.SetGray(Util.GetGameObject(_go.transform, "card/icon"), true)
Util.SetGray(Util.GetGameObject(_go.transform, "card/pro/Image"), true)
Util.GetGameObject(_go.transform, "card"):GetComponent("Image").material = Util.GetGameObject(_go.transform,
"card/icon"):GetComponent("Image").material
end
end
--设置装备数据
function HandBookHeroAndEquipListPanel:OnShowSingleEquipData(_go, _equipData)
local equipData = _equipData
local itemConFigData = ConfigManager.GetConfigData(ConfigName.ItemConfig, equipData.Id)
Util.GetGameObject(_go.transform, "GameObject/item/resetLv"):SetActive(false)
Util.GetGameObject(_go.transform, "GameObject/item/frame"):GetComponent("Image").sprite = self.spLoader:LoadSprite(
GetQuantityImageByquality(equipData.Quality))
if itemConFigData then
Util.GetGameObject(_go.transform, "GameObject/item/icon"):GetComponent("Image").sprite = self.spLoader
:LoadSprite(GetResourcePath(itemConFigData.ResourceID))
end
Util.GetGameObject(_go.transform, "GameObject/name"):GetComponent("Text").text = GetLanguageStrById(equipData.Name)
Util.AddOnceClick(Util.GetGameObject(_go.transform, "GameObject/item/frame"), function()
-- UIManager.OpenPanel(UIName.HandBookEquipInfoPanel,equipData.Id)
local _itemData = {}
_itemData.id = equipData.Id
-- UIManager.OpenPanel(UIName.RoleEquipChangePopup, nil, 4, nil, _itemData, nil, nil)
UIManager.OpenPanel(UIName.RewardEquipSingleShowPopup2, self, _itemData, 0)
end)
if PlayerManager.equipHandBook[equipData.Id] == nil then
Util.SetGray(_go, true)
else
Util.SetGray(_go, false)
end
end
--设置法宝数据
function HandBookHeroAndEquipListPanel:OnShowSingleTalismanData(_go, _talismanData)
local talismanData = _talismanData
local itemConFigData = ConfigManager.GetConfigData(ConfigName.ItemConfig, talismanData.Id)
--设置星级
local starGrid = Util.GetGameObject(_go.transform, "GameObject/item/star")
SetHeroStars(self.spLoader, starGrid, talismanData.Quantity)
Util.GetGameObject(_go.transform, "GameObject/item/resetLv"):SetActive(false)
Util.GetGameObject(_go.transform, "GameObject/item/frame"):GetComponent("Image").sprite = self.spLoader:LoadSprite(
GetQuantityImageByquality(talismanData.Quantity))
if itemConFigData then
Util.GetGameObject(_go.transform, "GameObject/item/icon"):GetComponent("Image").sprite = self.spLoader
:LoadSprite(GetResourcePath(itemConFigData.ResourceID))
end
Util.GetGameObject(_go.transform, "GameObject/name"):GetComponent("Text").text = GetLanguageStrById(talismanData
.Name)
Util.AddOnceClick(Util.GetGameObject(_go.transform, "GameObject/item/frame"), function()
UIManager.OpenPanel(UIName.HandBookTalismanInfoPanel, talismanData.Id)
--Log("打开详细信息")
end)
if PlayerManager.talismanHandBook[talismanData.Id] == nil then
Util.SetGray(_go, true)
else
Util.SetGray(_go, false)
end
end
--设置选中按钮
function HandBookHeroAndEquipListPanel:SetSelectBtn()
PlayerManager.headBookListTag = proId
-- self.selectBtn:SetActive(proId ~= ProIdConst.All)
self.selectBtn.transform:SetParent(tabs[proId].transform)
self.selectBtn.transform.localPosition = Vector3.zero
self.selectBtn.transform:SetAsFirstSibling()
end
function HandBookHeroAndEquipListPanel:SortHeroNatural(heroList)
table.sort(heroList, function(a, b)
if a.Natural == b.Natural then
return a.Sort < b.Sort
else
return a.Natural > b.Natural
end
end)
end
return HandBookHeroAndEquipListPanel