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

328 lines
14 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)
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local equipConfig=ConfigManager.GetConfig(ConfigName.EquipConfig)
local passiveSkillConfig=ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
local heroConfig=ConfigManager.GetConfig(ConfigName.HeroConfig)
2020-05-25 19:16:23 +08:00
local propertyconfig=ConfigManager.GetConfig(ConfigName.PropertyConfig)
2020-05-09 13:31:21 +08:00
2020-05-09 13:31:21 +08:00
--面板类型
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()
2021-11-09 15:48:56 +08:00
self.spLoader = SpriteLoader.New()
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")
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")
2020-05-09 13:31:21 +08:00
--魂印效果
2021-11-09 15:48:56 +08:00
self.midBar = Util.GetGameObject(self.transform, "Panel/midBar")
self.effectText=Util.GetGameObject(self.midBar,"basePro/Info"):GetComponent("Text")
2020-05-09 13:31:21 +08:00
--适用范围(还没做具体内容)
2021-11-09 15:48: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自动布局
2021-11-09 15:48: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优化布局
2021-11-09 15:48: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)
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")
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 = {}
2020-05-09 13:31:21 +08:00
--操作按钮
2021-11-09 15:48: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
--穿戴
2021-11-09 15:48: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
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11524])
2020-05-09 13:31:21 +08:00
return
end
end
end
--如果装备位置满了 显示替换界面
if pos==0 then
UIManager.OpenPanel(UIName.SoulPrintPopUpV2,2,curHeroData,localData,function()
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
--如果是别人装备的
if localData.upHero~="" then
--当前点击魂印被装到的英雄数据
local curClickHeroData=HeroManager.GetSingleHeroData(localData.upHero)
2021-03-02 16:53:12 +08:00
local str=string.format(Language[11525],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
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)
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11526])
2021-11-09 15:48:56 +08:00
self:RefreshShow()
--
if callback then
callback()
end
2020-05-09 13:31:21 +08:00
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)
--卸下
2021-11-09 15:48:56 +08:00
Util.AddClick(self.downBtn,function()
2020-05-09 13:31:21 +08:00
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()
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()
self.scrollView=nil
2020-05-09 13:31:21 +08:00
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
--读取魂印适用英雄效果
local x= function(index)
local args={}
2021-01-26 17:08:39 +08:00
local tempArgs = string.split(GetLanguageStrById(equipConfig[soulId].Parameter),'|')
local t = string.split(tempArgs[index],'#')
for i, v in ipairs(t) do
args[i]= v
2020-06-13 11:47:13 +08:00
end
2021-01-26 17:08:39 +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)
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))
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)
2024-01-17 11:47:52 +08:00
self.equipQuaText.text= GetQuaStringByEquipQua(equipConfig[soulId].Quality)
2021-11-09 15:48:56 +08:00
self.equipType.text= Language[11089]..GetEquipPosStrByEquipPosNum(equipConfig[soulId].Position)
2023-11-16 11:45:30 +08:00
self.topBar:GetComponent("Image").sprite = self.spLoader:LoadSprite("Bg_hz_beibao_pinjise_00"..equipConfig[soulId].Quality)
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 = ""
2022-11-09 17:55:54 +08:00
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)
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
if propertyconfig[value[1]].Style==1 then
2021-01-26 17:08:39 +08:00
txt=txt..GetLanguageStrById(propertyconfig[value[1]].Info).."+"..value[2]
2020-05-25 19:16:23 +08:00
elseif propertyconfig[value[1]].Style==2 then
2021-01-26 17:08:39 +08:00
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
2021-11-09 15:48: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
--适用范围
2020-06-03 19:09:01 +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
2023-12-07 01:11:27 +08:00
self.trialScopeText.text = "以下英雄可装备:"
2021-11-09 15:48: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时 固定长度生成(预设) 反之使用优化滚动条
if #equipConfig[soulId].Range<=3 then
2021-11-09 15:48:56 +08:00
for j = 0, self.scroll_1.transform.childCount-1 do
self.scroll_1.transform:GetChild(j).gameObject:SetActive(false)
2020-05-25 19:16:23 +08:00
end
2020-06-13 11:47:13 +08:00
for i = 1, #equipConfig[soulId].Range do--遍历每个适用英雄
2020-05-09 13:31:21 +08:00
local item= proList[i]
if not item then
2021-11-09 15:48:56 +08:00
item= newObjToParent(self.trialScopePre,self.scroll_1)
2020-05-09 13:31:21 +08:00
item.name="ProPre"..i
proList[i]=item
end
2020-05-25 19:16:23 +08:00
proList[i].gameObject:SetActive(true)
2020-05-09 13:31:21 +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")
2021-11-09 15:48:56 +08:00
frame.sprite=self.spLoader:LoadSprite(GetQuantityImageByquality(itemConfig[_heroId].Quantity))
icon.sprite=self.spLoader:LoadSprite(GetResourcePath(itemConfig[_heroId].ResourceID))
2021-01-26 17:08:39 +08:00
name.text=GetLanguageStrById(itemConfig[_heroId].Name)
2020-06-13 11:47:13 +08:00
info.text=x(i)
2020-05-09 13:31:21 +08:00
end
else
2021-11-09 15:48: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)
2023-12-07 01:11:27 +08:00
self.trialScopeText.text = "以下英雄可装备:所有英雄"
2020-05-09 13:31:21 +08:00
end
2024-01-11 10:37:43 +08:00
LayoutRebuilder.ForceRebuildLayoutImmediate(self.midBar.transform)
2020-05-09 13:31:21 +08:00
--获取途径
2021-11-09 15:48:56 +08:00
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])
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
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
2024-01-11 10:37:43 +08:00
LayoutRebuilder.ForceRebuildLayoutImmediate(self.gameObject.transform)
2020-05-09 13:31:21 +08:00
end
--优化滚动条数据赋值
2021-11-09 15:48:56 +08:00
function SoulPrintPopUp:SetScrollPre(root,data,index)
2020-05-09 13:31:21 +08:00
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")
2021-11-09 15:48:56 +08:00
frame.sprite=self.spLoader:LoadSprite(GetQuantityImageByquality(itemConfig[data].Quantity))
icon.sprite=self.spLoader:LoadSprite(GetResourcePath(itemConfig[data].ResourceID))
2021-01-26 17:08:39 +08:00
name.text=GetLanguageStrById(itemConfig[data].Name)
2020-06-13 11:47:13 +08:00
info.text=x(index)
2020-05-09 13:31:21 +08:00
end
2020-06-23 18:36:24 +08:00
return SoulPrintPopUp