126 lines
3.8 KiB
Lua
126 lines
3.8 KiB
Lua
|
----- 易经宝库弹窗 -----
|
||
|
local this = {}
|
||
|
--传入父脚本模块
|
||
|
local parent
|
||
|
--传入特效层级
|
||
|
local sortingOrder=0
|
||
|
local curId = nil--当前已选择的物品的Id
|
||
|
local ActData = {}
|
||
|
local itemList = {}--克隆预制体列表
|
||
|
local goList = {}--勾选按钮列表
|
||
|
local itemIconList={}--ItemView的List
|
||
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
||
|
local _args
|
||
|
local func
|
||
|
|
||
|
function this:InitComponent(gameObject)
|
||
|
this.titleText=Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text")
|
||
|
this.itemPre = Util.GetGameObject(gameObject, "itemPre")
|
||
|
this.ConfirmBtn = Util.GetGameObject(gameObject, "ConfirmBtn")
|
||
|
this.Scroll = Util.GetGameObject(gameObject, "Scroll")
|
||
|
|
||
|
local rootHight = this.Scroll.transform.rect.height
|
||
|
local width = this.Scroll.transform.rect.width
|
||
|
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.Scroll.transform,
|
||
|
this.itemPre, nil, Vector2.New(width, rootHight), 1, 2, Vector2.New(0, 0))
|
||
|
this.ScrollView.moveTween.MomentumAmount = 1
|
||
|
this.ScrollView.moveTween.Strength = 2
|
||
|
end
|
||
|
|
||
|
function this:BindEvent()
|
||
|
Util.AddClick(this.ConfirmBtn,function()
|
||
|
if curId then
|
||
|
-- NetManager.SelectFinalRewardRequest(curId,ActData.activityId,function ()
|
||
|
-- if func then
|
||
|
-- func()
|
||
|
-- end
|
||
|
-- parent:ClosePanel()
|
||
|
-- end)
|
||
|
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.YiJingBaoKuConfirm,curId,function()
|
||
|
-- parent:ClosePanel()
|
||
|
NetManager.SelectFinalRewardRequest(curId,ActData.activityId,function ()
|
||
|
if func then
|
||
|
func()
|
||
|
end
|
||
|
parent:ClosePanel()
|
||
|
end)
|
||
|
end)
|
||
|
else
|
||
|
PopupTipPanel.ShowTip(Language[11796])
|
||
|
end
|
||
|
end)
|
||
|
end
|
||
|
|
||
|
function this:AddListener()
|
||
|
end
|
||
|
|
||
|
function this:RemoveListener()
|
||
|
end
|
||
|
|
||
|
function this:OnShow(_parent,...)
|
||
|
|
||
|
itemList={}
|
||
|
parent=_parent
|
||
|
sortingOrder = _parent.sortingOrder
|
||
|
--不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参
|
||
|
_args = {...}
|
||
|
ActData = _args[1]
|
||
|
func = _args[2]
|
||
|
this.titleText.text = "选择最终奖励"
|
||
|
curId = ActData.selectId or nil
|
||
|
local RewardConfig = ConfigManager.GetAllConfigsDataByKey(ConfigName.BlessingRewardPoolNew,"PoolId",ActData.curFinalPool)
|
||
|
this.ScrollView:SetData(RewardConfig, function(index, go)
|
||
|
this:SetSingleData(index,go, RewardConfig[index])
|
||
|
end)
|
||
|
|
||
|
end
|
||
|
|
||
|
function this:SetSingleData(index,item,data)
|
||
|
itemList[index] = item
|
||
|
local icon = Util.GetGameObject(item,"icon")
|
||
|
local name = Util.GetGameObject(item,"name"):GetComponent("Text")
|
||
|
local tip = Util.GetGameObject(item,"text"):GetComponent("Text")
|
||
|
local select = Util.GetGameObject(item,"select")
|
||
|
local go = Util.GetGameObject(item,"select/Go")
|
||
|
|
||
|
goList[index] = go
|
||
|
|
||
|
item:SetActive(true)
|
||
|
if not itemIconList[item] then
|
||
|
local view = SubUIManager.Open(SubUIConfig.ItemView, icon.transform)
|
||
|
itemIconList[item] = view
|
||
|
end
|
||
|
itemIconList[item]:OnOpen(false,data.Reward,0.9,false)
|
||
|
name.text = itemConfig[data.Reward[1]].Name
|
||
|
|
||
|
|
||
|
--判断是否选了该物品
|
||
|
if curId == data.Id then
|
||
|
go:SetActive(true)
|
||
|
else
|
||
|
go:SetActive(false)
|
||
|
end
|
||
|
--选择一个物品
|
||
|
Util.AddOnceClick(select,function()
|
||
|
if go.gameObject.activeSelf then
|
||
|
go:SetActive(false)
|
||
|
curId = nil
|
||
|
else
|
||
|
for index, value in ipairs(goList) do
|
||
|
goList[index]:SetActive(false)
|
||
|
end
|
||
|
go:SetActive(true)
|
||
|
curId = data.Id
|
||
|
end
|
||
|
end)
|
||
|
end
|
||
|
|
||
|
function this:OnClose()
|
||
|
|
||
|
end
|
||
|
|
||
|
function this:OnDestroy()
|
||
|
itemIconList={}
|
||
|
end
|
||
|
|
||
|
return this
|