PGRData/Script/matrix/xui/xuimission/XUiPanelRewardSmall.lua

118 lines
3.8 KiB
Lua
Raw Normal View History

local XUiPanelRewardSmall = XClass(nil, "XUiPanelRewardSmall")
function XUiPanelRewardSmall:Ctor(ui,parent)
self.GameObject = ui.gameObject
self.Transform = ui.transform
self.Parent = parent
XTool.InitUiObject(self)
self:InitAutoScript()
self.GridList = {}
self.GridMissionCommonA.gameObject:SetActive(false)
end
--设置奖励
function XUiPanelRewardSmall:SetupReward(result)
if not result then
return
end
local rewardExtra = result.ExtraRewardList
local rewards = result.Rewards
local XUiGridMissionCommon = require("XUi/XUiMission/XUiGridMissionCommon")
local start = 0
if rewardExtra then
for _, item in ipairs(rewardExtra) do
start = start + 1
local grid
if self.GridList[start] then
grid = self.GridList[start]
else
local ui = CS.UnityEngine.Object.Instantiate(self.GridMissionCommonA)
grid = XUiGridMissionCommon.New(self.Parent, ui)
grid.Transform:SetParent(self.PanelReward, false)
grid.ImgAdditional.gameObject:SetActive(true)
grid.ImgBig.gameObject:SetActive(false)
table.insert(self.GridList, grid)
end
grid:Refresh(item)
grid.GameObject:SetActive(true)
end
end
--显示的奖励
if rewards then
for _, item in ipairs(rewards) do
start = start + 1
local grid
if self.GridList[start] then
grid = self.GridList[start]
else
local ui = CS.UnityEngine.Object.Instantiate(self.GridMissionCommonA)
grid = XUiGridMissionCommon.New(self.Parent, ui)
grid.Transform:SetParent(self.PanelReward, false)
grid.ImgAdditional.gameObject:SetActive(false)
grid.ImgBig.gameObject:SetActive(false)
table.insert(self.GridList, grid)
end
grid:Refresh(item)
grid.GameObject:SetActive(true)
end
end
for j = start + 1, #self.GridList do
self.GridList[j].GameObject:SetActive(false)
end
end
-- auto
-- Automatic generation of code, forbid to edit
function XUiPanelRewardSmall:InitAutoScript()
self:AutoInitUi()
self.SpecialSoundMap = {}
self:AutoAddListener()
end
function XUiPanelRewardSmall:AutoInitUi()
-- self.PanelRewardSmallA = self.Transform:Find("PanelRewardSmall")
-- self.ScrollViewA = self.Transform:Find("PanelRewardSmall/ScrollView"):GetComponent("Scrollbar")
-- self.PanelReward = self.Transform:Find("PanelRewardSmall/ScrollView/Viewport/PanelReward")
-- self.GridMissionCommonA = self.Transform:Find("PanelRewardSmall/ScrollView/Viewport/PanelReward/GridMissionCommon")
end
function XUiPanelRewardSmall:GetAutoKey(uiNode,eventName)
if not uiNode then return end
return eventName .. uiNode:GetHashCode()
end
function XUiPanelRewardSmall:RegisterListener(uiNode, eventName, func)
local key = self:GetAutoKey(uiNode, eventName)
if not key then return end
local listener = self.AutoCreateListeners[key]
if listener ~= nil then
uiNode[eventName]:RemoveListener(listener)
end
if func ~= nil then
if type(func) ~= "function" then
XLog.Error("XUiPanelRewardSmall:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func))
end
listener = function(...)
XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName)
func(self, ...)
end
uiNode[eventName]:AddListener(listener)
self.AutoCreateListeners[key] = listener
end
end
function XUiPanelRewardSmall:AutoAddListener()
self.AutoCreateListeners = {}
end
-- auto
return XUiPanelRewardSmall