miduo_client/Assets/ManagedResources/~Lua/Modules/FightLevel/View/FightLevelInfoPopup_MainLev...

127 lines
5.1 KiB
Lua
Raw Normal View History

2021-05-07 14:44:50 +08:00
----- 新副本主关卡奖励弹窗 -----
local this = {}
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder=0
local fun
--item容器
local itemList = {}
local rewardData = {}
2021-05-11 15:12:37 +08:00
local fightLevelData = {}
2021-05-13 09:56:11 +08:00
local fun
2021-05-11 15:12:37 +08:00
local RewardGroup = ConfigManager.GetConfig(ConfigName.RewardGroup)
2021-05-13 09:56:11 +08:00
local HardStageCondition = ConfigManager.GetConfig(ConfigName.HardStageCondition)
2021-05-07 14:44:50 +08:00
function this:InitComponent(gameObject)
this.spLoader = SpriteLoader.New()
2021-05-07 14:44:50 +08:00
this.titleText=Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text")
2021-05-07 20:24:41 +08:00
this.tipText=Util.GetGameObject(gameObject,"tipText"):GetComponent("Text")
2021-05-07 14:44:50 +08:00
this.backBtn=Util.GetGameObject(gameObject,"BackBtn")
2021-05-07 20:24:41 +08:00
this.rewardPre = Util.GetGameObject(gameObject, "rewardPre")
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(gameObject, "Root").transform,
2021-05-13 09:56:11 +08:00
this.rewardPre, nil, Vector2.New(920, 1071), 1, 1, Vector2.New(0,0))
2021-05-07 20:24:41 +08:00
this.ScrollView.moveTween.MomentumAmount = 1
this.ScrollView.moveTween.Strength = 1
this.NoviceItemList={}--存储itemview 重复利用
2021-05-07 14:44:50 +08:00
end
function this:BindEvent()
Util.AddClick(this.backBtn, function()
parent:ClosePanel()
2021-05-13 09:56:11 +08:00
if fun then
fun()
fun = nil
end
2021-05-07 14:44:50 +08:00
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 = {...}
2021-05-11 15:12:37 +08:00
fightLevelData = args[1]
2021-05-13 09:56:11 +08:00
fun = args[2]
2021-05-11 15:12:37 +08:00
this.titleText.text = "关卡奖励"
this.tipText.text = "达成目标后自动发放奖励"
2021-05-07 14:44:50 +08:00
--组数据
2021-05-13 09:56:11 +08:00
rewardData = {}
for i = 1, #fightLevelData.config.PassReward do
table.insert(rewardData,fightLevelData.config.PassReward[i])
end
2021-05-11 20:20:38 +08:00
for i = 1, #fightLevelData.config.Reward1 do
table.insert(rewardData,fightLevelData.config.Reward1[i])
end
2021-05-07 20:24:41 +08:00
this.ScrollView:SetData(rewardData, function (index, go)
2021-05-11 15:12:37 +08:00
this.SingleDataShow(go,rewardData[index],index)
end, true,true)
2021-05-07 14:44:50 +08:00
end
2021-05-11 20:20:38 +08:00
function this.SingleDataShow(_go,_rewardData,_index)
local index = _index - 1
2021-05-11 15:12:37 +08:00
local reward = RewardGroup[_rewardData].ShowItem
local condition = fightLevelData.config.ConditionValue or {}
local des = condition and HardStageCondition[condition[index]].Describe or ""
Util.GetGameObject(_go, "titleImage/titleText"):GetComponent("Text").text = index == 0 and "首通奖励" or des
2021-05-11 15:12:37 +08:00
Util.GetGameObject(_go, "titleImage/Text"):GetComponent("Text").text = index
Util.GetGameObject(_go, "okButton"):GetComponent("Image").sprite = this.spLoader:LoadSprite("g_ghhb_yidacheng_zh")
Util.GetGameObject(_go, "noButton"):GetComponent("Image").sprite = this.spLoader:LoadSprite("g_ghhb_weidacheng_zh")
2021-05-07 20:24:41 +08:00
local noStarImage = Util.GetGameObject(_go, "noStarImage")
local getStarImage = Util.GetGameObject(_go, "getStarImage")
2021-05-13 09:56:11 +08:00
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)
2021-05-07 20:24:41 +08:00
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)
2021-05-07 14:44:50 +08:00
end
2021-05-07 20:24:41 +08:00
this.NoviceItemList[_go][i].gameObject:SetActive(false)
2021-05-07 14:44:50 +08:00
end
2021-05-07 20:24:41 +08:00
for i = 1, #reward do
2021-05-11 15:12:37 +08:00
this.NoviceItemList[_go][i]:OnOpen(false, reward[i], 0.9,false,false,false,sortingOrder)
2021-05-07 20:24:41 +08:00
this.NoviceItemList[_go][i].gameObject:SetActive(true)
2021-05-07 14:44:50 +08:00
end
2021-05-07 20:24:41 +08:00
local noButton = Util.GetGameObject(_go.gameObject, "noButton")
local okButton = Util.GetGameObject(_go.gameObject, "okButton")
2021-05-11 15:12:37 +08:00
noButton:SetActive(not FightLevelManager.GetCurLevelStarState(fightLevelData.state,index))
okButton:SetActive(FightLevelManager.GetCurLevelStarState(fightLevelData.state,index))
2021-05-14 19:55:28 +08:00
if index == 0 then--首通
2021-05-18 16:51:43 +08:00
noButton:SetActive(not fightLevelData.isPass)--state > 0 说明有星 肯定通关了就
okButton:SetActive(fightLevelData.isPass)
2021-05-14 19:55:28 +08:00
else
noButton:SetActive(not FightLevelManager.GetCurLevelStarState(fightLevelData.state,index))
okButton:SetActive(FightLevelManager.GetCurLevelStarState(fightLevelData.state,index))
end
2021-05-07 20:24:41 +08:00
end
2021-05-27 20:17:53 +08:00
function this:OnSortingOrderChange(_sortingOrder)
2021-05-07 20:24:41 +08:00
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
2021-05-27 20:17:53 +08:00
this.NoviceItemList[i][j]:SetEffectLayer(_sortingOrder)
2021-05-07 20:24:41 +08:00
end
end
end
2021-05-27 20:17:53 +08:00
sortingOrder = _sortingOrder
2021-05-07 14:44:50 +08:00
end
function this:OnClose()
2021-05-13 09:56:11 +08:00
rewardData = {}
2021-05-07 14:44:50 +08:00
end
function this:OnDestroy()
this.spLoader:Destroy()
2021-05-07 14:44:50 +08:00
end
return this