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

124 lines
3.7 KiB
Lua
Raw Normal View History

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-10 18:29:38 +08:00
local count = 0
function this:SetCount(value)
if value == count then
return
end
if value < 0 then
count = 0
elseif value > selectEquipTreasureData.num then
count = selectEquipTreasureData.num
else
count = value
end
this.slider.value = count*1.00/selectEquipTreasureData.num
this.bodyText.text=string.format("出售%s个%s",count,selectEquipTreasureData.itemConfig.Name)
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.confirmBtn=Util.GetGameObject(gameObject,"ConfirmBtn")
2020-07-10 18:29:38 +08:00
this.addBtn=Util.GetGameObject(gameObject,"slider/add")
this.reduceBtn=Util.GetGameObject(gameObject,"slider/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
this:ClosePanel()
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-10 18:29:38 +08:00
if selectEquipTreasureData.itemConfig.Quantity>=4 then
UIManager.OpenPanel(UIName.BagResolveAnCompoundPanel,2,selectEquipTreasureData.itemConfig.ItemBaseType,selectEquipTreasureData)
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()
this:SetCount(count + 1)
end)
Util.AddClick(this.reduceBtn,function()
this:SetCount(count - 1)
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={...}
this.titleText.text="出售装备"
2020-07-07 15:20:43 +08:00
2020-07-10 18:29:38 +08:00
local equip = args[1]
selectEquipTreasureData = BagManager.GetItemById(equip.id)
count = this:SetCount(selectEquipTreasureData.num)
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.onValueChanged:AddListener(function()
this:SetCount(math.floor(this.slider.value * selectEquipTreasureData.num))
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()
end
return this