338 lines
15 KiB
Lua
338 lines
15 KiB
Lua
----- 魂印弹窗 -----
|
||
require("Base/BasePanel")
|
||
SoulPrintPopUp = Inherit(BasePanel)
|
||
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)
|
||
|
||
|
||
--面板类型
|
||
local Type = {
|
||
Up = 1, --穿戴
|
||
Down = 2, --卸下
|
||
Access = 3, --有获取途径 传nil就不显示了
|
||
}
|
||
--打开面板类型
|
||
local curType = 0
|
||
|
||
local heroId --当前英雄id
|
||
local soulId --魂印id
|
||
local pos --位置
|
||
local callback --回调
|
||
local localData --本地存储的魂印数据 包含soulId 该数据只在魂印装备时(Type.Up)才有用
|
||
|
||
--适用范围英雄容器
|
||
local proList = {}
|
||
function SoulPrintPopUp:InitComponent()
|
||
self.spLoader = SpriteLoader.New()
|
||
self.panel = Util.GetGameObject(self.gameObject, "Panel")
|
||
self.maskBtn = Util.GetGameObject(self.gameObject, "mask")
|
||
--基础信息
|
||
--装备详情--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")
|
||
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")
|
||
self.effectbaijin = Util.GetGameObject(self.topBar, "fx_zhuangbeijiemian")
|
||
|
||
--魂印效果
|
||
self.midBar = Util.GetGameObject(self.transform, "Panel/midBar")
|
||
self.effectText = Util.GetGameObject(self.midBar, "basePro/Info"):GetComponent("Text")
|
||
|
||
--适用范围(还没做具体内容)
|
||
self.trialScope = Util.GetGameObject(self.midBar, "TrialScope")
|
||
self.trialScopeText = Util.GetGameObject(self.trialScope, "Text"):GetComponent("Text")
|
||
--数据小于4自动布局
|
||
self.scroll_1 = Util.GetGameObject(self.trialScope, "Scroll_1") --静态布局根节点
|
||
self.trialScopePre = Util.GetGameObject(self.trialScope, "Scroll_1/TrialScopePre") --适用范围预设
|
||
--数据大于4优化布局
|
||
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)
|
||
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
|
||
|
||
self.btmBar = Util.GetGameObject(self.transform, "Panel/btmBar")
|
||
--获取途径
|
||
self.howGet = Util.GetGameObject(self.btmBar, "howGet")
|
||
self.canGetPre = Util.GetGameObject(self.howGet, "scroll/canGetPre")
|
||
self.canGetGrid = Util.GetGameObject(self.howGet, "scroll")
|
||
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))
|
||
self.canGetScrollView.moveTween.MomentumAmount = 1
|
||
self.canGetScrollView.moveTween.Strength = 2
|
||
self.canGetScrollView.elastic = false
|
||
self.jumpViewList = {}
|
||
--操作按钮
|
||
self.btns = Util.GetGameObject(self.btmBar, "btnGrid")
|
||
self.upBtn = Util.GetGameObject(self.btns, "UpBtn")
|
||
self.downBtn = Util.GetGameObject(self.btns, "DownBtn")
|
||
end
|
||
|
||
function SoulPrintPopUp:BindEvent()
|
||
--关闭面板
|
||
Util.AddClick(self.maskBtn, function()
|
||
self:ClosePanel()
|
||
end)
|
||
--穿戴
|
||
Util.AddClick(self.upBtn, function()
|
||
--检测是否已穿过该类型魂印
|
||
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
|
||
PopupTipPanel.ShowTip(Language[11169])
|
||
return
|
||
end
|
||
end
|
||
end
|
||
|
||
--如果装备位置满了 显示替换界面
|
||
if pos == 0 then
|
||
UIManager.OpenPanel(UIName.SoulPrintPopUpV2, 2, curHeroData, localData, function()
|
||
self:ClosePanel()
|
||
self:RefreshShow()
|
||
if callback then
|
||
callback()
|
||
end
|
||
end)
|
||
return
|
||
end
|
||
|
||
--如果是别人装备的
|
||
if localData.upHero ~= "" then
|
||
--当前点击魂印被装到的英雄数据
|
||
local curClickHeroData = HeroManager.GetSingleHeroData(localData.upHero)
|
||
local str = string.format(Language[11180], itemConfig[curClickHeroData.id].Name,
|
||
equipConfig[localData.id].Name, itemConfig[curHeroData.id].Name)
|
||
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
|
||
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)
|
||
end)
|
||
end)
|
||
return
|
||
end
|
||
-- else--选择的魂印没有被其他猎妖师装备 可直接装备
|
||
--穿戴
|
||
local wearInfo = { heroId = tostring(heroId), equipId = soulId, position = pos }
|
||
NetManager.SoulEquipWearRequest(wearInfo, nil, function()
|
||
HeroManager.AddSoulPrintUpHeroDynamicId(heroId, soulId, pos)
|
||
if callback then
|
||
callback()
|
||
end
|
||
end)
|
||
self:ClosePanel()
|
||
-- end
|
||
end)
|
||
--卸下
|
||
Util.AddClick(self.downBtn, function()
|
||
NetManager.SoulEquipUnLoadWearRequest(tostring(heroId), soulId, pos, function()
|
||
HeroManager.DelSoulPrintUpHeroDynamicId(heroId, soulId)
|
||
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(...)
|
||
local args = { ... }
|
||
curType = args[1]
|
||
heroId = args[2]
|
||
soulId = args[3]
|
||
pos = args[4]
|
||
callback = args[5]
|
||
localData = args[6]
|
||
end
|
||
|
||
function SoulPrintPopUp:OnShow()
|
||
self:RefreshShow(curType)
|
||
end
|
||
|
||
function SoulPrintPopUp:OnClose()
|
||
for i = 1, #self.jumpViewList do
|
||
destroy(self.jumpViewList[i].gameObject)
|
||
end
|
||
end
|
||
|
||
function SoulPrintPopUp:OnDestroy()
|
||
self.spLoader:Destroy()
|
||
self.scrollView = nil
|
||
proList = {}
|
||
self.jumpViewList = {}
|
||
end
|
||
|
||
--读取魂印适用英雄效果
|
||
local x = function(index)
|
||
local args = {}
|
||
local tempArgs = string.split(GetLanguageStrById(equipConfig[soulId].Parameter), '|')
|
||
local t = string.split(tempArgs[index], '#')
|
||
for i, v in ipairs(t) do
|
||
args[i] = v
|
||
end
|
||
return string.format(GetLanguageStrById(equipConfig[soulId].Describe), unpack(args))
|
||
end
|
||
--刷新面板
|
||
function SoulPrintPopUp:RefreshShow(type)
|
||
self.btns:SetActive(type == Type.Up or type == Type.Down)
|
||
self.upBtn:SetActive(type == Type.Up)
|
||
self.downBtn:SetActive(type == Type.Down)
|
||
|
||
--基础信息
|
||
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))
|
||
self.circleFrameBg.sprite = self.spLoader:LoadSprite(SoulPrintSpriteByQuantity[itemConfig[soulId].Quantity]
|
||
.circleBg2)
|
||
self.circleFrame.sprite = self.spLoader:LoadSprite(SoulPrintSpriteByQuantity[itemConfig[soulId].Quantity].circle)
|
||
self.powerNum.text = equipConfig[soulId].Score --战力
|
||
self.equipInfoText.text = GetLanguageStrById(itemConfig[soulId].ItemDescribe)
|
||
self.equipQuaText.text = GetStringByEquipQua(equipConfig[soulId].Quality,
|
||
GetQuaStringByEquipQua(equipConfig[soulId].Quality))
|
||
self.equipType.text = Language[11172] .. GetEquipPosStrByEquipPosNum(equipConfig[soulId].Position)
|
||
--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")
|
||
self.effectbaijin:SetActive(equipConfig[soulId].Quality == 7)
|
||
Util.SetParticleSortLayer(self.effectbaijin, self.sortingOrder + 1)
|
||
|
||
if equipConfig[soulId] then --魂印效果
|
||
local txt = ""
|
||
local pass = equipConfig[soulId].PassiveSkill
|
||
if pass and tonumber(pass[1]) ~= nil and tonumber(pass[1]) ~= 0 then
|
||
self.effectText.text = GetLanguageStrById(passiveSkillConfig[pass[1]].Desc)
|
||
else
|
||
for index, value in ipairs(equipConfig[soulId].Property) do --propertyconfig
|
||
if index > 1 then
|
||
txt = txt .. ","
|
||
end
|
||
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)) .. "%"
|
||
end
|
||
end
|
||
self.effectText.text = txt
|
||
end
|
||
end
|
||
--适用范围
|
||
local isOpenTrialScope = equipConfig[soulId].Range and equipConfig[soulId].Range[1] ~= 0 and
|
||
equipConfig[soulId].Range
|
||
[1] --是否开启适用
|
||
if isOpenTrialScope then
|
||
self.trialScopeText.text = Language[11175]
|
||
self.scroll_1:SetActive(#equipConfig[soulId].Range <= 3)
|
||
self.scroll_2:SetActive(#equipConfig[soulId].Range > 3)
|
||
--适用英雄<=3时 固定长度生成(预设) 反之使用优化滚动条
|
||
if #equipConfig[soulId].Range <= 3 then
|
||
for j = 0, self.scroll_1.transform.childCount - 1 do
|
||
self.scroll_1.transform:GetChild(j).gameObject:SetActive(false)
|
||
end
|
||
for i = 1, #equipConfig[soulId].Range do --遍历每个适用英雄
|
||
local item = proList[i]
|
||
if not item then
|
||
item = newObjToParent(self.trialScopePre, self.scroll_1)
|
||
item.name = "ProPre" .. i
|
||
proList[i] = item
|
||
end
|
||
proList[i].gameObject:SetActive(true)
|
||
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)
|
||
end
|
||
else
|
||
self.scrollView:SetData(equipConfig[soulId].Range, function(index, root)
|
||
self:SetScrollPre(root, equipConfig[soulId].Range[index], index)
|
||
end)
|
||
self.scrollView:SetIndex(1)
|
||
end
|
||
else
|
||
self.scroll_1:SetActive(false)
|
||
self.scroll_2:SetActive(false)
|
||
self.trialScopeText.text = Language[12252]
|
||
end
|
||
|
||
--获取途径
|
||
self.howGet:SetActive(type == Type.Access)
|
||
--获取途径
|
||
if self.jumpViewList and #self.jumpViewList > 0 then
|
||
for i = 1, #self.jumpViewList do
|
||
SubUIManager.Close(self.jumpViewList[i])
|
||
end
|
||
end
|
||
local curitemData = itemConfig[soulId]
|
||
if curitemData and curitemData.Jump then
|
||
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)
|
||
end
|
||
end
|
||
end
|
||
|
||
--优化滚动条数据赋值
|
||
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)
|
||
|
||
info.text = x(index)
|
||
end
|
||
|
||
return SoulPrintPopUp
|