----- 试练副本奖励弹窗 ----- require("Base/BasePanel") local TrialRewardPopup = Inherit(BasePanel) local this = TrialRewardPopup local trialKillConfig=ConfigManager.GetConfig(ConfigName.TrialKillConfig) local itemList={} --预设容器 local sortingOrder=0 function TrialRewardPopup:InitComponent() this.panel=Util.GetGameObject(this.gameObject,"Panel") this.backBtn=Util.GetGameObject(this.panel,"BackBtn") this.scroll=Util.GetGameObject(this.panel,"Scroll") this.pre=Util.GetGameObject(this.panel,"Scroll/Pre") this.scrollView=SubUIManager.Open(SubUIConfig.ScrollCycleView,this.scroll.transform,this.pre, nil, Vector2.New(this.scroll.transform.rect.width,this.scroll.transform.rect.height),1,1,Vector2.New(0,10)) this.scrollView.gameObject:GetComponent("RectTransform").anchoredPosition= Vector2.New(0,0) this.scrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5) this.scrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5) this.scrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5) this.scrollView.moveTween.MomentumAmount = 1 this.scrollView.moveTween.Strength = 2 end function TrialRewardPopup:BindEvent() Util.AddClick(this.backBtn,function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) self:ClosePanel() end) end function TrialRewardPopup:AddListener() end function TrialRewardPopup:RemoveListener() end function TrialRewardPopup:OnSortingOrderChange() sortingOrder = self.sortingOrder end function TrialRewardPopup:OnOpen(...) end function TrialRewardPopup:OnShow() this.RefreshPanel() end function TrialRewardPopup:OnClose() end function TrialRewardPopup:OnDestroy() this.scrollView=nil itemList={} end --刷新 function this.RefreshPanel() local d={} for _, configInfo in ConfigPairs(trialKillConfig) do table.insert(d, configInfo) end this.scrollView:SetData(d,function(index,root) this.SetScrollPre(root,d[index]) end) this.scrollView:SetIndex(1) end --设置每条数据 function this.SetScrollPre(root,data) local info=Util.GetGameObject(root,"Title/Info"):GetComponent("Text") local grid=Util.GetGameObject(root,"Grid") local goBtn=Util.GetGameObject(root,"GoBtn") local goText=Util.GetGameObject(goBtn,"Text"):GetComponent("Text") info.text=string.format( Language[11616],data.Count,MapTrialManager.GetKilCount(),data.Count) ResetItemView(root,grid.transform,itemList,#data.BoxReward,0.8,sortingOrder,false,data.BoxReward) --按钮状态 local s=MapTrialManager.GetTrialRewardState(data.Id) goBtn:GetComponent("Button").interactable=s~=0 if s==0 then goText.text=Language[10350] elseif s==1 then goText.text=Language[10022] elseif s==2 then goText.text=Language[10023] end Util.AddOnceClick(goBtn,function() if s==1 then NetManager.RequestLevelReward(data.Id, function(msg) MapTrialManager.SetTrialRewardInfo(data.Id) --本地记录已领奖励信息 UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function() this.RefreshPanel() end) end) elseif s==2 then this:ClosePanel() end end) end return TrialRewardPopup