136 lines
5.2 KiB
Lua
136 lines
5.2 KiB
Lua
----- 新副本主关卡奖励弹窗 -----
|
|
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.spLoader = SpriteLoader.New()
|
|
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
|
|
local condition = fightLevelData.config.ConditionValue or {}
|
|
local des = ""
|
|
if index == 0 then
|
|
des = HardStageCondition[100].Describe
|
|
else
|
|
if condition and condition[index] and HardStageCondition[condition[index]] then
|
|
des = HardStageCondition[condition[index]].Describe
|
|
else
|
|
des = ""
|
|
end
|
|
end
|
|
Util.GetGameObject(_go, "titleImage/titleText"):GetComponent("Text").text = index == 0 and "首通奖励" or des
|
|
Util.GetGameObject(_go, "titleImage/Text"):GetComponent("Text").text = index
|
|
-- Util.GetGameObject(_go, "okButton"):GetComponent("Text").text = "以达成"
|
|
-- Util.GetGameObject(_go, "noButton"):GetComponent("Text").text = "未达成"
|
|
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")
|
|
noButton:SetActive(not FightLevelManager.GetCurLevelStarState(fightLevelData.state,index))
|
|
okButton:SetActive(FightLevelManager.GetCurLevelStarState(fightLevelData.state,index))
|
|
if index == 0 then--首通
|
|
noButton:SetActive(not fightLevelData.isPass)--state > 0 说明有星 肯定通关了就
|
|
okButton:SetActive(fightLevelData.isPass)
|
|
else
|
|
noButton:SetActive(not FightLevelManager.GetCurLevelStarState(fightLevelData.state,index))
|
|
okButton:SetActive(FightLevelManager.GetCurLevelStarState(fightLevelData.state,index))
|
|
end
|
|
end
|
|
function this:OnSortingOrderChange(_sortingOrder)
|
|
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 = _sortingOrder
|
|
end
|
|
|
|
function this:OnClose()
|
|
rewardData = {}
|
|
end
|
|
|
|
function this:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
end
|
|
|
|
return this |