----- 新副本主关卡奖励弹窗 ----- local this = {} --传入父脚本模块 local parent --传入特效层级 local sortingOrder=0 local fun --item容器 local itemList = {} local rewardData = {} local fightLevelData = {} local fun local RewardGroup = ConfigManager.GetConfig(ConfigName.RewardGroup) local HardStageCondition = ConfigManager.GetConfig(ConfigName.HardStageCondition) function this:InitComponent(gameObject) this.titleText=Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text") this.tipText=Util.GetGameObject(gameObject,"tipText"):GetComponent("Text") this.backBtn=Util.GetGameObject(gameObject,"BackBtn") this.rewardPre = Util.GetGameObject(gameObject, "rewardPre") this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(gameObject, "Root").transform, this.rewardPre, nil, Vector2.New(920, 1071), 1, 1, Vector2.New(0,0)) this.ScrollView.moveTween.MomentumAmount = 1 this.ScrollView.moveTween.Strength = 1 this.NoviceItemList={}--存储itemview 重复利用 end function this:BindEvent() Util.AddClick(this.backBtn, function() parent:ClosePanel() if fun then fun() fun = nil end end) end function this:AddListener() end function this:RemoveListener() end function this:OnShow(_parent,...) parent=_parent sortingOrder = _parent.sortingOrder --不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参 local args = {...} fightLevelData = args[1] fun = args[2] this.titleText.text = "关卡奖励" this.tipText.text = "达成目标后自动发放奖励" --组数据 rewardData = {} for i = 1, #fightLevelData.config.PassReward do table.insert(rewardData,fightLevelData.config.PassReward[i]) end for i = 1, #fightLevelData.config.Reward1 do table.insert(rewardData,fightLevelData.config.Reward1[i]) end this.ScrollView:SetData(rewardData, function (index, go) this.SingleDataShow(go,rewardData[index],index) end, true,true) end function this.SingleDataShow(_go,_rewardData,_index) local index = _index - 1 local reward = RewardGroup[_rewardData].ShowItem Util.GetGameObject(_go, "titleImage/titleText"):GetComponent("Text").text = index == 0 and "首通奖励" or HardStageCondition[fightLevelData.config.ConditionValue[index]].Describe Util.GetGameObject(_go, "titleImage/Text"):GetComponent("Text").text = index Util.GetGameObject(_go, "okButton"):GetComponent("Image").sprite = Util.LoadSprite("s_slbz_yilingqu_zh") local noStarImage = Util.GetGameObject(_go, "noStarImage") local getStarImage = Util.GetGameObject(_go, "getStarImage") noStarImage:SetActive(not FightLevelManager.GetCurLevelStarState(fightLevelData.state,index) and index ~= 0) getStarImage:SetActive(FightLevelManager.GetCurLevelStarState(fightLevelData.state,index) and index ~= 0) Util.GetGameObject(_go, "titleImage/Text"):SetActive(index ~= 0) local itemGroup = Util.GetGameObject(_go, "content") --滚动条复用重设itemview if not this.NoviceItemList[_go] then this.NoviceItemList[_go] = {} end for i = 1, #reward do if not this.NoviceItemList[_go][i] then this.NoviceItemList[_go][i] = SubUIManager.Open(SubUIConfig.ItemView, itemGroup.transform) end this.NoviceItemList[_go][i].gameObject:SetActive(false) end for i = 1, #reward do this.NoviceItemList[_go][i]:OnOpen(false, reward[i], 0.9,false,false,false,sortingOrder) this.NoviceItemList[_go][i].gameObject:SetActive(true) end local noButton = Util.GetGameObject(_go.gameObject, "noButton") local okButton = Util.GetGameObject(_go.gameObject, "okButton") Util.GetGameObject(noButton, "Text"):GetComponent("Text").text = "未达成" noButton:SetActive(not FightLevelManager.GetCurLevelStarState(fightLevelData.state,index)) okButton:SetActive(FightLevelManager.GetCurLevelStarState(fightLevelData.state,index)) end function this.OnSortingOrderChange() for i, v in pairs(this.NoviceItemList) do for j = 1, #this.NoviceItemList[i] do if this.NoviceItemList[i][j] and this.NoviceItemList[i][j].gameObject then this.NoviceItemList[i][j]:SetEffectLayer(sortingOrder) end end end sortingOrder = self.sortingOrder end function this:OnClose() rewardData = {} if fun then fun() fun = nil end end function this:OnDestroy() end return this