112 lines
4.2 KiB
Lua
112 lines
4.2 KiB
Lua
----- 灵兽合成 -----
|
|
local this = {}
|
|
--传入父脚本模块
|
|
local sortingOrder
|
|
local parent
|
|
local compoundNum
|
|
local compoundMaxNum = 20
|
|
local itemData
|
|
local itemViewPre
|
|
|
|
function this:InitComponent(gameObject)
|
|
this.spLoader = SpriteLoader.New()
|
|
Util.GetGameObject(gameObject, "TitleText"):GetComponent("Text").text = Language[10219]
|
|
this.itemParent = Util.GetGameObject(gameObject, "itemParent")
|
|
this.Slider = Util.GetGameObject(gameObject, "Slider")
|
|
this.addBtn = Util.GetGameObject(gameObject, "addBtn")
|
|
this.jianBtn = Util.GetGameObject(gameObject, "jianBtn")
|
|
this.btnCompound = Util.GetGameObject(gameObject, "btnCompound")
|
|
this.numText = Util.GetGameObject(gameObject,
|
|
"Slider/numText"):GetComponent("Text")
|
|
this.numText2 = Util.GetGameObject(gameObject,
|
|
"Slider/numText2"):GetComponent("Text")
|
|
end
|
|
|
|
function this:BindEvent()
|
|
Util.AddSlider(this.Slider, function(go, value)
|
|
this.ShowCompoundNumData(value)
|
|
end)
|
|
Util.AddClick(this.addBtn, function()
|
|
if compoundNum < compoundMaxNum then
|
|
compoundNum = compoundNum + 1
|
|
this.ShowCompoundNumData(compoundNum)
|
|
end
|
|
end)
|
|
Util.AddClick(this.jianBtn, function()
|
|
if compoundNum >= 2 then
|
|
compoundNum = compoundNum - 1
|
|
this.ShowCompoundNumData(compoundNum)
|
|
end
|
|
end)
|
|
|
|
Util.AddClick(this.btnCompound, function()
|
|
if compoundNum > 0 then
|
|
local item = {}
|
|
item.itemId = itemData.id
|
|
item.itemNum = compoundNum * itemData.itemConfig.UsePerCount
|
|
Log("sssssssssssssss " .. item.itemId .. " " .. item.itemNum)
|
|
NetManager.HeroComposeRequest(item, function(drop)
|
|
UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1, function()
|
|
parent:ClosePanel()
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Pokemon.PokemonCompound)
|
|
end, nil, nil, nil, true)
|
|
end)
|
|
else
|
|
PopupTipPanel.ShowTip(Language[10210])
|
|
end
|
|
end)
|
|
end
|
|
|
|
function this:AddListener()
|
|
end
|
|
|
|
function this:RemoveListener()
|
|
end
|
|
|
|
function this:OnShow(_parent, ...)
|
|
parent = _parent
|
|
sortingOrder = _parent.sortingOrder
|
|
--不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参
|
|
local _args = { ... }
|
|
itemData = _args[1]
|
|
this.RefreshPanel()
|
|
end
|
|
|
|
function this:OnClose()
|
|
end
|
|
|
|
function this:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
itemViewPre = nil
|
|
end
|
|
|
|
--刷新面板
|
|
function this.RefreshPanel()
|
|
compoundNum = 1
|
|
compoundMaxNum = (math.floor(itemData.num / itemData.itemConfig.UsePerCount)) > 20 and 20 or
|
|
(math.floor(itemData.num / itemData.itemConfig.UsePerCount))
|
|
if not itemViewPre then
|
|
itemViewPre = SubUIManager.Open(SubUIConfig.ItemView, this.itemParent.transform)
|
|
end
|
|
itemViewPre:OnOpen(false, { itemData.id, itemData.num }, 0.97)
|
|
compoundNum = compoundNum >= compoundMaxNum and compoundMaxNum or compoundNum
|
|
Log("compoundNum " .. compoundNum)
|
|
this.Slider:GetComponent("Slider").value = compoundNum
|
|
this.Slider:GetComponent("Slider").minValue = 0
|
|
this.Slider:GetComponent("Slider").maxValue = compoundMaxNum
|
|
this.ShowCompoundNumData(compoundNum)
|
|
end
|
|
|
|
function this.ShowCompoundNumData(value)
|
|
Log("当前slider值 " .. value)
|
|
compoundNum = value
|
|
this.Slider:GetComponent("Slider").value = value
|
|
this.numText2.text = value
|
|
this.numText.text = Language[10225] ..
|
|
value * itemData.itemConfig.UsePerCount ..
|
|
Language[10226] ..
|
|
value .. Language[10227] .. GetLanguageStrById(string.gsub(itemData.itemConfig.Name, Language[10228], ""))
|
|
end
|
|
|
|
return this
|