miduo_client/Assets/ManagedResources/~Lua/Modules/SoulPrint/SoulPrintPopUpV2.lua

217 lines
9.5 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")
SoulPrintPopUpV2 = Inherit(BasePanel)
local this=SoulPrintPopUpV2
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local equipConfig=ConfigManager.GetConfig(ConfigName.EquipConfig)
2020-05-25 19:16:23 +08:00
local passiveSkillConfig=ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
local propertyconfig=ConfigManager.GetConfig(ConfigName.PropertyConfig)
2020-05-09 13:31:21 +08:00
--面板类型
local Type={
Detail=1,
Replace=2
}
--当前面板类型
local curType=0
local curHeroData --当前英雄数据
local equipData --点击的魂印数据
local callBack
function SoulPrintPopUpV2:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
this.panel=Util.GetGameObject(this.gameObject,"Panel")
this.backBtn=Util.GetGameObject(this.panel,"BackBtn")
this.title=Util.GetGameObject(this.panel,"Title"):GetComponent("Text")
this.empty=Util.GetGameObject(this.panel,"Empty")
this.scrollRoot=Util.GetGameObject(this.gameObject,"ScrollRoot")
this.pre=Util.GetGameObject(this.scrollRoot,"Pre")
this.scrollView=SubUIManager.Open(SubUIConfig.ScrollCycleView,this.scrollRoot.transform,this.pre, nil,--
Vector2.New(this.scrollRoot.transform.rect.width,this.scrollRoot.transform.rect.height),1,1,Vector2.New(0,10))
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)
this.scrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
this.scrollView.moveTween.MomentumAmount = 1
this.scrollView.moveTween.Strength = 2
this.tihuan=Util.GetGameObject(this.panel,"tihuan")
end
function SoulPrintPopUpV2:BindEvent()
--返回按钮
Util.AddClick(this.backBtn,function()
self:ClosePanel()
end)
Util.AddClick(this.tihuan,function()
local wearInfo = {heroId = "10042304010015867490050000",equipId = 5000048,position = 1}
local unloadInfo = {heroId = "10042304010015867490050000",equipId = 5000044,position = 1}
NetManager.SoulEquipWearRequest(wearInfo,unloadInfo,function ()
HeroManager.DelSoulPrintUpHeroDynamicId("10042304010015867490050000",5000044)
HeroManager.AddSoulPrintUpHeroDynamicId("10042304010015867490050000",5000048,1)
self:ClosePanel()
end)
end)
end
function SoulPrintPopUpV2:AddListener()
end
function SoulPrintPopUpV2:RemoveListener()
end
--curType 1为详情 2为替换
function SoulPrintPopUpV2:OnOpen(...)
local args={...}
curType=args[1]
curHeroData=args[2]
equipData=args[3]
callBack=args[4]
end
function SoulPrintPopUpV2:OnShow()
this.RefreshShow(curType)
end
function SoulPrintPopUpV2:OnClose()
end
function SoulPrintPopUpV2:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
this.scrollView=nil
end
--刷新面板
function this.RefreshShow(type)
if type==Type.Detail then
2021-03-02 16:53:12 +08:00
this.title.text=Language[11906]
2020-05-09 13:31:21 +08:00
this.empty.gameObject:SetActive(#curHeroData.soulPrintList==0)
elseif type==Type.Replace then
2021-03-02 16:53:12 +08:00
this.title.text=Language[11907]
2020-05-09 13:31:21 +08:00
this.empty.gameObject:SetActive(false)
end
--数据是无序的 需要按位置排序下
table.sort(curHeroData.soulPrintList,function(a,b)
return tonumber(a.position)<tonumber(b.position)
end)
this.scrollView:SetData(curHeroData.soulPrintList,function(index,root)
this.SetScrollPre(root,curHeroData.soulPrintList[index],type,index)
end)
this.scrollView:SetIndex(1)
end
--优化滚动条数据赋值
function this.SetScrollPre(root,data,type,index)
local frame=Util.GetGameObject(root,"Frame"):GetComponent("Image")
2020-06-23 18:36:24 +08:00
local icon=Util.GetGameObject(root,"circleFrameBg/Icon"):GetComponent("Image")
2020-05-09 13:31:21 +08:00
local name=Util.GetGameObject(root,"Name"):GetComponent("Text")
local info=Util.GetGameObject(root,"Info"):GetComponent("Text")
local Info2=Util.GetGameObject(root,"Info2"):GetComponent("Text")
local goBtn=Util.GetGameObject(root,"GoBtn")
Util.GetGameObject(root,"Info"):SetActive(type==Type.Replace)
Util.GetGameObject(root,"Info2"):SetActive(type==Type.Detail)
2021-04-21 13:12:04 +08:00
frame.sprite=this.spLoader:LoadSprite(GetQuantityImageByquality(itemConfig[data.equipId].Quantity))
icon.sprite=this.spLoader:LoadSprite(GetResourcePath(itemConfig[data.equipId].ResourceID))
Util.GetGameObject(root,"circleFrameBg"):GetComponent("Image").sprite=this.spLoader:LoadSprite(SoulPrintSpriteByQuantity[itemConfig[data.equipId].Quantity].circleBg2)
Util.GetGameObject(root,"circleFrameBg/circleFrame"):GetComponent("Image").sprite=this.spLoader:LoadSprite(SoulPrintSpriteByQuantity[itemConfig[data.equipId].Quantity].circle)
2021-01-26 17:08:39 +08:00
name.text=GetLanguageStrById(itemConfig[data.equipId].Name)
2020-05-09 13:31:21 +08:00
local infoStr = ""
2020-05-25 19:16:23 +08:00
if equipConfig[data.equipId] then
2024-01-11 16:43:13 +08:00
if equipConfig[data.equipId].PassiveSkill and #equipConfig[data.equipId].PassiveSkill>0 and tonumber(equipConfig[data.equipId].PassiveSkill[1])~=nil then
--LogError("data.equipId====="..data.equipId)
2021-01-26 17:08:39 +08:00
infoStr=GetLanguageStrById(passiveSkillConfig[equipConfig[data.equipId].PassiveSkill[1]].Desc)
2020-05-25 19:16:23 +08:00
else
for index, value in ipairs(equipConfig[data.equipId].Property) do --propertyconfig
if index > 1 then
infoStr = infoStr .. ""
end
if propertyconfig[value[1]].Style==1 then
2021-01-26 17:08:39 +08:00
infoStr=infoStr..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
infoStr=infoStr..GetLanguageStrById(propertyconfig[value[1]].Info).."+"..math.floor((value[2]/100)).."%"
2020-05-25 19:16:23 +08:00
end
2020-05-09 13:31:21 +08:00
end
end
2020-05-25 19:16:23 +08:00
-- for index, pid in ipairs(equipConfig[data.equipId].PassiveSkill) do
-- if index > 1 then
-- infoStr = infoStr .. ""
-- end
2021-01-26 17:08:39 +08:00
-- infoStr = infoStr .. GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.PassiveSkillConfig, pid).Desc)
2020-05-25 19:16:23 +08:00
-- end
2020-05-09 13:31:21 +08:00
end
2020-05-25 19:16:23 +08:00
-- if infoStr == "" then
-- if equipConfig[data.equipId].Property and #equipConfig[data.equipId].Property > 0 then
-- for i = 1, #equipConfig[data.equipId].Property do
-- local curPropertyConfig = ConfigManager.GetConfigData(ConfigName.PropertyConfig,equipConfig[data.equipId].Property[1][1])
-- infoStr =infoStr .. curPropertyConfig.Info.." +"..equipConfig[data.equipId].Property[1][2]
-- end
-- end
-- end
2020-05-09 13:31:21 +08:00
info.text = infoStr
Info2.text = infoStr
goBtn:SetActive(type==Type.Replace)
--替换操作
Util.AddOnceClick(goBtn,function()
--检测是否已穿过该类型魂印
if curHeroData and curHeroData.soulPrintList and #curHeroData.soulPrintList > 0 then
for i = 1, #curHeroData.soulPrintList do
if curHeroData.soulPrintList[i].equipId == equipData.id 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
2020-06-30 18:59:44 +08:00
2020-05-09 13:31:21 +08:00
local wearInfo = {heroId =curHeroData.dynamicId,equipId = equipData.id,position = index} --点击魂印
local unloadInfo = nil
--是其他人装备的魂印
if equipData.upHero~="" then
local curClickHeroData= HeroManager.GetSingleHeroData(equipData.upHero)
local pos = 0
for i = 1, #curClickHeroData.soulPrintList do
2020-06-30 18:59:44 +08:00
if curClickHeroData.soulPrintList[i].equipId == equipData.id then
pos = curClickHeroData.soulPrintList[i].position
end
2020-05-09 13:31:21 +08:00
end
unloadInfo={heroId =equipData.upHero,equipId = equipData.id,position = pos} --被替换的目标魂印
local curClickHeroData=HeroManager.GetSingleHeroData(equipData.upHero)
2021-03-02 16:53:12 +08:00
local str=string.format(Language[11525],GetLanguageStrById(itemConfig[curClickHeroData.id].Name),GetLanguageStrById(equipConfig[equipData.id].Name),GetLanguageStrById(itemConfig[curHeroData.id].Name))
2020-05-09 13:31:21 +08:00
MsgPanel.ShowTwo(str, nil, function()
NetManager.SoulEquipWearRequest(wearInfo,unloadInfo,function ()
HeroManager.DelSoulPrintUpHeroDynamicId(curHeroData.dynamicId,data.equipId)--卸下自身魂印
if unloadInfo then
HeroManager.DelSoulPrintUpHeroDynamicId(unloadInfo.heroId,unloadInfo.equipId)--卸下别人魂印
end
HeroManager.AddSoulPrintUpHeroDynamicId(curHeroData.dynamicId,equipData.id,index)--装上自身魂印
if callBack then
callBack()
end
this:ClosePanel()
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11908])
2020-05-09 13:31:21 +08:00
end)
end)
return
end
--不是其他人装备的魂印
NetManager.SoulEquipWearRequest(wearInfo,unloadInfo,function ()
HeroManager.DelSoulPrintUpHeroDynamicId(curHeroData.dynamicId,data.equipId)--卸下自身魂印
if unloadInfo then
HeroManager.DelSoulPrintUpHeroDynamicId(unloadInfo.heroId,unloadInfo.equipId)--卸下别人魂印
end
HeroManager.AddSoulPrintUpHeroDynamicId(curHeroData.dynamicId,equipData.id,index)--装上自身魂印
if callBack then
callBack()
end
this:ClosePanel()
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11908])
2020-05-09 13:31:21 +08:00
end)
end)
end
2020-06-23 18:36:24 +08:00
return SoulPrintPopUpV2