2021-04-21 13:12:04 +08:00
|
|
|
|
----- 易经宝库弹窗 -----
|
2020-11-05 19:10:20 +08:00
|
|
|
|
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)
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader = SpriteLoader.New()
|
2020-11-05 19:10:20 +08:00
|
|
|
|
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,
|
2021-03-04 21:22:02 +08:00
|
|
|
|
this.itemPre, nil, Vector2.New(860, rootHight), 1, 2, Vector2.New(0, 0))
|
2020-11-05 19:10:20 +08:00
|
|
|
|
this.ScrollView.moveTween.MomentumAmount = 1
|
|
|
|
|
this.ScrollView.moveTween.Strength = 2
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:BindEvent()
|
|
|
|
|
Util.AddClick(this.ConfirmBtn,function()
|
2020-11-09 13:47:37 +08:00
|
|
|
|
if curId and curId ~= 0 then
|
2020-11-05 19:10:20 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.YiJingBaoKuConfirm,curId,function()
|
|
|
|
|
NetManager.SelectFinalRewardRequest(curId,ActData.activityId,function ()
|
|
|
|
|
if func then
|
|
|
|
|
func()
|
|
|
|
|
end
|
|
|
|
|
parent:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
else
|
2021-03-02 16:53:12 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[10759])
|
2020-11-05 19:10:20 +08:00
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:AddListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:RemoveListener()
|
|
|
|
|
end
|
|
|
|
|
|
2021-09-18 17:58:28 +08:00
|
|
|
|
function this:OnShow(_parent,data)
|
2020-11-05 19:10:20 +08:00
|
|
|
|
|
|
|
|
|
itemList={}
|
|
|
|
|
parent=_parent
|
|
|
|
|
sortingOrder = _parent.sortingOrder
|
|
|
|
|
--不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参
|
2021-09-18 17:58:28 +08:00
|
|
|
|
_args = data
|
2020-11-05 19:10:20 +08:00
|
|
|
|
ActData = _args[1]
|
|
|
|
|
func = _args[2]
|
2021-03-02 16:53:12 +08:00
|
|
|
|
this.titleText.text = Language[10760]
|
2020-11-05 19:10:20 +08:00
|
|
|
|
curId = ActData.selectId or nil
|
|
|
|
|
local RewardConfig = ConfigManager.GetAllConfigsDataByKey(ConfigName.BlessingRewardPoolNew,"PoolId",ActData.curFinalPool)
|
2021-09-18 14:19:26 +08:00
|
|
|
|
table.sort(RewardConfig, function(a, b)
|
|
|
|
|
if a.FloorLimit == b.FloorLimit then
|
|
|
|
|
return a.Id < b.Id
|
|
|
|
|
end
|
|
|
|
|
return a.FloorLimit < b.FloorLimit
|
|
|
|
|
end)
|
2020-11-05 19:10:20 +08:00
|
|
|
|
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")
|
2020-11-06 13:36:48 +08:00
|
|
|
|
local num = Util.GetGameObject(item,"text"):GetComponent("Text")
|
|
|
|
|
local limit1 = Util.GetGameObject(item,"limit1"):GetComponent("Text")
|
|
|
|
|
local limit2 = Util.GetGameObject(item,"limit2"):GetComponent("Text")
|
2020-11-05 19:10:20 +08:00
|
|
|
|
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)
|
2021-01-26 17:08:39 +08:00
|
|
|
|
name.text = SubString2(GetLanguageStrById(itemConfig[data.Reward[1]].Name),10)
|
2020-11-05 19:10:20 +08:00
|
|
|
|
--判断是否选了该物品
|
|
|
|
|
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)
|
2020-11-06 13:36:48 +08:00
|
|
|
|
|
|
|
|
|
local t1 = true
|
|
|
|
|
local t2 = true
|
|
|
|
|
local t3 = true
|
|
|
|
|
--判断是否可以选择
|
2021-10-15 14:35:57 +08:00
|
|
|
|
num.gameObject:SetActive(true)
|
|
|
|
|
if PlayerManager.level >= data.LevelLimit then
|
2020-11-06 13:36:48 +08:00
|
|
|
|
limit1.gameObject:SetActive(false)
|
|
|
|
|
select:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
limit1.gameObject:SetActive(true)
|
2021-03-02 16:53:12 +08:00
|
|
|
|
limit1.text = data.LevelLimit..Language[10761]
|
2020-11-06 13:36:48 +08:00
|
|
|
|
t1 = false
|
|
|
|
|
end
|
|
|
|
|
if ActData.curLevel >= data.FloorLimit then
|
|
|
|
|
limit2.gameObject:SetActive(false)
|
|
|
|
|
select:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
limit2.gameObject:SetActive(true)
|
2021-03-02 16:53:12 +08:00
|
|
|
|
limit2.text = Language[10262]..data.FloorLimit..Language[10762]
|
2020-11-06 13:36:48 +08:00
|
|
|
|
t2 = false
|
|
|
|
|
end
|
2021-09-18 18:40:21 +08:00
|
|
|
|
local aData = this.GetDataByRewardId(data.Id)
|
|
|
|
|
-- LogRed(aData.rewardId..":"..tostring(aData.progress))
|
2022-01-06 18:27:09 +08:00
|
|
|
|
if not aData then--2022/1/6 易经宝库增加层数容错
|
|
|
|
|
aData = {}
|
|
|
|
|
aData.progress = data.InitializeNum
|
|
|
|
|
end
|
|
|
|
|
if aData.progress >= data.InitializeNum then
|
|
|
|
|
t3 = false
|
|
|
|
|
-- 如果是当前层选中的特殊奖励
|
|
|
|
|
if aData.progress == data.InitializeNum and ActData.selectId == data.Id then--and ActData.curLevel > data.InitializeNum
|
|
|
|
|
t3 = true
|
|
|
|
|
end
|
|
|
|
|
num.text = "<color=red>"..(data.InitializeNum-aData.progress).."/"..data.InitializeNum.."</color>"
|
|
|
|
|
else
|
|
|
|
|
t3 = true
|
|
|
|
|
num.text = (data.InitializeNum - aData.progress).."/"..data.InitializeNum
|
|
|
|
|
end
|
2020-11-09 11:09:42 +08:00
|
|
|
|
|
2022-01-06 18:27:09 +08:00
|
|
|
|
select:SetActive(t1 and t2 and t3)
|
2020-11-06 13:36:48 +08:00
|
|
|
|
|
2020-11-05 19:10:20 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-09-18 18:40:21 +08:00
|
|
|
|
-- 获取数量
|
|
|
|
|
function this.GetDataByRewardId(rId)
|
|
|
|
|
for k, v in ipairs(ActData.allData) do
|
|
|
|
|
if v.rewardId == rId then
|
|
|
|
|
return v
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2020-11-05 19:10:20 +08:00
|
|
|
|
function this:OnClose()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnDestroy()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader:Destroy()
|
2020-11-05 19:10:20 +08:00
|
|
|
|
itemIconList={}
|
2021-09-18 13:41:26 +08:00
|
|
|
|
goList = {}
|
2020-11-05 19:10:20 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return this
|