miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/View/GeneralPopup_EquipSingleSel...

138 lines
4.2 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +08:00
----- 宝器分解弹窗 -----
2020-07-07 15:20:43 +08:00
local this = {}
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder=0
local _args={}
--传入选择宝器计算返回奖励数据列表
local dropList = {}
--item容器
local itemList = {}
--传入选择英雄
local selectEquipTreasureData
2020-07-11 16:21:15 +08:00
local func
2020-07-10 18:29:38 +08:00
local count = 0
2020-07-11 16:21:15 +08:00
function this:SetCount(value)
count = value
this.slider.value = value
2021-03-02 16:53:12 +08:00
this.bodyText.text=string.format(Language[11542],count,GetLanguageStrById(selectEquipTreasureData.itemConfig.Name))
this.numText.text = value
2020-07-10 18:29:38 +08:00
end
2020-07-07 15:20:43 +08:00
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
function this:InitComponent(gameObject)
this.titleText=Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text")
this.bodyText=Util.GetGameObject(gameObject,"BodyText"):GetComponent("Text")
this.numText=Util.GetGameObject(gameObject,"numText"):GetComponent("Text")
2020-07-07 15:20:43 +08:00
this.confirmBtn=Util.GetGameObject(gameObject,"ConfirmBtn")
2020-07-11 16:21:15 +08:00
this.addBtn=Util.GetGameObject(gameObject,"add")
this.reduceBtn=Util.GetGameObject(gameObject,"reduce")
this.slider=Util.GetGameObject(gameObject,"Slider"):GetComponent("Slider")
2020-07-07 15:20:43 +08:00
--滚动条根节点
this.root = Util.GetGameObject(gameObject, "Root")
end
2020-07-10 18:29:38 +08:00
--道具 和 装备分解 发送请求后 回调
function this.SendBackResolveReCallBack(drop)
local isShowReward=false
if drop.itemlist~=nil and #drop.itemlist>0 then
for i = 1, #drop.itemlist do
if drop.itemlist[i].itemNum>0 then
isShowReward=true
break
end
end
end
if isShowReward then
UIManager.OpenPanel(UIName.RewardItemPopup,drop,1,function ()
BagManager.OnShowTipDropNumZero(drop)
end)
else
BagManager.OnShowTipDropNumZero(drop)
end
2020-07-13 11:15:53 +08:00
parent:ClosePanel()
2020-07-11 16:21:15 +08:00
if func then
func()
end
2020-07-10 18:29:38 +08:00
end
2020-07-07 15:20:43 +08:00
function this:BindEvent()
Util.AddClick(this.cancelBtn,function()
parent:ClosePanel()
end)
Util.AddClick(this.confirmBtn,function()
2020-07-11 16:21:15 +08:00
if count == 0 then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11543])
2020-07-11 16:21:15 +08:00
return
end
if selectEquipTreasureData.itemConfig.Quantity >= 4 then
UIManager.OpenPanel(UIName.BagResolveAnCompoundPanel,2,selectEquipTreasureData.itemConfig.ItemBaseType,selectEquipTreasureData,function() end,count)
parent:ClosePanel()
2020-07-10 18:29:38 +08:00
else
local curResolveAllItemList={}
local equip = {}
equip.itemId = selectEquipTreasureData.id
equip.itemNum = count
table.insert(curResolveAllItemList,equip)
local type = 1
NetManager.UseAndPriceItemRequest(type,curResolveAllItemList,function (drop)
this.SendBackResolveReCallBack(drop)
end)
end
end)
Util.AddClick(this.addBtn,function()
if count < selectEquipTreasureData.num then
this:SetCount(count + 1)
else
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[12144])
end
2020-07-10 18:29:38 +08:00
end)
Util.AddClick(this.reduceBtn,function()
if count > 1 then
this:SetCount(count - 1)
else
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[12145])
end
2020-07-07 15:20:43 +08:00
end)
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnShow(_parent,...)
parent=_parent
sortingOrder =_parent.sortingOrder
2020-07-10 18:29:38 +08:00
local args={...}
2021-03-02 16:53:12 +08:00
this.titleText.text=Language[11544]
2020-07-07 15:20:43 +08:00
2020-07-10 18:29:38 +08:00
local equip = args[1]
2020-07-11 16:21:15 +08:00
func = args[2]
2020-07-10 18:29:38 +08:00
selectEquipTreasureData = BagManager.GetItemById(equip.id)
2020-07-11 16:21:15 +08:00
this:SetCount(selectEquipTreasureData.num)
2020-07-10 18:29:38 +08:00
if not itemList or #itemList < 1 then
local item = SubUIManager.Open(SubUIConfig.ItemView, this.root.transform)
table.insert(itemList,item)
2020-07-07 15:20:43 +08:00
end
2020-07-10 18:29:38 +08:00
itemList[1].gameObject:SetActive(true)
itemList[1]:OnOpen(false,{selectEquipTreasureData.id,selectEquipTreasureData.num},1,true,false)
this.slider.minValue = 1
2020-07-11 16:21:15 +08:00
this.slider.maxValue = selectEquipTreasureData.num
this.slider.value = selectEquipTreasureData.num
2020-07-10 18:29:38 +08:00
this.slider.onValueChanged:AddListener(function()
2020-07-11 16:21:15 +08:00
this:SetCount(this.slider.value)
2020-07-10 18:29:38 +08:00
end)
2020-07-07 15:20:43 +08:00
end
function this:OnClose()
2020-07-10 18:29:38 +08:00
2020-07-07 15:20:43 +08:00
end
function this:OnDestroy()
2020-07-13 11:15:53 +08:00
itemList = {}
count = 0
2020-07-07 15:20:43 +08:00
end
return this