DESKTOP-MMO982B\User 2026-04-12 17:25:07 +08:00
parent eb2172cf6c
commit 8b2a116230
1 changed files with 291 additions and 258 deletions

View File

@ -1,4 +1,4 @@
----- 魂印主面板 -----
----- 魂印主面板 -----
require("Base/BasePanel")
GodPrintPanel = Inherit(BasePanel)
local this = GodPrintPanel
@ -18,9 +18,9 @@ local didLv=0
-- 配置最大等级
local maxLv = 0
-- 间隔角度
local angle=270
local angle = 0
-- 半径
local radius=250
local radius = 285
local curHeroData -- 当前英雄信息
local heroDatas -- 全部英雄数据
@ -35,7 +35,9 @@ local isPlayAnim = true
local isFristOpenTime
function GodPrintPanel:InitComponent()
this.spLoader = SpriteLoader.New()
this.upView = SubUIManager.Open(SubUIConfig.UpView, this.gameObject.transform, { showType = UpViewOpenType.ShowLeft})
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
this.leftBtn = Util.GetGameObject(this.gameObject, "LeftBtn")
@ -64,8 +66,10 @@ function GodPrintPanel:InitComponent()
-- 魂印列表
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 = 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)
this.scrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
this.scrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
@ -75,6 +79,7 @@ function GodPrintPanel:InitComponent()
this.SetIsShow()
-- this.BgMask = Util.GetGameObject(this.gameObject,"bgMask")
end
-- function GodPrintPanel:SetSortingOrder()
-- end
@ -122,6 +127,7 @@ end
function GodPrintPanel:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.GetNewItemIncarnation, this.SetScrollData)
end
function GodPrintPanel:OnSortingOrderChange()
-- 特效层级重设
for _, v in pairs(list) do
@ -153,21 +159,22 @@ function GodPrintPanel:OnOpen(_curHeroData,_heroDatas)
break
end
end
end
function GodPrintPanel:OnShow()
isPlayAnim = true
this.upView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main })
this.upView:OnOpen({
showType = UpViewOpenType.ShowLeft,
panelType = PanelType.Main
})
-- 已激活魂印的Hero为1时 隐藏左右按钮
this.leftBtn.gameObject:SetActive(#heroDatas > 1)
this.rightBtn.gameObject:SetActive(#heroDatas > 1)
this.RefreshShow()
end
function GodPrintPanel:OnClose()
angle=270
angle = 0
loopCount = 0
local var = isShow and 1 or 0
PlayerPrefs.SetInt(PlayerManager.uid .. "_GodPrint_IsShow", var)
@ -191,6 +198,7 @@ function this.OnLeftBtnClick()
curHeroData = heroDatas[index]
this.RefreshShow()
end
-- 点击右
function this.OnRightBtnClick()
index = (index + 1 <= #heroDatas and index + 1 or 1)
@ -198,7 +206,6 @@ function this.OnRightBtnClick()
this.RefreshShow()
end
-- 刷新显示
function this.RefreshShow()
-- LogGreen("刷新魂印面板")
@ -226,7 +233,7 @@ function this.SetLoopUI()
local didLv = 0
-- 最终最大等级
local maxLv = 0
loopCount,didLen,didLv,maxLv= HeroManager.GetGodPrintLoopUIMaxData(curHeroData.star)
loopCount, didLen, didLv, maxLv = HeroManager.GetGodPrintLoopUIMaxData(curHeroData.lv)
-- LogBlue("最大槽位数量"..loopCount.." 可装备槽位数量"..didLen.." 最大动态等级"..didLv.." 配置最大等级"..maxLv)
local d = string.split(ConfigManager.GetConfigData(ConfigName.SpecialConfig, 149).Value, "#")
loopCount = #d
@ -240,7 +247,10 @@ function this.SetLoopUI()
-- 设置不包含最后一位 为默认
for j = 1, #d do
loopList[j]:GetComponent("RectTransform").anchoredPosition = this.GetCurPosByIndex(j)
if curHeroData.star>=tonumber(d[j]) then
-- 由星级限制修改为鸿蒙等级限制
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)
else
this.SetLoopPre(loopList[j], 2, nil, tonumber(d[j]), j)
@ -254,12 +264,14 @@ function this.SetLoopUI()
this.SetLoopPre(loopList[index], 3, index, curHeroData.godPrintList[k])
end
end
-- 获取当前子布局坐标
function this.GetCurPosByIndex(index)
local hudu = (angle / 180) * Mathf.PI
angle = angle + (360 / loopCount)
return Vector2.New(radius * Mathf.Cos(hudu), radius * Mathf.Sin(hudu))
end
-- 设置环形布局预设 root:预设根节点 type:开启类型 index 位置 data:数据
function this.SetLoopPre(root, type, index, data, curIndex)
local normal = Util.GetGameObject(root, "Normal")
@ -270,24 +282,33 @@ function this.SetLoopPre(root,type,index,data,curIndex)
lvTxt.gameObject:SetActive(false)
Util.GetGameObject(bg, "Frame"):GetComponent("Image").enabled = false
if curIndex then
bg.transform:DORotate(Vector3.New(0,0,(360/loopCount)*(curIndex-1) + root.transform.localRotation.z-90),0)
bg.transform:DORotate(Vector3.New(0, 0, (360 / loopCount) * (curIndex - 1) + root.transform.localRotation.z), 0)
end
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)
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("%s星解锁",data)
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, "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, "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
@ -307,7 +328,8 @@ end
-- 设置英雄
function this.SetHero()
this.heroIcon.sprite = this.spLoader:LoadSprite(curHeroData.icon)
this.heroFrame.sprite=this.spLoader:LoadSprite(GetHeroQuantityImageByquality(curHeroData.heroConfig.Quality,curHeroData.star))
this.heroFrame.sprite = this.spLoader:LoadSprite(GetHeroQuantityImageByquality(curHeroData.heroConfig.Quality,
curHeroData.star))
-- local allPro = HeroManager.CalculateHeroAllProValList(1, curHeroData.dynamicId, false)
local WarPower
-- 计算面板属性
@ -319,7 +341,6 @@ function this.SetHero()
this.power.text = WarPower
end
-- 设置装备中的魂印
function this.SetIsShow()
if PlayerPrefs.GetInt(PlayerManager.uid .. "_GodPrint_IsShow") then
@ -354,9 +375,9 @@ function this.SetScrollData()
end
this.scrollView:SetIndex(1)
end
-- 设置魂印列表预设
function this.SetScrollPre(root, data)
Util.SetParticleSortLayer(root, this.sortingOrder + 1)
SetSoulEffect(itemConfig[data.id].Quantity1, root)
@ -368,7 +389,9 @@ function this.SetScrollPre(root,data)
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=="")
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))
@ -387,18 +410,18 @@ function this.SetScrollPre(root,data)
-- 点击事件(穿戴或替换魂印)
Util.AddOnceClick(root, function()
if not GodPrintManager.GetCurGodPrintIsCanUp(data.id) and data.upHero == "" then
PopupTipPanel.ShowTip("该神印只能装备一个")
PopupTipPanel.ShowTip(Language[11166])
return
end
if this.GetCurHeroSoulPrintState(data.id) then
PopupTipPanel.ShowTip("该神印只能装备一个")
PopupTipPanel.ShowTip(Language[11166])
return
end
local pos = this.GetPos() -- 位置
local oldPower = HeroManager.GetSingleHeroData(curHeroData.dynamicId).warPower
UIManager.OpenPanel(UIName.GodPrintPopUp, 1, curHeroData.dynamicId, data.id, pos, function()
-- if curHeroData.dynamicId then
-- PopupTipPanel.ShowTip(Language[11526])
-- PopupTipPanel.ShowTip("装备成功!")
-- end
this.RefreshShow()
-- 对比战力并更新战力值 播放战力变更动画
@ -416,23 +439,32 @@ function this.GetPos()
table.insert(_data, k, k)
end
end
for i = 1, loopCount do
if _data[i]==nil then
return i
end
if didLen == LengthOfTable(_data) then
-- LogError("ssssssssssssssssss"..tostring(loopCount).."/"..tostring(didLen).."/"..tostring( LengthOfTable(_data)))
return 0
end
for i = 1, loopCount do
if _data[i] == nil then
-- LogError("ssssssssssssssssss"..tostring(loopCount).."/"..tostring(didLen).."/"..tostring( LengthOfTable(_data)))
return i
end
end
end
function this.ShowRedPotDataAndSort(allData)
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
else
return false
end
end)
return
end
@ -467,13 +499,14 @@ function this.ShowRedPotDataAndSort(allData)
isHave = true
end
end
local isHaveCurHeroid = HeroManager.CheckHeroIsCanAddGodPrint(equipConfig[allData[i].id].ProfessionLimit,curHeroData)
local allNum,open=HeroManager.GetGodPrintLoopUIMaxData(curHeroData.star)
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
if not isHave and isHaveCurHeroid and allData[i].upHero == "" and not haveRedPointSid[suitId] and
#curHeroData.godPrintList < open then
allData[i].isShowRedPot = 1 -- 有空位可以穿戴
haveRedPointSid[suitId] = suitId
end
if limitSoulPrint[allData[i].id] then