miduo_client/Assets/ManagedResources/~Lua/Modules/GodPrint/GodPrintPanel.lua

547 lines
22 KiB
Lua
Raw Normal View History

2026-04-12 17:25:07 +08:00
----- 魂印主面板 -----
2022-04-22 18:23:01 +08:00
require("Base/BasePanel")
GodPrintPanel = Inherit(BasePanel)
local this = GodPrintPanel
2026-04-12 17:25:07 +08:00
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local equipConfig = ConfigManager.GetConfig(ConfigName.EquipConfig)
2022-04-22 18:23:01 +08:00
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
2026-04-12 17:25:07 +08:00
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
2022-04-22 18:23:01 +08:00
local equipSignSetting = ConfigManager.GetConfig(ConfigName.EquipSignSetting)
2026-04-12 17:25:07 +08:00
-- 循环布局容器
local loopList = {}
-- 最大槽位数量
local loopCount = 0
-- 可装备槽位数量
local didLen = 0
-- 动态最大等级
local didLv = 0
-- 配置最大等级
local maxLv = 0
-- 间隔角度
local angle = 0
-- 半径
local radius = 285
local curHeroData -- 当前英雄信息
local heroDatas -- 全部英雄数据
local index = 0 -- 当前索引
local isShow = true -- 默认显示装备中的魂印
local _specialData = {}
2022-04-22 18:23:01 +08:00
local isUpZhen = false
2026-04-12 17:25:07 +08:00
local list = {}
2022-04-22 18:23:01 +08:00
local teamHero = {}
local isPlayAnim = true
local isFristOpenTime
function GodPrintPanel:InitComponent()
this.spLoader = SpriteLoader.New()
2026-04-12 17:25:07 +08:00
this.upView = SubUIManager.Open(SubUIConfig.UpView, this.gameObject.transform, {
showType = UpViewOpenType.ShowLeft
})
this.helpBtn = Util.GetGameObject(this.gameObject, "HelpBtn")
this.helpPosition = this.helpBtn:GetComponent("RectTransform").localPosition
2022-04-22 18:23:01 +08:00
this.leftBtn = Util.GetGameObject(this.gameObject, "LeftBtn")
this.rightBtn = Util.GetGameObject(this.gameObject, "RightBtn")
2026-04-12 17:25:07 +08:00
this.handBookBtn = Util.GetGameObject(this.gameObject, "HandBookBtn") -- 图鉴按钮
this.detailsBtn = Util.GetGameObject(this.gameObject, "DetailsBtn") -- 细节按钮
this.showBtn = Util.GetGameObject(this.gameObject, "ShowBtn") -- 显示装备中的魂印按钮
this.showBtnOn = Util.GetGameObject(this.showBtn, "Bg/On"):GetComponent("Image")
2022-04-22 18:23:01 +08:00
this.showBtn:SetActive(false)
this.backBtn = Util.GetGameObject(this.gameObject, "BackBtn/btnBack")
2026-04-12 17:25:07 +08:00
this.empty = Util.GetGameObject(this.gameObject, "Empty")
this.emptyTxt = Util.GetGameObject(this.gameObject, "Empty/talkImage/Text"):GetComponent("Text")
this.emptyTxt.text = Language[12325]
-- 循环布局根节点
this.loopRoot = Util.GetGameObject(this.gameObject, "LoopRoot")
this.loopPre = Util.GetGameObject(this.loopRoot, "Pre")
-- 英雄头像
this.heroFrame = Util.GetGameObject(this.gameObject, "Hero/Frame"):GetComponent("Image")
this.heroIcon = Util.GetGameObject(this.gameObject, "Hero/Icon"):GetComponent("Image")
-- 战力
this.power = Util.GetGameObject(this.gameObject, "Power/Value"):GetComponent("Text")
this.scrollBar = Util.GetGameObject(this.gameObject, "Scrollbar"):GetComponent("Scrollbar")
-- 魂印列表
this.scrollRoot = Util.GetGameObject(this.gameObject, "ScrollRoot")
this.scrollPre = Util.GetGameObject(this.gameObject, "ScrollRoot/Pre")
this.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.scrollRoot.transform, this.scrollPre,
this.scrollBar, --
Vector2.New(this.scrollRoot.transform.rect.width, this.scrollRoot.transform.rect.height), 1, 5,
Vector2.New(45, 40))
this.scrollView.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(0, 0)
2022-04-22 18:23:01 +08:00
this.scrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
this.scrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
this.scrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
this.scrollView.moveTween.MomentumAmount = 1
this.scrollView.moveTween.Strength = 2
this.SetIsShow()
-- this.BgMask = Util.GetGameObject(this.gameObject,"bgMask")
end
2026-04-12 17:25:07 +08:00
2022-04-22 18:23:01 +08:00
-- function GodPrintPanel:SetSortingOrder()
-- end
function GodPrintPanel:BindEvent()
2026-04-12 17:25:07 +08:00
-- 帮助按钮
2022-04-22 18:23:01 +08:00
Util.AddClick(this.helpBtn, function()
2026-04-12 17:25:07 +08:00
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.GodPrint, this.helpPosition.x, this.helpPosition.y)
2022-04-22 18:23:01 +08:00
end)
2026-04-12 17:25:07 +08:00
-- 向左切换英雄数据
2022-04-22 18:23:01 +08:00
Util.AddClick(this.leftBtn, function()
isPlayAnim = true
this.OnLeftBtnClick()
end)
2026-04-12 17:25:07 +08:00
-- 向右切换英雄数据
2022-04-22 18:23:01 +08:00
Util.AddClick(this.rightBtn, function()
isPlayAnim = true
this.OnRightBtnClick()
end)
2026-04-12 17:25:07 +08:00
-- 点击图鉴按钮
2022-04-22 18:23:01 +08:00
Util.AddClick(this.handBookBtn, function()
UIManager.OpenPanel(UIName.GodPrintHandBook)
end)
2026-04-12 17:25:07 +08:00
-- 点击细节按钮
2022-04-22 18:23:01 +08:00
Util.AddClick(this.detailsBtn, function()
2026-04-12 17:25:07 +08:00
-- UIManager.OpenPanel(UIName.GodPrintPopUpV2,1,curHeroData)
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.GodPrint, this.helpPosition.x, this.helpPosition.y)
2022-04-22 18:23:01 +08:00
end)
2026-04-12 17:25:07 +08:00
-- 点击显示装备中魂印按钮
2022-04-22 18:23:01 +08:00
Util.AddClick(this.showBtn, function()
2026-04-12 17:25:07 +08:00
isShow = (not isShow and true or false)
this.showBtnOn.enabled = isShow
2022-04-22 18:23:01 +08:00
this.SetScrollData()
end)
2026-04-12 17:25:07 +08:00
-- 关闭页面
2022-04-22 18:23:01 +08:00
Util.AddClick(this.backBtn, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
end
function GodPrintPanel:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Bag.GetNewItemIncarnation, this.SetScrollData)
end
function GodPrintPanel:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.GetNewItemIncarnation, this.SetScrollData)
end
2026-04-12 17:25:07 +08:00
2022-04-22 18:23:01 +08:00
function GodPrintPanel:OnSortingOrderChange()
2026-04-12 17:25:07 +08:00
-- 特效层级重设
2022-04-22 18:23:01 +08:00
for _, v in pairs(list) do
Util.SetParticleSortLayer(v, self.sortingOrder)
2026-04-12 17:25:07 +08:00
end
2022-04-22 18:23:01 +08:00
end
2026-04-12 17:25:07 +08:00
function GodPrintPanel:OnOpen(_curHeroData, _heroDatas)
curHeroData = _curHeroData
2022-04-22 18:23:01 +08:00
heroDatas = {}
if _heroDatas then
for i = 1, #_heroDatas do
if GodPrintManager.GetSoulPrintIsOpen(_heroDatas[i]) then
2026-04-12 17:25:07 +08:00
table.insert(heroDatas, _heroDatas[i])
2022-04-22 18:23:01 +08:00
end
end
else
2026-04-12 17:25:07 +08:00
local curheroListData = HeroManager.GetAllHeroDatas()
2022-04-22 18:23:01 +08:00
for i = 1, #curheroListData do
if GodPrintManager.GetSoulPrintIsOpen(curheroListData[i]) then
2026-04-12 17:25:07 +08:00
table.insert(heroDatas, curheroListData[i])
2022-04-22 18:23:01 +08:00
end
end
end
for i = 1, #heroDatas do
if curHeroData.dynamicId == heroDatas[i].dynamicId then
index = i
break
end
end
end
function GodPrintPanel:OnShow()
isPlayAnim = true
2026-04-12 17:25:07 +08:00
this.upView:OnOpen({
showType = UpViewOpenType.ShowLeft,
panelType = PanelType.Main
})
-- 已激活魂印的Hero为1时 隐藏左右按钮
this.leftBtn.gameObject:SetActive(#heroDatas > 1)
this.rightBtn.gameObject:SetActive(#heroDatas > 1)
2022-04-22 18:23:01 +08:00
this.RefreshShow()
end
function GodPrintPanel:OnClose()
2026-04-12 17:25:07 +08:00
angle = 0
loopCount = 0
local var = isShow and 1 or 0
PlayerPrefs.SetInt(PlayerManager.uid .. "_GodPrint_IsShow", var)
2022-04-22 18:23:01 +08:00
if isFristOpenTime then
isFristOpenTime:Stop()
isFristOpenTime = nil
end
end
function GodPrintPanel:OnDestroy()
this.spLoader:Destroy()
SubUIManager.Close(this.upView)
2026-04-12 17:25:07 +08:00
this.scrollView = nil
loopList = {}
list = {}
2022-04-22 18:23:01 +08:00
end
2026-04-12 17:25:07 +08:00
-- 点击左
2022-04-22 18:23:01 +08:00
function this.OnLeftBtnClick()
index = (index - 1 > 0 and index - 1 or #heroDatas)
curHeroData = heroDatas[index]
this.RefreshShow()
end
2026-04-12 17:25:07 +08:00
-- 点击右
2022-04-22 18:23:01 +08:00
function this.OnRightBtnClick()
index = (index + 1 <= #heroDatas and index + 1 or 1)
curHeroData = heroDatas[index]
this.RefreshShow()
end
2026-04-12 17:25:07 +08:00
-- 刷新显示
2022-04-22 18:23:01 +08:00
function this.RefreshShow()
2026-04-12 17:25:07 +08:00
-- LogGreen("刷新魂印面板")
2022-04-22 18:23:01 +08:00
teamHero = FormationManager.GetAllMainFormationHeroId()
isUpZhen = teamHero[curHeroData.dynamicId] and true or false
this.SetLoopUI()
this.SetHero()
this.SetScrollData()
2026-04-12 17:25:07 +08:00
-- 对比战力并更新战力值 播放战力变更动画
2022-04-22 18:23:01 +08:00
local allAddProVal
2026-04-12 17:25:07 +08:00
-- 计算面板属性
2022-04-22 18:23:01 +08:00
local WarPower
if isUpZhen then
allAddProVal = HeroPropManager.GetHeroProp(curHeroData.dynamicId, FormationTypeDef.FORMATION_NORMAL)
2026-04-12 17:25:07 +08:00
WarPower = HeroPowerManager.GetHeroPower(curHeroData.dynamicId, FormationTypeDef.FORMATION_NORMAL)
else
2022-04-22 18:23:01 +08:00
allAddProVal = HeroPropManager.GetHeroProp(curHeroData.dynamicId)
2026-04-12 17:25:07 +08:00
WarPower = HeroPowerManager.GetHeroPower(curHeroData.dynamicId)
end
2022-04-22 18:23:01 +08:00
this.power.text = WarPower
end
2026-04-12 17:25:07 +08:00
-- 设置环形布局
2022-04-22 18:23:01 +08:00
function this.SetLoopUI()
2026-04-12 17:25:07 +08:00
local didLv = 0
-- 最终最大等级
local maxLv = 0
loopCount, didLen, didLv, maxLv = HeroManager.GetGodPrintLoopUIMaxData(curHeroData.lv)
2022-04-22 18:23:01 +08:00
-- LogBlue("最大槽位数量"..loopCount.." 可装备槽位数量"..didLen.." 最大动态等级"..didLv.." 配置最大等级"..maxLv)
local d = string.split(ConfigManager.GetConfigData(ConfigName.SpecialConfig, 149).Value, "#")
2026-04-12 17:25:07 +08:00
loopCount = #d
-- 初始化
for i = 1, #d do
2022-04-22 18:23:01 +08:00
if not loopList[i] then
2026-04-12 17:25:07 +08:00
loopList[i] = newObjToParent(this.loopPre, this.loopRoot)
2022-04-22 18:23:01 +08:00
end
2026-04-12 17:25:07 +08:00
loopList[i].name = "Pre" .. i
2022-04-22 18:23:01 +08:00
end
2026-04-12 17:25:07 +08:00
-- 设置不包含最后一位 为默认
for j = 1, #d do
2022-04-22 18:23:01 +08:00
loopList[j]:GetComponent("RectTransform").anchoredPosition = this.GetCurPosByIndex(j)
2026-04-12 17:25:07 +08:00
-- 由星级限制修改为鸿蒙等级限制
local harmony = HarmonyManager.GetSingleAdditionsData(HarmonyAddType.AddLv)
if (harmony and harmony.value >= tonumber(d[j])) or 1 >= tonumber(d[j]) then
-- if curHeroData.star >= tonumber(d[j]) then
this.SetLoopPre(loopList[j], 1, nil, nil, j)
2022-04-22 18:23:01 +08:00
else
2026-04-12 17:25:07 +08:00
this.SetLoopPre(loopList[j], 2, nil, tonumber(d[j]), j)
2022-04-22 18:23:01 +08:00
end
end
2026-04-12 17:25:07 +08:00
-- 数据赋值
-- LogError("#curHeroData.godPrintList=="..#curHeroData.godPrintList)
for k = 1, #curHeroData.godPrintList do
local index = curHeroData.godPrintList[k].position
this.SetLoopPre(loopList[index], 3, index, curHeroData.godPrintList[k])
2022-04-22 18:23:01 +08:00
end
end
2026-04-12 17:25:07 +08:00
-- 获取当前子布局坐标
2022-04-22 18:23:01 +08:00
function this.GetCurPosByIndex(index)
2026-04-12 17:25:07 +08:00
local hudu = (angle / 180) * Mathf.PI
angle = angle + (360 / loopCount)
return Vector2.New(radius * Mathf.Cos(hudu), radius * Mathf.Sin(hudu))
2022-04-22 18:23:01 +08:00
end
2026-04-12 17:25:07 +08:00
-- 设置环形布局预设 root:预设根节点 type:开启类型 index 位置 data:数据
function this.SetLoopPre(root, type, index, data, curIndex)
local normal = Util.GetGameObject(root, "Normal")
local lock = Util.GetGameObject(root, "Lock")
local unlock = Util.GetGameObject(root, "UnLock")
local bg = Util.GetGameObject(root, "Bg")
local lvTxt = Util.GetGameObject(root, "lv"):GetComponent("Text")
2024-01-02 16:58:06 +08:00
lvTxt.gameObject:SetActive(false)
2026-04-12 17:25:07 +08:00
Util.GetGameObject(bg, "Frame"):GetComponent("Image").enabled = false
2022-04-22 18:23:01 +08:00
if curIndex then
2026-04-12 17:25:07 +08:00
bg.transform:DORotate(Vector3.New(0, 0, (360 / loopCount) * (curIndex - 1) + root.transform.localRotation.z), 0)
2022-04-22 18:23:01 +08:00
end
2026-04-12 17:25:07 +08:00
normal:SetActive(type == 1) -- 解锁 未装备
lock:SetActive(type == 2) -- 锁定
unlock:SetActive(type == 3) -- 解锁装备魂印
root:GetComponent("Button").interactable = type == 3 -- 只有被赋值的按钮才能点击
if type == 1 then
Util.GetGameObject(bg, "bg"):GetComponent("Image").sprite = this.spLoader:LoadSprite(
SoulPrintSpriteByQuantity[0].circleBg1)
elseif type == 2 then
Util.GetGameObject(bg, "bg"):GetComponent("Image").sprite = this.spLoader:LoadSprite(
SoulPrintSpriteByQuantity[0].circleBg1)
-- Util.GetGameObject(lock, "Text"):GetComponent("Text").text = string.format(Language[11165], data)
-- Util.GetGameObject(lock, "Text"):GetComponent("Text").text = string.format(Language[11165], data)
Util.GetGameObject(lock, "Text"):GetComponent("Text").text =
string.format(GetLanguageStrById("伙伴共鸣%s级解锁"), data)
elseif type == 3 then
-- Util.GetGameObject(bg,"Frame"):GetComponent("Image").enabled=true
Util.GetGameObject(bg, "bg"):GetComponent("Image").sprite = this.spLoader:LoadSprite(
SoulPrintSpriteByQuantity[equipConfig[data.equipId].Quality].circleBg1)
-- Util.GetGameObject(bg,"Frame"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetQuantityImageByqualityPoint(equipConfig[data.equipId].Quality))
Util.GetGameObject(unlock, "circleFrame"):GetComponent("Image").sprite = this.spLoader:LoadSprite(
SoulPrintSpriteByQuantity[equipConfig[data.equipId].Quality].circleBg2)
Util.GetGameObject(unlock, "Icon"):GetComponent("Image").sprite =
this.spLoader:LoadSprite(GetResourcePath(itemConfig[data.equipId].ResourceID))
Util.GetGameObject(unlock, "circle"):GetComponent("Image").sprite = this.spLoader:LoadSprite(
SoulPrintSpriteByQuantity[equipConfig[data.equipId].Quality].circle)
Util.GetGameObject(unlock, "Name"):GetComponent("Text").text = GetLanguageStrById(itemConfig[data.equipId].Name)
lvTxt.gameObject:SetActive(equipConfig[data.equipId].Star > 0)
lvTxt.text = "+" .. equipConfig[data.equipId].Star
Util.AddOnceClick(root, function()
local pos = index
LogBlue("卸下时 " .. data.equipId)
UIManager.OpenPanel(UIName.GodPrintPopUp, 2, curHeroData.dynamicId, data.equipId, pos, function()
2022-04-22 18:23:01 +08:00
this.RefreshShow()
2026-04-12 17:25:07 +08:00
-- 对比战力并更新战力值 播放战力变更动画
2022-04-22 18:23:01 +08:00
HeroManager.CompareWarPower(curHeroData.dynamicId)
LogError("刷新完界面数据")
end)
end)
end
end
2026-04-12 17:25:07 +08:00
-- 设置英雄
2022-04-22 18:23:01 +08:00
function this.SetHero()
2026-04-12 17:25:07 +08:00
this.heroIcon.sprite = this.spLoader:LoadSprite(curHeroData.icon)
this.heroFrame.sprite = this.spLoader:LoadSprite(GetHeroQuantityImageByquality(curHeroData.heroConfig.Quality,
curHeroData.star))
2022-04-22 18:23:01 +08:00
-- local allPro = HeroManager.CalculateHeroAllProValList(1, curHeroData.dynamicId, false)
local WarPower
2026-04-12 17:25:07 +08:00
-- 计算面板属性
2022-04-22 18:23:01 +08:00
if isUpZhen then
2026-04-12 17:25:07 +08:00
WarPower = HeroPowerManager.GetHeroPower(curHeroData.dynamicId, FormationTypeDef.FORMATION_NORMAL)
else
WarPower = HeroPowerManager.GetHeroPower(curHeroData.dynamicId)
end
2022-04-22 18:23:01 +08:00
this.power.text = WarPower
end
2026-04-12 17:25:07 +08:00
-- 设置装备中的魂印
2022-04-22 18:23:01 +08:00
function this.SetIsShow()
if PlayerPrefs.GetInt(PlayerManager.uid .. "_GodPrint_IsShow") then
2026-04-12 17:25:07 +08:00
isShow = PlayerPrefs.GetInt(PlayerManager.uid .. "_GodPrint_IsShow") == 1
2022-04-22 18:23:01 +08:00
else
2026-04-12 17:25:07 +08:00
isShow = true
2022-04-22 18:23:01 +08:00
end
2026-04-12 17:25:07 +08:00
this.showBtnOn.enabled = isShow
2022-04-22 18:23:01 +08:00
end
2026-04-12 17:25:07 +08:00
-- 设置魂印列表滚动条
2022-04-22 18:23:01 +08:00
function this.SetScrollData()
2026-04-12 17:25:07 +08:00
local data = GodPrintManager.GetAllSoulPrint(isShow, curHeroData.id, curHeroData.dynamicId, curHeroData)
this.empty:SetActive(#data == 0)
2022-04-22 18:23:01 +08:00
this.ShowRedPotDataAndSort(data)
2026-04-12 17:25:07 +08:00
this.scrollView:SetData(data, function(index, root)
this.SetScrollPre(root, data[index])
2022-04-22 18:23:01 +08:00
list[root] = root
2026-04-12 17:25:07 +08:00
end, true, true)
2022-04-22 18:23:01 +08:00
if isPlayAnim then
if isFristOpenTime then
isFristOpenTime:Stop()
isFristOpenTime = nil
end
-- isFristOpenTime = Timer.New(function()
-- this.BgMask:SetActive(false)
2026-04-12 17:25:07 +08:00
-- end, 1):Start()
-- this.BgMask:SetActive(true)
2022-04-22 18:23:01 +08:00
SecTorPlayAnimByScroll(this.scrollView)
isPlayAnim = false
end
this.scrollView:SetIndex(1)
end
2026-04-12 17:25:07 +08:00
-- 设置魂印列表预设
function this.SetScrollPre(root, data)
2022-04-22 18:23:01 +08:00
Util.SetParticleSortLayer(root, this.sortingOrder + 1)
SetSoulEffect(itemConfig[data.id].Quantity1, root)
2026-04-12 17:25:07 +08:00
local frame = Util.GetGameObject(root, "Frame"):GetComponent("Image")
local icon = Util.GetGameObject(root, "Icon"):GetComponent("Image")
local name = Util.GetGameObject(root, "Name"):GetComponent("Text")
local hero = Util.GetGameObject(root, "Hero")
local heroIcon = Util.GetGameObject(hero, "Icon"):GetComponent("Image")
local circle = Util.GetGameObject(root, "circle"):GetComponent("Image")
local equipped = Util.GetGameObject(root, "Equipped") -- 是否已装备
local lvTxt = Util.GetGameObject(root, "lv"):GetComponent("Text")
Util.GetGameObject(root, "limit"):SetActive(equipConfig[data.id].limit == 1 and
not GodPrintManager.GetCurGodPrintIsCanUp(data.id) and data.upHero ==
"")
frame.sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(equipConfig[data.id].Quality))
circle.sprite = this.spLoader:LoadSprite(SoulPrintSpriteByQuantity[equipConfig[data.id].Quality].circle)
icon.sprite = this.spLoader:LoadSprite(GetResourcePath(itemConfig[data.id].ResourceID))
name.text = SubString2(GetLanguageStrById(equipConfig[data.id].Name), 8)
hero.gameObject:SetActive(data.upHero ~= "")
lvTxt.gameObject:SetActive(equipConfig[data.id].Star > 0)
lvTxt.text = "+" .. equipConfig[data.id].Star
Util.GetGameObject(root, "redPoint"):SetActive(data.isShowRedPot == 1)
2022-04-22 18:23:01 +08:00
equipped.gameObject:SetActive(this.GetCurHeroSoulPrintState(data.id))
2026-04-12 17:25:07 +08:00
if data.upHero ~= "" then
2022-04-22 18:23:01 +08:00
local heroData = HeroManager.GetSingleHeroData(data.upHero)
2026-04-12 17:25:07 +08:00
local heroId = heroData.id
-- LogGreen(heroId)
heroIcon.sprite = this.spLoader:LoadSprite(heroData.icon)
2022-04-22 18:23:01 +08:00
end
2026-04-12 17:25:07 +08:00
-- 点击事件(穿戴或替换魂印)
Util.AddOnceClick(root, function()
if not GodPrintManager.GetCurGodPrintIsCanUp(data.id) and data.upHero == "" then
PopupTipPanel.ShowTip(Language[11166])
2022-04-22 18:23:01 +08:00
return
end
2026-04-12 17:25:07 +08:00
if this.GetCurHeroSoulPrintState(data.id) then
PopupTipPanel.ShowTip(Language[11166])
2022-04-22 18:23:01 +08:00
return
2026-04-12 17:25:07 +08:00
end
local pos = this.GetPos() -- 位置
2022-04-22 18:23:01 +08:00
local oldPower = HeroManager.GetSingleHeroData(curHeroData.dynamicId).warPower
2026-04-12 17:25:07 +08:00
UIManager.OpenPanel(UIName.GodPrintPopUp, 1, curHeroData.dynamicId, data.id, pos, function()
2022-05-05 11:52:48 +08:00
-- if curHeroData.dynamicId then
2026-04-12 17:25:07 +08:00
-- PopupTipPanel.ShowTip("装备成功!")
2022-05-05 11:52:48 +08:00
-- end
2022-04-22 18:23:01 +08:00
this.RefreshShow()
2026-04-12 17:25:07 +08:00
-- 对比战力并更新战力值 播放战力变更动画
HeroManager.CompareWarPower1(curHeroData.dynamicId, oldPower)
end, data)
2022-04-22 18:23:01 +08:00
-- end
end)
end
2026-04-12 17:25:07 +08:00
-- 自动获取魂印的位置 如果有位置返回位置 如果没位置返回0
2022-04-22 18:23:01 +08:00
function this.GetPos()
2026-04-12 17:25:07 +08:00
local _data = {}
for k = 1, loopCount do
if Util.GetGameObject(loopList[k].gameObject, "UnLock").activeSelf then
table.insert(_data, k, k)
2022-04-22 18:23:01 +08:00
end
end
2026-04-12 17:25:07 +08:00
if didLen == LengthOfTable(_data) then
-- LogError("ssssssssssssssssss"..tostring(loopCount).."/"..tostring(didLen).."/"..tostring( LengthOfTable(_data)))
return 0
end
2022-04-22 18:23:01 +08:00
for i = 1, loopCount do
2026-04-12 17:25:07 +08:00
if _data[i] == nil then
-- LogError("ssssssssssssssssss"..tostring(loopCount).."/"..tostring(didLen).."/"..tostring( LengthOfTable(_data)))
2022-04-22 18:23:01 +08:00
return i
end
end
end
2026-04-12 17:25:07 +08:00
2022-04-22 18:23:01 +08:00
function this.ShowRedPotDataAndSort(allData)
2026-04-12 17:25:07 +08:00
if curHeroData.godPrintList and #curHeroData.godPrintList >= 3 then
table.sort(allData, function(a, b)
if this.GetCurHeroSoulPrintState(a.id) == this.GetCurHeroSoulPrintState(b.id) then
if equipConfig[a.id].Quality == equipConfig[b.id].Quality then
return a.id > b.id
else
return equipConfig[a.id].Quality > equipConfig[b.id].Quality
end
elseif this.GetCurHeroSoulPrintState(a.id) == false and this.GetCurHeroSoulPrintState(b.id) then
return true
2022-04-22 18:23:01 +08:00
else
2026-04-12 17:25:07 +08:00
return false
2022-04-22 18:23:01 +08:00
end
end)
2026-04-12 17:25:07 +08:00
return
2022-04-22 18:23:01 +08:00
end
2026-04-12 17:25:07 +08:00
local allUpSoulPrint = {} -- 所有已上魂印
2022-04-22 18:23:01 +08:00
if curHeroData.godPrintList then
for i = 1, #curHeroData.godPrintList do
2026-04-12 17:25:07 +08:00
local equip = equipConfig[curHeroData.godPrintList[i].equipId]
-- allUpSoulPrint[curHeroData.godPrintList[i].equipId] = equip --curHeroData.godPrintList[i]
-- LogError("equip.SuiteID=="..equip.SuiteID)
table.insert(allUpSoulPrint, equip.SuiteID)
2022-04-22 18:23:01 +08:00
end
end
2026-04-12 17:25:07 +08:00
-- LogError("allUpSoulPrint "..LengthOfTable(allUpSoulPrint).." "..#allData)
local haveRedPointSid = {} -- 所有已标记红点魂印
2022-04-22 18:23:01 +08:00
2026-04-12 17:25:07 +08:00
local temp = GodPrintManager.GetAllSoulPrint(true, curHeroData.id, curHeroData.dynamicId, curHeroData)
local limitSoulPrint = {}
2022-04-22 18:23:01 +08:00
for i = 1, #temp do
if not limitSoulPrint[temp[i].id] and equipConfig[temp[i].id].limit == 1 and temp[i].upHero ~= "" then
limitSoulPrint[temp[i].id] = temp[i].id
end
end
2026-04-12 17:25:07 +08:00
2022-04-22 18:23:01 +08:00
for i = 1, #allData do
2026-04-12 17:25:07 +08:00
-- 这个英雄没有装备这个魂印,并且可以装备,并且不在haveRedPointSid列表里
2022-04-22 18:23:01 +08:00
allData[i].isShowRedPot = 0
2026-04-12 17:25:07 +08:00
local suitId = equipConfig[allData[i].id].SuiteID
local isHave = false
for k = 1, #allUpSoulPrint do
if allUpSoulPrint[k] == suitId then
isHave = true
2022-04-22 18:23:01 +08:00
end
end
2026-04-12 17:25:07 +08:00
local isHaveCurHeroid = HeroManager.CheckHeroIsCanAddGodPrint(equipConfig[allData[i].id].ProfessionLimit,
curHeroData)
local allNum, open = HeroManager.GetGodPrintLoopUIMaxData(curHeroData.lv)
-- LogError("#curHeroData.godPrintList=="..#curHeroData.godPrintList.." open=="..open.." curHeroData.star=="..curHeroData.star)
if not isHave and isHaveCurHeroid and allData[i].upHero == "" and not haveRedPointSid[suitId] and
#curHeroData.godPrintList < open then
allData[i].isShowRedPot = 1 -- 有空位可以穿戴
2022-04-22 18:23:01 +08:00
haveRedPointSid[suitId] = suitId
end
if limitSoulPrint[allData[i].id] then
allData[i].isShowRedPot = 0
2026-04-12 17:25:07 +08:00
end
2022-04-22 18:23:01 +08:00
end
2026-04-12 17:25:07 +08:00
table.sort(allData, function(a, b)
2022-04-22 18:23:01 +08:00
if a.isShowRedPot > b.isShowRedPot then
2026-04-12 17:25:07 +08:00
return true
elseif a.isShowRedPot == b.isShowRedPot then
2022-04-22 18:23:01 +08:00
if equipConfig[a.id].Quality == equipConfig[b.id].Quality then
return a.id > b.id
2026-04-12 17:25:07 +08:00
else
return equipConfig[a.id].Quality > equipConfig[b.id].Quality
end
2022-04-22 18:23:01 +08:00
else
return false
end
end)
end
2026-04-12 17:25:07 +08:00
-- 获取当前英雄是否已装备该魂印
2022-04-22 18:23:01 +08:00
function this.GetCurHeroSoulPrintState(id)
2026-04-12 17:25:07 +08:00
for k = 1, #curHeroData.godPrintList do
local _id = curHeroData.godPrintList[k].equipId
if equipConfig[_id].SuiteID == equipConfig[id].SuiteID then
2022-04-22 18:23:01 +08:00
return true
end
2022-04-29 18:36:20 +08:00
-- if equipConfig[_id].Id==equipConfig[id].Id then
-- return true
-- end
2022-04-22 18:23:01 +08:00
end
return false
end
2026-04-12 17:25:07 +08:00
return GodPrintPanel