miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/View/GeneralPopup_ResolveRecall.lua

149 lines
5.5 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
----- 归元弹窗 -----
2020-05-09 13:31:21 +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)
local itemNum = nil
local heroUseCount = nil
local heroUseItemId = nil
2020-05-09 13:31:21 +08:00
function this:InitComponent(gameObject)
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
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")
this.itemImage = Util.GetGameObject(gameObject, "ConfirmBtn/itemImage"):GetComponent("Image")
this.itemImageText = Util.GetGameObject(gameObject, "ConfirmBtn/itemText"):GetComponent("Text")
2020-05-09 13:31:21 +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()
local data
for k,v in pairs(selectHeroData) do
data=v.dynamicId
break
end
if itemNum < heroUseCount then
PopupTipPanel.ShowTip(string.format( Language[10298],ConfigManager.GetConfigData(ConfigName.ItemConfig,heroUseItemId).Name))
return
end
2020-05-09 13:31:21 +08:00
NetManager.HeroRetureEvent(data, function(msg)
local oldPowerNum = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
HeroManager.ResetHero(data)
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11608])
2020-05-09 13:31:21 +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)
2020-07-16 10:49:01 +08:00
end,0,nil,nil,1)
HeroPropManager.SetDirtyByType(data, Hero_Prop_Type.Base)
HeroPropManager.SetDirtyByType(data, Hero_Prop_Type.PassiveSkill)
2020-05-09 13:31:21 +08:00
end)
end)
end
function this:AddListener()
end
function this:RemoveListener()
end
2020-05-25 19:16:23 +08:00
function this:OnShow(_parent,...)
parent=_parent
sortingOrder =_parent.sortingOrder
2020-05-09 13:31:21 +08:00
local args = {...}
2020-05-25 19:16:23 +08:00
dropList = args[1]
selectHeroData=args[2]
2021-11-05 17:13:49 +08:00
local curhero
for k,v in pairs(selectHeroData) do
curhero = v
end
2020-05-09 13:31:21 +08:00
this.root.transform:GetComponent("RectTransform"):DOAnchorPosX(0, 0)
2021-03-02 16:53:12 +08:00
this.titleText.text=Language[11609]
2020-05-09 13:31:21 +08:00
--返还比
local num=tonumber(ConfigManager.GetConfigData(ConfigName.SpecialConfig,34).Value)/100
2021-10-26 17:55:49 +08:00
this.bodyText.text = string.format("归元神将会返还所有的升级材料神将重置为1级\n 此操作不可逆,是否确认归元?")
2020-05-09 13:31:21 +08:00
local _data={}
for i=1,#dropList do
2021-11-05 17:13:49 +08:00
_data[i] = {dropList[i].id,dropList[i].num,nil,dropList[i].star,curhero.dynamicId}
2020-05-09 13:31:21 +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)
--英雄消耗道具数量
heroUseCount=0
heroUseItemId=0
local pId = nil
local curHeroData = nil
for k,v in pairs(selectHeroData) do
curHeroData=v
break
end
if curHeroData == nil then return end
local heroRankupConfig = ConfigManager.GetConfig(ConfigName.HeroRankupConfig)
if curHeroData.breakId == 0 then
pId=0
else
pId= heroRankupConfig[curHeroData.breakId].Phase[2]
end
local heroReturnConfig = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.HeroReturn,"HeroId",curHeroData.id,"Star",pId)
if not heroReturnConfig then
2021-10-26 17:55:49 +08:00
-- LogRed("HeroId"..curHeroData.id.." Star"..pId.." curHeroData.breakId"..curHeroData.breakId)
heroUseCount= 50
heroUseItemId = 16
else
heroUseCount= heroReturnConfig.ReturnConsume[1][2]
heroUseItemId = heroReturnConfig.ReturnConsume[1][1]
end
itemNum = BagManager.GetItemCountById(heroUseItemId)
2021-10-26 17:55:49 +08:00
-- 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
2021-04-21 13:12:04 +08:00
this.itemImage.sprite = this.spLoader:LoadSprite(GetResourcePath(itemConfig[heroUseItemId].ResourceID))
2020-05-09 13:31:21 +08:00
end
function this:OnClose()
end
function this:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
end
2020-06-23 18:36:24 +08:00
return this