----- 易经宝库弹窗 ----- 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.spLoader = SpriteLoader.New() 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(860, 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 and curId ~= 0 then 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 PopupTipPanel.ShowTip(Language[10759]) end end) end function this:AddListener() end function this:RemoveListener() end function this:OnShow(_parent,data) itemList={} parent=_parent sortingOrder = _parent.sortingOrder --不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参 _args = data ActData = _args[1] func = _args[2] this.titleText.text = Language[10760] curId = ActData.selectId or nil local RewardConfig = ConfigManager.GetAllConfigsDataByKey(ConfigName.BlessingRewardPoolNew,"PoolId",ActData.curFinalPool) table.sort(RewardConfig, function(a, b) if a.FloorLimit == b.FloorLimit then return a.Id < b.Id end return a.FloorLimit < b.FloorLimit end) 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 num = Util.GetGameObject(item,"text"):GetComponent("Text") local limit1 = Util.GetGameObject(item,"limit1"):GetComponent("Text") local limit2 = Util.GetGameObject(item,"limit2"):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 = SubString2(GetLanguageStrById(itemConfig[data.Reward[1]].Name),10) --判断是否选了该物品 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) local t1 = true local t2 = true local t3 = true --判断是否可以选择 num.gameObject:SetActive(true) if PlayerManager.level >= data.LevelLimit then limit1.gameObject:SetActive(false) select:SetActive(true) else limit1.gameObject:SetActive(true) limit1.text = data.LevelLimit..Language[10761] t1 = false end if ActData.curLevel >= data.FloorLimit then limit2.gameObject:SetActive(false) select:SetActive(true) else limit2.gameObject:SetActive(true) limit2.text = Language[10262]..data.FloorLimit..Language[10762] t2 = false end local aData = this.GetDataByRewardId(data.Id) -- LogRed(aData.rewardId..":"..tostring(aData.progress)) 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 = ""..(data.InitializeNum-aData.progress).."/"..data.InitializeNum.."" else t3 = true num.text = (data.InitializeNum - aData.progress).."/"..data.InitializeNum end select:SetActive(t1 and t2 and t3) end -- 获取数量 function this.GetDataByRewardId(rId) for k, v in ipairs(ActData.allData) do if v.rewardId == rId then return v end end end function this:OnClose() end function this:OnDestroy() this.spLoader:Destroy() itemIconList={} goList = {} end return this