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

87 lines
2.3 KiB
Lua
Raw Normal View History

2021-12-09 13:29:16 +08:00
----灵脉跳转界面 -----
local this = {}
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder=0
function this:InitComponent(gameObject)
self.spLoader = SpriteLoader.New()
self.btnSure = Util.GetGameObject(gameObject,"BtnSure")
self.btnCancel = Util.GetGameObject(gameObject,"BtnCancel")
2021-12-09 20:17:37 +08:00
self.money = Util.GetGameObject(gameObject,"Content/money"):GetComponent("Text")
self.grid1 = Util.GetGameObject(gameObject,"Grid1/scroll")
self.grid2 = Util.GetGameObject(gameObject,"Grid2")
self.itemList1 = {}
self.itemList2 = {}
2021-12-09 13:29:16 +08:00
end
function this:BindEvent()
2021-12-09 20:17:37 +08:00
Util.AddClick(self.btnCancel,function()
self.parent:ClosePanel()
end)
Util.AddClick(self.btnSure,function()
NetManager.LifeStoneUpRequest(2,nil,nil,nil,nil,function ()
Game.GlobalEvent:DispatchEvent(GameEvent.Gem.RefreshPanel)
2021-12-14 09:48:28 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.OnTempBagChanged)
2021-12-09 20:17:37 +08:00
PopupTipPanel.ShowTip("一键合成成功!")
self.parent:ClosePanel()
end)
end)
2021-12-09 13:29:16 +08:00
end
function this:AddListener()
end
function this:RemoveListener()
end
2021-12-10 11:01:44 +08:00
function this:OnShow(_parent,...)
self.args = {...}
2021-12-09 13:29:16 +08:00
self.parent = _parent
self:Refresh()
end
function this:Refresh()
2021-12-09 20:17:37 +08:00
self.money.text = self.args[2]
local list = {}
for key, value in pairs(self.args[1]) do
2021-12-13 17:26:08 +08:00
-- LogGreen("id:"..tostring(key).." num:"..tostring(value))
2021-12-09 20:17:37 +08:00
local data = {}
data.id = key
data.num = value
table.insert(list,data)
end
table.sort(list,function (a,b)
return a.id < b.id
end)
local grid = nil
if #list > 5 then
grid = self.grid1
self.grid1:SetActive(true)
2021-12-10 13:57:24 +08:00
self.grid2:SetActive(false)
2021-12-09 20:17:37 +08:00
else
grid = self.grid2
self.grid1:SetActive(false)
2021-12-10 17:18:18 +08:00
self.grid2:SetActive(true)
2021-12-09 20:17:37 +08:00
end
for i = 1, #list do
2021-12-10 17:18:18 +08:00
local go = self.itemList1[i]
2021-12-09 20:17:37 +08:00
if not go then
go = SubUIManager.Open(SubUIConfig.ItemView,grid.transform)
2021-12-10 17:18:18 +08:00
self.itemList1[i] = go
2021-12-09 20:17:37 +08:00
end
2021-12-10 11:01:44 +08:00
go:OnOpen(false, {list[i].id,list[i].num}, 1, false,false,false,self.parent.sortingOrder + 1)
go.gameObject:SetActive(true)
2021-12-09 20:17:37 +08:00
end
2021-12-09 13:29:16 +08:00
end
function this:OnClose()
end
function this:OnDestroy()
this.spLoader:Destroy()
2021-12-09 20:17:37 +08:00
self.itemList1 = {}
2021-12-09 13:29:16 +08:00
end
return this