2021-04-21 13:12:04 +08:00
|
|
|
|
require("Base/BasePanel")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
ItemGetPopup = Inherit(BasePanel)
|
|
|
|
|
local this = ItemGetPopup
|
|
|
|
|
local ItemDataConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
|
|
|
local itemListPrefab = {}
|
|
|
|
|
|
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
function ItemGetPopup:InitComponent()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader = SpriteLoader.New()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
this.btnBack = Util.GetGameObject(self.gameObject, "btnBack")
|
|
|
|
|
this.itemPrefab = Util.GetGameObject(self.gameObject, "frame")
|
|
|
|
|
|
|
|
|
|
for i = 1, 10 do
|
|
|
|
|
itemListPrefab[i] = Util.GetGameObject(self.gameObject, "ScrollView/Content/frame" .. i)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
function ItemGetPopup:BindEvent()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Util.AddClick(this.btnBack, function()
|
|
|
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function ItemGetPopup:AddListener()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function ItemGetPopup:RemoveListener()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
|
function ItemGetPopup:OnOpen(...)
|
2021-01-09 14:20:06 +08:00
|
|
|
|
Log("物品获得界面")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local args = {...}
|
|
|
|
|
local itemList = args[1]
|
|
|
|
|
this.SetItemShow(itemList)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function ItemGetPopup:OnClose()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function ItemGetPopup:OnDestroy()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader:Destroy()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 根据物品列表数据显示物品
|
|
|
|
|
function this.SetItemShow(itemList)
|
|
|
|
|
-- 初始化
|
|
|
|
|
for i = 1, 10 do
|
|
|
|
|
itemListPrefab[i].gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
local itemCount = 2
|
|
|
|
|
for i = 1, itemCount do
|
|
|
|
|
local itemId = itemList[i].id -- 增加道具的id
|
|
|
|
|
local itemAdd = itemList[i].num -- 需要增加的数量
|
|
|
|
|
local itemFrame = itemListPrefab[i]
|
|
|
|
|
itemFrame:SetActive(true)
|
|
|
|
|
local itemIcon = Util.GetGameObject(itemFrame, "icon"):GetComponent("Image")
|
|
|
|
|
local itemNum = Util.GetGameObject(itemFrame, "num"):GetComponent("Text")
|
|
|
|
|
local itemName = Util.GetGameObject(itemFrame, "expInfo"):GetComponent("Text")
|
|
|
|
|
|
|
|
|
|
itemNum.text = 2 --tostring(itemAdd)
|
2021-03-02 16:53:12 +08:00
|
|
|
|
itemName.text = Language[11484]-- ItemDataConfig[itemId].Name
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return ItemGetPopup
|