miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/SoulPrintPopUp.lua

338 lines
15 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
----- 魂印弹窗 -----
2020-05-09 13:31:21 +08:00
require("Base/BasePanel")
SoulPrintPopUp = Inherit(BasePanel)
2024-09-06 10:38:56 +08:00
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local equipConfig = ConfigManager.GetConfig(ConfigName.EquipConfig)
local passiveSkillConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
local propertyconfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
2020-05-09 13:31:21 +08:00
2020-05-09 13:31:21 +08:00
--面板类型
2024-09-06 10:38:56 +08:00
local Type = {
Up = 1, --穿戴
Down = 2, --卸下
Access = 3, --有获取途径 传nil就不显示了
2020-05-09 13:31:21 +08:00
}
--打开面板类型
2024-09-06 10:38:56 +08:00
local curType = 0
2020-05-09 13:31:21 +08:00
2024-09-06 10:38:56 +08:00
local heroId --当前英雄id
local soulId --魂印id
local pos --位置
local callback --回调
2020-05-09 13:31:21 +08:00
local localData --本地存储的魂印数据 包含soulId 该数据只在魂印装备时Type.Up才有用
--适用范围英雄容器
local proList = {}
function SoulPrintPopUp:InitComponent()
2021-11-09 15:48:56 +08:00
self.spLoader = SpriteLoader.New()
2024-09-06 10:38:56 +08:00
self.panel = Util.GetGameObject(self.gameObject, "Panel")
self.maskBtn = Util.GetGameObject(self.gameObject, "mask")
2020-05-09 13:31:21 +08:00
--基础信息
2021-11-09 15:48:56 +08:00
--装备详情--topBar
self.topBar = Util.GetGameObject(self.transform, "Panel/topBar")
self.soulName = Util.GetGameObject(self.topBar, "name"):GetComponent("Text")
self.icon = Util.GetGameObject(self.topBar, "icon"):GetComponent("Image")
self.frame = Util.GetGameObject(self.topBar, "frame"):GetComponent("Image")
2024-09-06 10:38:56 +08:00
self.circleFrameBg = Util.GetGameObject(self.topBar, "circleFrameBg"):GetComponent("Image")
self.circleFrame = Util.GetGameObject(self.topBar, "circleFrame"):GetComponent("Image")
self.equipType = Util.GetGameObject(self.topBar, "equipType"):GetComponent("Text")
self.equipQuaText = Util.GetGameObject(self.topBar, "equipQuaText"):GetComponent("Text")
self.equipInfoText = Util.GetGameObject(self.topBar, "equipInfoText"):GetComponent("Text")
self.powerNum = Util.GetGameObject(self.topBar, "powerNum"):GetComponent("Text")
self.star = Util.GetGameObject(self.topBar, "star")
2021-11-09 15:48:56 +08:00
self.effectbaijin = Util.GetGameObject(self.topBar, "fx_zhuangbeijiemian")
2020-05-09 13:31:21 +08:00
--魂印效果
2021-11-09 15:48:56 +08:00
self.midBar = Util.GetGameObject(self.transform, "Panel/midBar")
2024-09-06 10:38:56 +08:00
self.effectText = Util.GetGameObject(self.midBar, "basePro/Info"):GetComponent("Text")
2021-11-09 15:48:56 +08:00
2020-05-09 13:31:21 +08:00
--适用范围(还没做具体内容)
2024-09-06 10:38:56 +08:00
self.trialScope = Util.GetGameObject(self.midBar, "TrialScope")
self.trialScopeText = Util.GetGameObject(self.trialScope, "Text"):GetComponent("Text")
2020-05-09 13:31:21 +08:00
--数据小于4自动布局
2024-09-06 10:38:56 +08:00
self.scroll_1 = Util.GetGameObject(self.trialScope, "Scroll_1") --静态布局根节点
self.trialScopePre = Util.GetGameObject(self.trialScope, "Scroll_1/TrialScopePre") --适用范围预设
2020-05-09 13:31:21 +08:00
--数据大于4优化布局
2024-09-06 10:38:56 +08:00
self.scroll_2 = Util.GetGameObject(self.trialScope, "Scroll_2") --优化滚动条
self.scrollView = SubUIManager.Open(SubUIConfig.ScrollFitterView, self.scroll_2.transform, self.trialScopePre,
Vector2.New(899.5, 490), 1, 15)
self.scrollView.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(-70, 0)
2021-11-09 15:48:56 +08:00
self.scrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
self.scrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
self.scrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
self.scrollView.moveTween.MomentumAmount = 1
self.scrollView.moveTween.Strength = 2
2020-05-09 13:31:21 +08:00
2021-11-09 15:48:56 +08:00
self.btmBar = Util.GetGameObject(self.transform, "Panel/btmBar")
2020-05-09 13:31:21 +08:00
--获取途径
2021-11-09 15:48:56 +08:00
self.howGet = Util.GetGameObject(self.btmBar, "howGet")
self.canGetPre = Util.GetGameObject(self.howGet, "scroll/canGetPre")
self.canGetGrid = Util.GetGameObject(self.howGet, "scroll")
2024-09-06 10:38:56 +08:00
self.canGetScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.canGetGrid.transform, self.canGetPre, nil,
Vector2.New(self.canGetGrid.transform.rect.width, self.canGetGrid.transform.rect.height), 1, 1, Vector2.New(0, 0))
2021-11-09 15:48:56 +08:00
self.canGetScrollView.moveTween.MomentumAmount = 1
self.canGetScrollView.moveTween.Strength = 2
self.canGetScrollView.elastic = false
self.jumpViewList = {}
2020-05-09 13:31:21 +08:00
--操作按钮
2024-09-06 10:38:56 +08:00
self.btns = Util.GetGameObject(self.btmBar, "btnGrid")
self.upBtn = Util.GetGameObject(self.btns, "UpBtn")
self.downBtn = Util.GetGameObject(self.btns, "DownBtn")
2020-05-09 13:31:21 +08:00
end
function SoulPrintPopUp:BindEvent()
--关闭面板
2021-11-09 15:48:56 +08:00
Util.AddClick(self.maskBtn, function()
2020-06-13 11:47:13 +08:00
self:ClosePanel()
end)
2020-05-09 13:31:21 +08:00
--穿戴
2024-09-06 10:38:56 +08:00
Util.AddClick(self.upBtn, function()
2020-05-09 13:31:21 +08:00
--检测是否已穿过该类型魂印
local curHeroData = HeroManager.GetSingleHeroData(heroId)
if curHeroData and curHeroData.soulPrintList and #curHeroData.soulPrintList > 0 then
for i = 1, #curHeroData.soulPrintList do
if curHeroData.soulPrintList[i].equipId == soulId then
2024-08-29 21:36:51 +08:00
PopupTipPanel.ShowTip(Language[11169])
2020-05-09 13:31:21 +08:00
return
end
end
end
--如果装备位置满了 显示替换界面
2024-09-06 10:38:56 +08:00
if pos == 0 then
UIManager.OpenPanel(UIName.SoulPrintPopUpV2, 2, curHeroData, localData, function()
2020-05-09 13:31:21 +08:00
self:ClosePanel()
2021-11-09 15:48:56 +08:00
self:RefreshShow()
if callback then
callback()
end
2020-05-09 13:31:21 +08:00
end)
return
end
--如果是别人装备的
2024-09-06 10:38:56 +08:00
if localData.upHero ~= "" then
2020-05-09 13:31:21 +08:00
--当前点击魂印被装到的英雄数据
2024-09-06 10:38:56 +08:00
local curClickHeroData = HeroManager.GetSingleHeroData(localData.upHero)
local str = string.format(Language[11180], itemConfig[curClickHeroData.id].Name,
equipConfig[localData.id].Name, itemConfig[curHeroData.id].Name)
2020-05-09 13:31:21 +08:00
MsgPanel.ShowTwo(str, nil, function()
local _pos = 0
for i = 1, #curClickHeroData.soulPrintList do
if curClickHeroData.soulPrintList[i].equipId == localData.id then
_pos = curClickHeroData.soulPrintList[i].position
end
end
2024-09-06 10:38:56 +08:00
NetManager.SoulEquipUnLoadWearRequest(tostring(curClickHeroData.dynamicId), localData.id, _pos,
function()
HeroManager.DelSoulPrintUpHeroDynamicId(curClickHeroData.dynamicId, localData.id)
local wearInfo = {
heroId = tostring(curHeroData.dynamicId),
equipId = localData.id,
position =
pos
}
NetManager.SoulEquipWearRequest(wearInfo, nil, function()
HeroManager.AddSoulPrintUpHeroDynamicId(curHeroData.dynamicId, localData.id, pos)
PopupTipPanel.ShowTip(Language[11170])
self:RefreshShow()
--
if callback then
callback()
end
self:ClosePanel()
end)
2020-05-09 13:31:21 +08:00
end)
end)
return
end
-- else--选择的魂印没有被其他猎妖师装备 可直接装备
--穿戴
2024-09-06 10:38:56 +08:00
local wearInfo = { heroId = tostring(heroId), equipId = soulId, position = pos }
NetManager.SoulEquipWearRequest(wearInfo, nil, function()
HeroManager.AddSoulPrintUpHeroDynamicId(heroId, soulId, pos)
2020-05-09 13:31:21 +08:00
if callback then
callback()
end
end)
self:ClosePanel()
-- end
end)
--卸下
2024-09-06 10:38:56 +08:00
Util.AddClick(self.downBtn, function()
NetManager.SoulEquipUnLoadWearRequest(tostring(heroId), soulId, pos, function()
HeroManager.DelSoulPrintUpHeroDynamicId(heroId, soulId)
2020-05-09 13:31:21 +08:00
if callback then
callback()
end
end)
self:ClosePanel()
end)
end
function SoulPrintPopUp:AddListener()
end
function SoulPrintPopUp:RemoveListener()
end
--curtype 面板类型(看最上面解释) heroId 英雄ID soulId魂印ID pos位置 callback回调 localData本地存储魂印数据只在穿戴时用
function SoulPrintPopUp:OnOpen(...)
2024-09-06 10:38:56 +08:00
local args = { ... }
curType = args[1]
heroId = args[2]
soulId = args[3]
pos = args[4]
callback = args[5]
localData = args[6]
2020-05-09 13:31:21 +08:00
end
function SoulPrintPopUp:OnShow()
2021-11-09 15:48:56 +08:00
self:RefreshShow(curType)
2020-05-09 13:31:21 +08:00
end
function SoulPrintPopUp:OnClose()
2021-11-09 15:48:56 +08:00
for i = 1, #self.jumpViewList do
destroy(self.jumpViewList[i].gameObject)
end
2020-05-09 13:31:21 +08:00
end
function SoulPrintPopUp:OnDestroy()
2021-11-09 15:48:56 +08:00
self.spLoader:Destroy()
2024-09-06 10:38:56 +08:00
self.scrollView = nil
proList = {}
2021-11-09 15:48:56 +08:00
self.jumpViewList = {}
2020-05-09 13:31:21 +08:00
end
2020-06-13 11:47:13 +08:00
--读取魂印适用英雄效果
2024-09-06 10:38:56 +08:00
local x = function(index)
local args = {}
local tempArgs = string.split(GetLanguageStrById(equipConfig[soulId].Parameter), '|')
local t = string.split(tempArgs[index], '#')
2021-01-26 17:08:39 +08:00
for i, v in ipairs(t) do
2024-09-06 10:38:56 +08:00
args[i] = v
2020-06-13 11:47:13 +08:00
end
2024-09-06 10:38:56 +08:00
return string.format(GetLanguageStrById(equipConfig[soulId].Describe), unpack(args))
2020-06-13 11:47:13 +08:00
end
2020-05-09 13:31:21 +08:00
--刷新面板
2021-11-09 15:48:56 +08:00
function SoulPrintPopUp:RefreshShow(type)
2024-09-06 10:38:56 +08:00
self.btns:SetActive(type == Type.Up or type == Type.Down)
self.upBtn:SetActive(type == Type.Up)
self.downBtn:SetActive(type == Type.Down)
2020-05-09 13:31:21 +08:00
--基础信息
2021-11-09 15:48:56 +08:00
self.soulName.text = GetLanguageStrById(equipConfig[soulId].Name)
self.frame.sprite = self.spLoader:LoadSprite(GetQuantityImageByquality(equipConfig[soulId].Quality))
self.icon.sprite = self.spLoader:LoadSprite(GetResourcePath(itemConfig[soulId].ResourceID))
2024-09-06 10:38:56 +08:00
self.circleFrameBg.sprite = self.spLoader:LoadSprite(SoulPrintSpriteByQuantity[itemConfig[soulId].Quantity]
.circleBg2)
2021-11-09 15:48:56 +08:00
self.circleFrame.sprite = self.spLoader:LoadSprite(SoulPrintSpriteByQuantity[itemConfig[soulId].Quantity].circle)
2024-09-06 10:38:56 +08:00
self.powerNum.text = equipConfig[soulId].Score --战力
2021-11-09 15:48:56 +08:00
self.equipInfoText.text = GetLanguageStrById(itemConfig[soulId].ItemDescribe)
2024-09-06 10:38:56 +08:00
self.equipQuaText.text = GetStringByEquipQua(equipConfig[soulId].Quality,
GetQuaStringByEquipQua(equipConfig[soulId].Quality))
self.equipType.text = Language[11172] .. GetEquipPosStrByEquipPosNum(equipConfig[soulId].Position)
2024-01-19 20:01:17 +08:00
--self.topBar:GetComponent("Image").sprite = self.spLoader:LoadSprite("t_tongyong_di_"..equipConfig[soulId].Quality)
self.topBar:GetComponent("Image").sprite = self.spLoader:LoadSprite("t_tongyong_di_4")
2024-09-06 10:38:56 +08:00
self.effectbaijin:SetActive(equipConfig[soulId].Quality == 7)
Util.SetParticleSortLayer(self.effectbaijin, self.sortingOrder + 1)
2020-05-15 16:52:35 +08:00
2020-05-25 19:16:23 +08:00
if equipConfig[soulId] then --魂印效果
2020-05-15 16:52:35 +08:00
local txt = ""
2024-09-06 10:38:56 +08:00
local pass = equipConfig[soulId].PassiveSkill
if pass and tonumber(pass[1]) ~= nil and tonumber(pass[1]) ~= 0 then
2022-11-09 17:55:54 +08:00
self.effectText.text = GetLanguageStrById(passiveSkillConfig[pass[1]].Desc)
2020-05-25 19:16:23 +08:00
else
for index, value in ipairs(equipConfig[soulId].Property) do --propertyconfig
if index > 1 then
txt = txt .. ""
end
2024-09-06 10:38:56 +08:00
if propertyconfig[value[1]].Style == 1 then
txt = txt .. GetLanguageStrById(propertyconfig[value[1]].Info) .. "+" .. value[2]
elseif propertyconfig[value[1]].Style == 2 then
txt = txt .. GetLanguageStrById(propertyconfig[value[1]].Info) ..
"+" .. math.floor((value[2] / 100)) .. "%"
2020-05-25 19:16:23 +08:00
end
2020-05-15 16:52:35 +08:00
end
2024-09-06 10:38:56 +08:00
self.effectText.text = txt
2020-05-15 16:52:35 +08:00
end
2020-05-09 13:31:21 +08:00
end
--适用范围
2024-09-06 10:38:56 +08:00
local isOpenTrialScope = equipConfig[soulId].Range and equipConfig[soulId].Range[1] ~= 0 and
equipConfig[soulId].Range
[1] --是否开启适用
2020-05-09 13:31:21 +08:00
if isOpenTrialScope then
2024-08-29 21:36:51 +08:00
self.trialScopeText.text = Language[11175]
2024-09-06 10:38:56 +08:00
self.scroll_1:SetActive(#equipConfig[soulId].Range <= 3)
self.scroll_2:SetActive(#equipConfig[soulId].Range > 3)
2020-06-13 11:47:13 +08:00
--适用英雄<=3时 固定长度生成(预设) 反之使用优化滚动条
2024-09-06 10:38:56 +08:00
if #equipConfig[soulId].Range <= 3 then
for j = 0, self.scroll_1.transform.childCount - 1 do
2021-11-09 15:48:56 +08:00
self.scroll_1.transform:GetChild(j).gameObject:SetActive(false)
2020-05-25 19:16:23 +08:00
end
2024-09-06 10:38:56 +08:00
for i = 1, #equipConfig[soulId].Range do --遍历每个适用英雄
local item = proList[i]
2020-05-09 13:31:21 +08:00
if not item then
2024-09-06 10:38:56 +08:00
item = newObjToParent(self.trialScopePre, self.scroll_1)
item.name = "ProPre" .. i
proList[i] = item
2020-05-09 13:31:21 +08:00
end
2020-05-25 19:16:23 +08:00
proList[i].gameObject:SetActive(true)
2024-09-06 10:38:56 +08:00
local _heroId = equipConfig[soulId].Range[i]
local frame = Util.GetGameObject(item, "Head/Frame"):GetComponent("Image")
local icon = Util.GetGameObject(item, "Head/Icon"):GetComponent("Image")
local name = Util.GetGameObject(item, "Name"):GetComponent("Text")
local info = Util.GetGameObject(item, "Info"):GetComponent("Text")
frame.sprite = self.spLoader:LoadSprite(GetQuantityImageByquality(itemConfig[_heroId].Quantity))
icon.sprite = self.spLoader:LoadSprite(GetResourcePath(itemConfig[_heroId].ResourceID))
name.text = GetLanguageStrById(itemConfig[_heroId].Name)
info.text = x(i)
2020-05-09 13:31:21 +08:00
end
else
2024-09-06 10:38:56 +08:00
self.scrollView:SetData(equipConfig[soulId].Range, function(index, root)
self:SetScrollPre(root, equipConfig[soulId].Range[index], index)
2020-05-09 13:31:21 +08:00
end)
2021-11-09 15:48:56 +08:00
self.scrollView:SetIndex(1)
2020-05-09 13:31:21 +08:00
end
else
2021-11-09 15:48:56 +08:00
self.scroll_1:SetActive(false)
self.scroll_2:SetActive(false)
2024-08-29 21:36:51 +08:00
self.trialScopeText.text = Language[12252]
2020-05-09 13:31:21 +08:00
end
--获取途径
2024-09-06 10:38:56 +08:00
self.howGet:SetActive(type == Type.Access)
2021-11-09 15:48:56 +08:00
--获取途径
if self.jumpViewList and #self.jumpViewList > 0 then
2024-09-06 10:38:56 +08:00
for i = 1, #self.jumpViewList do
2021-11-09 15:48:56 +08:00
SubUIManager.Close(self.jumpViewList[i])
2020-06-30 18:59:44 +08:00
end
2021-11-09 15:48:56 +08:00
end
local curitemData = itemConfig[soulId]
if curitemData and curitemData.Jump then
2024-09-06 10:38:56 +08:00
if curitemData.Jump and #curitemData.Jump > 0 then
self.canGetScrollView:SetData(curitemData.Jump, function(index, item)
local tempView = SubUIManager.Open(SubUIConfig.JumpView, item.transform, curitemData.Jump[index], true)
table.insert(self.jumpViewList, tempView)
end, true, true)
2020-06-30 18:59:44 +08:00
end
end
2020-05-09 13:31:21 +08:00
end
--优化滚动条数据赋值
2024-09-06 10:38:56 +08:00
function SoulPrintPopUp:SetScrollPre(root, data, index)
local frame = Util.GetGameObject(root, "Head/Frame"):GetComponent("Image")
local icon = Util.GetGameObject(root, "Head/Icon"):GetComponent("Image")
local name = Util.GetGameObject(root, "Name"):GetComponent("Text")
local info = Util.GetGameObject(root, "Info"):GetComponent("Text")
frame.sprite = self.spLoader:LoadSprite(GetQuantityImageByquality(itemConfig[data].Quantity))
icon.sprite = self.spLoader:LoadSprite(GetResourcePath(itemConfig[data].ResourceID))
name.text = GetLanguageStrById(itemConfig[data].Name)
2020-06-13 11:47:13 +08:00
2024-09-06 10:38:56 +08:00
info.text = x(index)
2020-05-09 13:31:21 +08:00
end
2024-09-06 10:38:56 +08:00
return SoulPrintPopUp