2021-12-14 17:25:44 +08:00
|
|
|
|
----- 归元弹窗 -----
|
|
|
|
|
local this = {}
|
|
|
|
|
--传入父脚本模块
|
|
|
|
|
local parent
|
|
|
|
|
--层级
|
|
|
|
|
local sortingOrder = 0
|
|
|
|
|
--传入不定参
|
|
|
|
|
local _args = {}
|
|
|
|
|
--传入选择英雄计算返回奖励数据列表
|
|
|
|
|
local dropList = {}
|
|
|
|
|
--item容器
|
|
|
|
|
local itemList = {}
|
|
|
|
|
--传入选择英雄
|
|
|
|
|
local selectHeroData
|
|
|
|
|
local heroConfig=ConfigManager.GetConfig(ConfigName.HeroConfig)
|
|
|
|
|
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
|
2021-12-15 14:41:04 +08:00
|
|
|
|
local SpecialConfig = ConfigManager.GetConfigData(ConfigName.SpecialConfig,143)
|
2021-12-14 17:25:44 +08:00
|
|
|
|
local itemNum = nil
|
|
|
|
|
local heroUseCount = nil
|
|
|
|
|
local heroUseItemId = nil
|
2021-12-14 17:57:21 +08:00
|
|
|
|
local returnHeroSame = 0
|
2021-12-14 17:25:44 +08:00
|
|
|
|
function this:InitComponent(gameObject)
|
|
|
|
|
this.spLoader = SpriteLoader.New()
|
|
|
|
|
this.titleText = Util.GetGameObject(gameObject, "TitleText"):GetComponent("Text")
|
|
|
|
|
this.bodyText = Util.GetGameObject(gameObject, "BodyText"):GetComponent("Text")
|
|
|
|
|
this.cancelBtn = Util.GetGameObject(gameObject, "CancelBtn")
|
|
|
|
|
this.confirmBtn = Util.GetGameObject(gameObject, "ConfirmBtn")
|
2021-12-15 14:41:04 +08:00
|
|
|
|
this.itemImage = Util.GetGameObject(gameObject, "ConfirmBtn/itemImage"):GetComponent("Image")
|
|
|
|
|
this.itemImageText = Util.GetGameObject(gameObject, "ConfirmBtn/itemText"):GetComponent("Text")
|
2021-12-14 17:25:44 +08:00
|
|
|
|
--滚动条根节点
|
|
|
|
|
this.root = Util.GetGameObject(gameObject, "Root/Viewport/Content")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:BindEvent()
|
|
|
|
|
Util.AddClick(this.cancelBtn,function()
|
|
|
|
|
parent:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(this.confirmBtn,function()
|
2021-12-15 14:41:04 +08:00
|
|
|
|
if itemNum < heroUseCount then
|
|
|
|
|
PopupTipPanel.ShowTip(string.format("%s不足",itemConfig[heroUseItemId].Name) )
|
|
|
|
|
return
|
|
|
|
|
end
|
2021-12-14 17:57:21 +08:00
|
|
|
|
if returnHeroSame + LengthOfTable(HeroManager.GetAllHeroList()) - 1 > 999 then
|
2023-12-07 01:11:27 +08:00
|
|
|
|
PopupTipPanel.ShowTip("英雄数量即将超出上限,请整理后再进行回退操作!")
|
2021-12-14 17:57:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
2021-12-14 17:25:44 +08:00
|
|
|
|
local data
|
|
|
|
|
for k,v in pairs(selectHeroData) do
|
|
|
|
|
data=v.dynamicId
|
|
|
|
|
break
|
2021-12-14 17:57:21 +08:00
|
|
|
|
end
|
2021-12-14 17:25:44 +08:00
|
|
|
|
NetManager.HeroRetureEvent(data, function(msg)
|
|
|
|
|
local oldPowerNum = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
|
|
|
|
HeroManager.ResetHeroStar(data)
|
2021-12-16 10:09:48 +08:00
|
|
|
|
HeroManager.SetTalismanLv(data, 1)
|
|
|
|
|
HeroManager.SetSoulPrintNil(data)
|
2022-04-22 18:23:01 +08:00
|
|
|
|
HeroManager.SetGodPrintNil(data)
|
2021-12-14 17:25:44 +08:00
|
|
|
|
PopupTipPanel.ShowTip("回退成功")
|
2021-12-16 10:09:48 +08:00
|
|
|
|
HeroPropManager.SetDirtyByType(data, Hero_Prop_Type.Base)
|
|
|
|
|
HeroPropManager.SetDirtyByType(data, Hero_Prop_Type.Talisman)
|
|
|
|
|
HeroPropManager.SetDirtyByType(data, Hero_Prop_Type.SoulPrint)
|
2022-04-22 18:23:01 +08:00
|
|
|
|
HeroPropManager.SetDirtyByType(data, Hero_Prop_Type.GodPrint)
|
2021-12-16 10:09:48 +08:00
|
|
|
|
HeroPropManager.SetDirtyByType(data, Hero_Prop_Type.PassiveSkill)
|
2021-12-14 17:25:44 +08:00
|
|
|
|
parent:ClosePanel()
|
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function ()
|
|
|
|
|
-- ResolvePanel.SwitchView(2,true,true)
|
|
|
|
|
local mainFormationHeroList = FormationManager.GetAllMainFormationHeroId()
|
|
|
|
|
if mainFormationHeroList[data] then
|
|
|
|
|
local newPowerNum = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
|
|
|
|
if oldPowerNum ~= newPowerNum then
|
|
|
|
|
UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = oldPowerNum,newValue = newPowerNum})
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Role.UpdateRoleInfoPanel)
|
|
|
|
|
end,0,nil,nil,1)
|
2021-12-16 10:09:48 +08:00
|
|
|
|
|
2021-12-14 17:25:44 +08:00
|
|
|
|
end,1)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:AddListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:RemoveListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnShow(_parent,...)
|
|
|
|
|
parent=_parent
|
|
|
|
|
sortingOrder =_parent.sortingOrder
|
|
|
|
|
local args = {...}
|
|
|
|
|
dropList = args[1]
|
|
|
|
|
selectHeroData=args[2]
|
|
|
|
|
local curhero
|
|
|
|
|
for k,v in pairs(selectHeroData) do
|
|
|
|
|
curhero = v
|
|
|
|
|
end
|
|
|
|
|
this.root.transform:GetComponent("RectTransform"):DOAnchorPosX(0, 0)
|
|
|
|
|
|
2023-12-07 01:11:27 +08:00
|
|
|
|
this.bodyText.text = string.format("回退英雄会返还英雄进阶时消耗的本体,其他英雄以将魂形式返还,此操作不可逆,是否确认回退?")
|
2021-12-14 17:25:44 +08:00
|
|
|
|
|
|
|
|
|
local _data={}
|
|
|
|
|
for i=1,#dropList do
|
|
|
|
|
_data[i] = {dropList[i].id,dropList[i].num,nil,dropList[i].star}
|
2021-12-14 17:57:21 +08:00
|
|
|
|
if dropList[i].id == curhero.dynamicId then
|
|
|
|
|
returnHeroSame = dropList[i].num
|
|
|
|
|
end
|
2021-12-14 17:25:44 +08:00
|
|
|
|
end
|
|
|
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
|
|
|
table.sort(_data,function(a,b)
|
|
|
|
|
if itemConfig[a[1]].ItemType == itemConfig[b[1]].ItemType then
|
|
|
|
|
return itemConfig[a[1]].Quantity > itemConfig[b[1]].Quantity
|
|
|
|
|
else
|
|
|
|
|
return itemConfig[a[1]].ItemType < itemConfig[b[1]].ItemType
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
ResetItemView(this.root,this.root.transform,itemList,8,1,sortingOrder,false,_data)
|
2021-12-15 14:41:04 +08:00
|
|
|
|
local strs = string.split(SpecialConfig.Value,"#")
|
|
|
|
|
heroUseItemId = tonumber(strs[1])
|
|
|
|
|
heroUseCount = tonumber(strs[2])
|
|
|
|
|
itemNum = BagManager.GetItemCountById(heroUseItemId)
|
|
|
|
|
-- LogBlue("heroUseItemId "..heroUseItemId.." itemNum "..itemNum.." heroUseCount "..heroUseCount)
|
|
|
|
|
if itemNum >= heroUseCount then
|
|
|
|
|
this.itemImageText.text = string.format("<color=#FFF8EC>×%s</color>", heroUseCount)
|
|
|
|
|
else
|
|
|
|
|
this.itemImageText.text = string.format("<color=#C66366FF>×%s</color>", heroUseCount)
|
|
|
|
|
end
|
|
|
|
|
this.itemImage.sprite = this.spLoader:LoadSprite(GetResourcePath(itemConfig[heroUseItemId].ResourceID))
|
2021-12-14 17:25:44 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnClose()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnDestroy()
|
|
|
|
|
this.spLoader:Destroy()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return this
|