miduo_client/Assets/ManagedResources/~Lua/Modules/FightLevel/FightLevelSingleChapterPane...

484 lines
23 KiB
Lua
Raw Normal View History

2021-05-07 14:44:50 +08:00
require("Base/BasePanel")
FightLevelSingleChapterPanel = Inherit(BasePanel)
local this = FightLevelSingleChapterPanel
local sortingOrder = 0
local boxList = {}
local levelList = {}
2021-05-11 15:12:37 +08:00
local chapterId = 0
local chapterData = {}
local allMissionDailyBoxItemPres = {}
2021-05-21 14:37:09 +08:00
local mainLevleBg = {[1] = "s_shanhe_xiaoditu_dabiao",[2] = "s_shanhe_xiaoditu_dabiao_01"}
local LevleTitleBg = {[1] = "s_shanhe_xiaoditu_biaoxiamingzidi",[2] = "s_shanhe_xiaoditu_biaoxiamingzidi_01"}
local point = {[1] = "s_shanhe_xiaoditu_xiabao",[2] = "s_shanhe_xiaoditu_xiabao_01"}
local assistantLevleDiBg = {[1] = "s_shanhe_xiaoditu_zhongbiao",[2] = "s_shanhe_xiaoditu_zhongbiao_01"}
2021-05-22 15:55:14 +08:00
local assistantLevleBattle = {[1] = "s_shanhe_xiaoditu_jian",[2] = "s_shanhe_xiaoditu_jian_01",[3] = "r_jyxz_qizhi_gou"}
local assistantLevleReward = {[1] = "baoxiang-01-1",[2] = "s_shanhe_xiaoditu_baoxiang_01",[3] = "baoxiang-01-2"}
2021-05-21 14:37:09 +08:00
local allSmallPoint = {}
2021-05-07 14:44:50 +08:00
--初始化组件(用于子类重写)
function FightLevelSingleChapterPanel:InitComponent()
2021-05-19 17:36:43 +08:00
this.spLoader = SpriteLoader.New()
2021-05-07 14:44:50 +08:00
self.btnBack = Util.GetGameObject(self.gameObject, "btnBack")
this.chapterNameText = Util.GetGameObject(self.gameObject, "rightUp/chapterNameText"):GetComponent("Text")
2021-05-21 19:07:46 +08:00
this.chapterNameImage = Util.GetGameObject(self.gameObject, "rightUp/starInfoBg/Image/Image"):GetComponent("Text")
2021-05-07 14:44:50 +08:00
this.totalPro = Util.GetGameObject(self.gameObject, "rewardBg/totalProImage/totalPro"):GetComponent("Text")
this.prb = Util.GetGameObject(self.gameObject, "middle/prb")
2021-05-11 15:12:37 +08:00
this.rect = Util.GetGameObject(self.gameObject, "middle/rect")
2021-05-07 14:44:50 +08:00
levelList = {}
2021-05-11 15:12:37 +08:00
this.rewardBoxParent = Util.GetGameObject(self.gameObject, "middle/rewardBg/btnList")
this.progressBottom = Util.GetGameObject(self.gameObject, "middle/rewardBg/progressBottom/Image"):GetComponent("Image")
2021-05-07 14:44:50 +08:00
for i = 1, 3 do
boxList[i] = Util.GetGameObject(self.gameObject, "middle/rewardBg/btnList/BoxBtn"..i)
end
2021-05-11 15:12:37 +08:00
this.leftBtn=Util.GetGameObject(self.gameObject,"middle/leftBtn")
this.rightBtn=Util.GetGameObject(self.gameObject,"middle/rightBtn")
2021-05-11 20:20:38 +08:00
this.leftBtnClick=Util.GetGameObject(self.gameObject,"middle/leftBtn/GameObject")
this.rightBtnClick=Util.GetGameObject(self.gameObject,"middle/rightBtn/GameObject")
--宝箱预览
this.rewardMaskBtn = Util.GetGameObject(self.gameObject, "middle/rewardMaskBtn")
this.RewardPanelGetInfo = Util.GetGameObject(self.gameObject, "middle/rewardMaskBtn/RewardPanel/getInfo"):GetComponent("Text")
this.RewardPanelGrid = Util.GetGameObject(self.gameObject, "middle/rewardMaskBtn/RewardPanel/ViewRect/grid")
Util.GetGameObject(self.gameObject, "middle/rewardMaskBtn/RewardPanel/Image/Text"):GetComponent("Text").text = Language[10763]
2021-05-21 14:37:09 +08:00
--无用小点显示
allSmallPoint = {}
this.pointPre = Util.GetGameObject(self.gameObject, "middle/pointPre")
this.pointParent = Util.GetGameObject(self.gameObject, "middle/pointParent")
2021-05-22 15:55:14 +08:00
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft })
this.mask = Util.GetGameObject(self.gameObject, "mask")
this.activityEnterBtn = Util.GetGameObject(self.gameObject, "activityEnterBtn")
this.activityEnterBtnTime = Util.GetGameObject(this.activityEnterBtn, "time"):GetComponent("Text")
2021-05-07 14:44:50 +08:00
end
--绑定事件(用于子类重写)
function FightLevelSingleChapterPanel:BindEvent()
Util.AddClick(self.activityEnterBtn, function()
JumpManager.GoJump(26002)
end)
2021-05-07 14:44:50 +08:00
Util.AddClick(self.btnBack, function()
self:ClosePanel()
end)
2021-05-11 20:20:38 +08:00
Util.AddClick(this.leftBtnClick, function()
2021-05-11 15:12:37 +08:00
this.LeftOrRightBtnClickEvent(1)
end)
2021-05-11 20:20:38 +08:00
Util.AddClick(this.rightBtnClick, function()
this.LeftOrRightBtnClickEvent(2)
2021-05-11 15:12:37 +08:00
end)
Util.AddClick(this.rewardMaskBtn, function()
this.rewardMaskBtn:SetActive(false)
end)
2021-05-07 14:44:50 +08:00
end
function FightLevelSingleChapterPanel:OnSortingOrderChange()
--特效层级重设
if levelList and #levelList > 0 then
for i=1,#levelList do
Util.SetParticleSortLayer(levelList[i], self.sortingOrder + 1)
2021-05-26 14:59:25 +08:00
end
sortingOrder = self.sortingOrder
end
2021-05-07 14:44:50 +08:00
end
--界面打开时调用(用于子类重写)
2021-05-11 15:12:37 +08:00
function FightLevelSingleChapterPanel:OnOpen(_chapterId)
chapterId = _chapterId
this.mask:SetActive(false)
2021-05-07 14:44:50 +08:00
-- SoundManager.PlaySound(SoundConfig.Sound_WorldMap)
2021-05-22 15:55:14 +08:00
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main })
2021-05-07 14:44:50 +08:00
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function FightLevelSingleChapterPanel:OnShow()
this.OnShowPanel()
2021-05-14 16:44:40 +08:00
this.LeftOrRightBtnClickEvent()
this.rewardMaskBtn:SetActive(false)
this.showActivityBtn()
end
2021-05-26 14:59:25 +08:00
function this.showActivityBtn()
if ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.ShanHeShiLian) then
this.activityEnterBtn.gameObject:SetActive(true)
else
this.activityEnterBtn.gameObject:SetActive(false)
end
this.activityBtnTimeShow()
2021-05-07 14:44:50 +08:00
end
function this.activityBtnTimeShow()
if this.activityBtnTime then
this.activityBtnTime:Stop()
this.activityBtnTime = nil
end
local remainTime = ActivityGiftManager.GetTaskRemainTime(ActivityTypeDef.ShanHeShiLian)
local s = function()
2022-03-21 17:21:11 +08:00
local temp = ""
if remainTime <= 86400 then
temp = TimeToFelaxible(remainTime).."后结束"
elseif remainTime > 86400 then
temp = TimeToDHM(remainTime).."后结束"
end
this.activityEnterBtnTime.text = temp
remainTime = remainTime - 1
if remainTime <= 0 then
this.activityEnterBtn.gameObject:SetActive(false)
if this.activityBtnTime then
this.activityBtnTime:Stop()
this.activityBtnTime = nil
end
return
end
end
s()
this.activityBtnTime = Timer.New(s, 1)
this.activityBtnTime:Start()
end
2022-03-21 17:21:11 +08:00
2021-05-07 14:44:50 +08:00
function this.OnShowPanel()
SoundManager.PlayMusic(SoundConfig.BGM_Main)
2021-05-11 15:12:37 +08:00
chapterData = FightLevelManager.GetChapterData(chapterId)
this.chapterNameText.text = chapterData.config.Name
2021-05-21 19:07:46 +08:00
this.chapterNameImage.text = chapterData.config.Id
2021-05-13 09:56:11 +08:00
if chapterData.node and LengthOfTable(chapterData.node) > 0 then
2021-05-14 15:03:48 +08:00
local curchapterData = {}
for key, value in pairs(chapterData.node) do
table.insert(curchapterData,value)
end
table.sort(curchapterData, function(a,b) return a.nodeId < b.nodeId end)
this.SetSingleLevel(curchapterData)
2021-05-26 14:59:25 +08:00
sortingOrder = this.sortingOrder
2021-05-13 09:56:11 +08:00
end
if chapterData.reward and LengthOfTable(chapterData.reward) > 0 then
this.SetlevelBox(chapterData.reward)
end
2021-05-21 14:37:09 +08:00
this.ShowChapterPoint()
end
function this.ShowChapterPoint()
2021-05-21 19:07:46 +08:00
2021-05-22 15:26:30 +08:00
local allNodeDatas = {}
for key, value in pairs(chapterData.node) do
table.insert(allNodeDatas,value)
end
table.sort(allNodeDatas, function(a,b) return a.nodeId < b.nodeId end)
2021-05-26 20:47:41 +08:00
local points = {}
2021-05-22 15:26:30 +08:00
for i = 1, #allNodeDatas do
if allNodeDatas[i].config.UselessPoint then
2021-05-26 20:47:41 +08:00
local isOpen = this.GetCurLevelIsOpen(allNodeDatas[i])-- -1 未开启 0 开启 1 需解锁上一关 2 等级不足
2021-05-22 15:26:30 +08:00
for j = 1, #allNodeDatas[i].config.UselessPoint do
2021-05-26 20:47:41 +08:00
table.insert(points,{allNodeDatas[i].config.UselessPoint[j][1],allNodeDatas[i].config.UselessPoint[j][2],isOpen})
-- if allNodeDatas[i].config.UselessPoint[j + 1] then
-- local posX = allNodeDatas[i].config.UselessPoint[j][1] + (allNodeDatas[i].config.UselessPoint[j + 1][1] - allNodeDatas[i].config.UselessPoint[j][1])/2
-- local posY = allNodeDatas[i].config.UselessPoint[j][2] + (allNodeDatas[i].config.UselessPoint[j + 1][2] - allNodeDatas[i].config.UselessPoint[j][2])/2
-- table.insert(points,{posX,posY,isOpen})
-- end
2021-05-21 19:07:46 +08:00
end
end
end
2021-05-26 20:47:41 +08:00
for i = 1, math.max(#allSmallPoint , #points) do
2021-05-21 14:37:09 +08:00
local go = allSmallPoint[i]
if not go then
go = newObject(this.pointPre)
go.transform:SetParent(this.pointParent.transform)
go.name = "pointPre"..i
go.transform.localScale = Vector3.one
go.transform.localPosition = Vector3.zero
allSmallPoint[i] = go
end
go.gameObject:SetActive(false)
end
2021-05-26 20:47:41 +08:00
for i = 1, #points do
allSmallPoint[i].gameObject:SetActive(true)
allSmallPoint[i].transform.localPosition = Vector3.New(points[i][1],points[i][2],0)
local image = allSmallPoint[i]:GetComponent("Image")
image.sprite = this.spLoader:LoadSprite(points[i][3] == 0 and point[1] or point[2])
2021-05-21 14:37:09 +08:00
end
2021-05-21 19:07:46 +08:00
2021-05-07 14:44:50 +08:00
end
function this.SetSingleLevel(levelDatas)
2021-05-21 19:07:46 +08:00
for i = math.max(#levelDatas , #levelList), 1, -1 do
2021-05-07 14:44:50 +08:00
local go = levelList[i]
if not go then
go = newObject(this.prb)
go.transform:SetParent(this.rect.transform)
go.name = "level"..i
go.transform.localScale = Vector3.one
go.transform.localPosition = Vector3.zero
levelList[i] = go
end
go.gameObject:SetActive(false)
end
2021-05-14 15:03:48 +08:00
for i = 1, #levelDatas do
2021-05-11 15:12:37 +08:00
local levelData = levelDatas[i]
2021-05-07 14:44:50 +08:00
levelList[i]:SetActive(true)
2021-05-11 15:12:37 +08:00
levelList[i].transform.localPosition = Vector3.New(levelDatas[i].config.LevelPointPosition[1],levelDatas[i].config.LevelPointPosition[2],0)
2021-05-21 14:37:09 +08:00
local prb1 = Util.GetGameObject(levelList[i], "prb1")--主
local prb2 = Util.GetGameObject(levelList[i], "prb2")--副奖励
2021-05-21 19:07:46 +08:00
local prb3 = Util.GetGameObject(levelList[i], "prb3")--副战斗
2021-05-26 14:59:25 +08:00
local UI_Effect_Kuang_JinSe = Util.GetGameObject(levelList[i], "UI_Effect_Kuang_JinSe")
2021-05-27 20:17:53 +08:00
local isFarstEffect = Util.GetGameObject(levelList[i], "isFirst")
2021-05-14 15:03:48 +08:00
local isOpen = this.GetCurLevelIsOpen(levelDatas[i])-- -1 未开启 0 开启 1 需解锁上一关 2 等级不足
2021-05-14 16:44:40 +08:00
prb1:SetActive(false)
prb2:SetActive(false)
2021-05-21 14:37:09 +08:00
prb3:SetActive(false)
2021-05-26 14:59:25 +08:00
UI_Effect_Kuang_JinSe:SetActive(isOpen == 0 and levelData.config.StageType == FIGHTLEVEL_STAGETYPE.MainLevel)
2021-05-27 20:17:53 +08:00
isFarstEffect:SetActive(levelData.isFirst and levelData.config.StageType == FIGHTLEVEL_STAGETYPE.MainLevel)
for j = 1, 3 do
Util.SetParticleSortLayer(Util.GetGameObject(isFarstEffect, "Fx_star_looping ("..j..")"),this.sortingOrder + 1)
2021-05-27 20:17:53 +08:00
end
Util.SetParticleSortLayer(UI_Effect_Kuang_JinSe,this.sortingOrder + 1)
2021-05-11 15:12:37 +08:00
if levelData.config.StageType == FIGHTLEVEL_STAGETYPE.MainLevel then --主关卡
2021-05-07 14:44:50 +08:00
prb1:SetActive(true)
2021-05-21 14:37:09 +08:00
Util.GetGameObject(prb1, "nameBg"):GetComponent("Image").sprite = this.spLoader:LoadSprite(isOpen == 0 and LevleTitleBg[1] or LevleTitleBg[2])
local name = isOpen == 0 and string.format("<color=#FFC07C>%s</color>", levelData.config.Name) or string.format("<color=#E3D8CC>%s</color>", levelData.config.Name)
Util.GetGameObject(prb1, "nameBg/levelName"):GetComponent("Text").text = name
Util.GetGameObject(prb1, "openImage"):GetComponent("Image").sprite = this.spLoader:LoadSprite(isOpen == 0 and mainLevleBg[1] or mainLevleBg[2])
local bossIcon = Util.GetGameObject(prb1, "openImage/bossIcon")
bossIcon:GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(ConfigManager.GetConfigData(ConfigName.HeroConfig,levelData.config.Head).Icon))
Util.SetGray(bossIcon, not (isOpen == 0))
local starParent = Util.GetGameObject(prb1, "star")
if levelData.isPass then
starParent:SetActive(true)
for j = 1, 3 do
local curIndexStarGo = Util.GetGameObject(levelList[i], "prb1/star/star (" ..j.. ")/star")
curIndexStarGo:SetActive(FightLevelManager.GetCurLevelStarState(levelData.state,j))
end
else
starParent:SetActive(false)
2021-05-11 15:12:37 +08:00
end
Util.AddOnceClick(levelList[i], function()
2021-05-14 15:03:48 +08:00
if isOpen == 0 then
UIManager.OpenPanel(UIName.FightLevelSingleLevelInfoPopup,FIGHTLEVEL_POPUP_TYPE.MainLevel,levelData)
elseif isOpen == -1 then
PopupTipPanel.ShowTip("未开启!")
elseif isOpen == 1 then
PopupTipPanel.ShowTip("通关上一关后解锁!")
elseif isOpen == 2 then
PopupTipPanel.ShowTip(string.format("到达%s级后解锁",levelDatas[i].config.LevelLimit))
end
2021-05-11 15:12:37 +08:00
end)
elseif levelData.config.StageType == FIGHTLEVEL_STAGETYPE.AssistantLevelReward then--副关卡奖励
prb2:SetActive(true)
local prb2Icon = Util.GetGameObject(prb2, "Icon")
2021-05-21 14:37:09 +08:00
prb2:GetComponent("Image").sprite = this.spLoader:LoadSprite(isOpen == 0 and assistantLevleDiBg[1] or assistantLevleDiBg[2])
2021-05-22 15:55:14 +08:00
local icon = isOpen == 0 and assistantLevleReward[1] or assistantLevleReward[2]
if levelData.state == 1 then
icon = assistantLevleReward[3]
end
if isOpen == 0 then
prb2Icon:SetActive(false)
else
prb2Icon:SetActive(true)
end
prb2Icon:GetComponent("Image").sprite = this.spLoader:LoadSprite(icon)
Util.GetGameObject(levelList[i], "prb2/UI_Effect_BaoXiang_KaiQi"):SetActive(levelData.state==1)
Util.GetGameObject(levelList[i], "prb2/UI_Effect_BaoXiang_KaiQi/MeiKaiQi"):SetActive(false)
Util.GetGameObject(levelList[i], "prb2/UI_Effect_BaoXiang_KaiQi"):GetComponent("Animator").enabled = false
Util.GetGameObject(levelList[i], "prb2/UI_Effect_BaoXiang_KaiQi/KaiQi"):SetActive(levelData.state==1)
Util.GetGameObject(levelList[i], "prb2/UI_Effect_BaoXiang_KeKaiQi"):SetActive(levelData.state==0 and isOpen == 0)
2021-05-11 15:12:37 +08:00
Util.AddOnceClick(levelList[i], function()
2021-05-14 15:03:48 +08:00
if isOpen == 0 then
if levelData.state == 0 then
this.mask:SetActive(true)
Util.GetGameObject(levelList[i], "prb2/UI_Effect_BaoXiang_KeKaiQi"):SetActive(false)
Util.GetGameObject(levelList[i], "prb2/UI_Effect_BaoXiang_KaiQi"):SetActive(true)
Util.GetGameObject(levelList[i], "prb2/UI_Effect_BaoXiang_KaiQi"):GetComponent("Animator").enabled = true
Util.GetGameObject(levelList[i], "prb2/UI_Effect_BaoXiang_KaiQi/MeiKaiQi"):SetActive(true)
Timer.New(function()
FightLevelManager.FightLevelFightBattle(levelData, function()
this.OnShowPanel()
this.LeftOrRightBtnClickEvent()
this.mask:SetActive(false)
end)
end, 1, 1, true):Start()
2021-05-14 15:03:48 +08:00
elseif levelData.state == 1 then
PopupTipPanel.ShowTip("奖励已领取!")
end
elseif isOpen == -1 then
PopupTipPanel.ShowTip("未开启!")
elseif isOpen == 1 then
PopupTipPanel.ShowTip("通关上一关后解锁!")
elseif isOpen == 2 then
PopupTipPanel.ShowTip(string.format("到达%s级后解锁",levelDatas[i].config.LevelLimit))
end
end)
Util.SetParticleSortLayer(levelList[i], this.sortingOrder + 1)
2021-05-11 15:12:37 +08:00
elseif levelData.config.StageType == FIGHTLEVEL_STAGETYPE.AssistantLevel then--副关卡战斗
2021-05-21 14:37:09 +08:00
prb3:SetActive(true)
prb3:GetComponent("Image").sprite = this.spLoader:LoadSprite(isOpen == 0 and assistantLevleDiBg[1] or assistantLevleDiBg[2])
2021-05-22 15:55:14 +08:00
local icon = isOpen == 0 and assistantLevleBattle[1] or assistantLevleBattle[2]
if levelData.state == 1 then
icon = assistantLevleBattle[3]
end
Util.GetGameObject(prb3, "Icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(icon)
2021-05-07 14:44:50 +08:00
Util.AddOnceClick(levelList[i], function()
2021-05-14 15:03:48 +08:00
if isOpen == 0 then
UIManager.OpenPanel(UIName.FightLevelSingleLevelInfoPopup,FIGHTLEVEL_POPUP_TYPE.AssistantLevel,levelData)
elseif isOpen == -1 then
PopupTipPanel.ShowTip("未开启!")
elseif isOpen == 1 then
PopupTipPanel.ShowTip("通关上一关后解锁!")
elseif isOpen == 2 then
PopupTipPanel.ShowTip(string.format("到达%s级后解锁",levelDatas[i].config.LevelLimit))
end
2021-05-07 14:44:50 +08:00
end)
end
end
end
2021-05-13 09:56:11 +08:00
function this.SetlevelBox(_rewardBoxDatas)
2021-05-11 15:12:37 +08:00
this.totalPro.text = chapterData.stars.."/"..chapterData.curMaxStarNum
this.progressBottom.fillAmount=chapterData.stars/chapterData.curMaxStarNum
2021-05-13 09:56:11 +08:00
for i = 1, math.max(#_rewardBoxDatas, #boxList) do
2021-05-07 14:44:50 +08:00
local go = boxList[i]
if not go then
2021-05-11 15:12:37 +08:00
go = newObject(boxList[1])
go.transform:SetParent(this.rewardBoxParent.transform)
2021-05-07 14:44:50 +08:00
go.name = "BoxBtn"..i
go.transform.localScale = Vector3.one
go.transform.localPosition = Vector3.zero
boxList[i] = go
end
go.gameObject:SetActive(false)
end
2021-05-13 09:56:11 +08:00
for i, v in pairs(_rewardBoxDatas) do
2021-05-07 14:44:50 +08:00
boxList[i]:SetActive(true)
2021-05-13 09:56:11 +08:00
local missionConfigData = _rewardBoxDatas[i].config
boxList[i]:GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(missionConfigData.RewardIcon))
2021-05-11 15:12:37 +08:00
Util.GetGameObject(boxList[i], "num"):GetComponent("Text").text = missionConfigData.Star
2021-05-13 22:50:34 +08:00
Util.GetGameObject(boxList[i], "redPoint"):SetActive( _rewardBoxDatas[i].state == 0 and chapterData.stars > _rewardBoxDatas[i].config.Star)
2021-05-11 15:12:37 +08:00
-- Util.GetGameObject(boxList[i], "UI_Effect_BaoXiang_KaiQi"):SetActive(v.state==SingleDailyMissionState.GetFinish)
-- Util.GetGameObject(boxList[i], "UI_Effect_BaoXiang_KaiQi/MeiKaiQi"):SetActive(false)
-- Util.GetGameObject(boxList[i], "UI_Effect_BaoXiang_KaiQi"):GetComponent("Animator").enabled = false
-- Util.GetGameObject(boxList[i], "UI_Effect_BaoXiang_KaiQi/KaiQi"):SetActive(v.state==SingleDailyMissionState.GetFinish)
-- Util.GetGameObject(boxList[i], "UI_Effect_BaoXiang_KeKaiQi"):SetActive(v.state==SingleDailyMissionState.Finish)
2021-05-07 14:44:50 +08:00
Util.GetGameObject(boxList[i], "getFinish"):SetActive(false)
Util.GetGameObject(boxList[i], "redPoint"):SetActive(false)
2021-05-13 22:50:34 +08:00
if _rewardBoxDatas[i].state == 0 then
if chapterData.stars >= missionConfigData.Star then
Util.GetGameObject(boxList[i], "redPoint"):SetActive(true)
Util.AddOnceClick(boxList[i], function()
NetManager.GetHardStageChapterReward(chapterData.chapterId,missionConfigData.Id,function(msg)
--自己刷新一下宝箱数据
2021-05-14 15:03:48 +08:00
FightLevelManager.SetChapterBoxRewardData(chapterData.chapterId,missionConfigData.Id,1)
CheckRedPointStatus(RedPointType.FightLevelBoxReward)
2021-05-13 22:50:34 +08:00
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop, 1,function()--isBackBattle true时 为回放不走回调
2021-05-14 15:03:48 +08:00
if chapterData.reward and LengthOfTable(chapterData.reward) > 0 then
this.SetlevelBox(chapterData.reward)
end
2021-05-13 22:50:34 +08:00
end)
end)
2021-05-13 09:56:11 +08:00
end)
2021-05-13 22:50:34 +08:00
else
Util.GetGameObject(boxList[i], "redPoint"):SetActive(false)
Util.AddOnceClick(boxList[i], function()
this.FindBoxRewardInfo(missionConfigData)
end)
2021-05-13 22:50:34 +08:00
end
elseif _rewardBoxDatas[i].state == 1 then
2021-05-13 09:56:11 +08:00
Util.GetGameObject(boxList[i], "getFinish"):SetActive(true)
2021-05-14 15:03:48 +08:00
Util.AddOnceClick(boxList[i], function()
this.FindBoxRewardInfo(missionConfigData)
2021-05-14 15:03:48 +08:00
end)
2021-05-13 09:56:11 +08:00
end
2021-05-07 14:44:50 +08:00
end
end
2021-05-11 15:12:37 +08:00
--左右按钮
function this.LeftOrRightBtnClickEvent(index)
--index 为空时 刷新下左右按钮的显示 下一章节未开启的时候不显示右按钮 相反
2021-05-14 16:44:40 +08:00
local upChapterId = chapterData.chapterId - 1
local upChapterData = FightLevelManager.GetChapterData(upChapterId)
2021-05-26 20:47:41 +08:00
local canLeft = true
2021-05-14 16:44:40 +08:00
if upChapterData and upChapterId <= FightLevelManager.GetCurChapterId() then
this.leftBtn:SetActive(true)
else
2021-05-26 20:47:41 +08:00
canLeft = false
2021-05-14 16:44:40 +08:00
this.leftBtn:SetActive(false)
end
local downChapterId = chapterData.chapterId + 1
2021-05-14 19:55:28 +08:00
local downChapterData = FightLevelManager.GetChapterData(downChapterId)
2021-05-26 20:47:41 +08:00
local canRight = true
2021-05-14 16:44:40 +08:00
if downChapterData and downChapterId <= FightLevelManager.GetCurChapterId() then
this.rightBtn:SetActive(true)
else
2021-05-26 20:47:41 +08:00
canRight = false
2021-05-14 16:44:40 +08:00
this.rightBtn:SetActive(false)
end
2021-05-26 20:47:41 +08:00
if index and index == 1 and canLeft then--左
2021-05-14 16:44:40 +08:00
chapterId = upChapterId
chapterData = upChapterData
2021-11-02 17:45:18 +08:00
FightLevelManager.curSelect = FightLevelManager.curSelect - 1
2021-05-14 16:44:40 +08:00
this.OnShowPanel()
2021-05-14 19:55:28 +08:00
this.LeftOrRightBtnClickEvent()
2021-05-26 20:47:41 +08:00
elseif index and index == 2 and canRight then--右
2021-05-14 16:44:40 +08:00
chapterId = downChapterId
chapterData = downChapterData
2021-11-02 17:45:18 +08:00
FightLevelManager.curSelect = FightLevelManager.curSelect + 1
2021-05-14 16:44:40 +08:00
this.OnShowPanel()
2021-05-14 19:55:28 +08:00
this.LeftOrRightBtnClickEvent()
2021-05-11 15:12:37 +08:00
end
end
2021-05-14 15:03:48 +08:00
function this.GetCurLevelIsOpen(levelDatas)
if levelDatas.config.LevelLimit == -1 then
return -1
end
if levelDatas.nodeId > FightLevelManager.GetCurChapterLevelId() then
--特殊判断 分主关卡和副关卡
2021-05-25 14:51:26 +08:00
local upMainLevelConfig = FightLevelManager.GetChapterLevelData(levelDatas.config.Chapter,levelDatas.config.NextLevel)
if not upMainLevelConfig.isPass then
return 1
end
2021-05-14 15:03:48 +08:00
end
if levelDatas.config.LevelLimit > PlayerManager.level then
return 2
end
return 0
end
--宝箱奖励预览
function this.FindBoxRewardInfo(missionConfigData)
local curConfig = missionConfigData
this.RewardPanelGetInfo.text = string.format("收集%s星获得",curConfig.Star)
local showItem = ConfigManager.GetConfigData(ConfigName.RewardGroup,curConfig.StarReward)
local reward ={}
if showItem and showItem.ShowItem then
reward = showItem.ShowItem
end
if reward then
for i = 1, math.max(#allMissionDailyBoxItemPres, #reward) do
local go = allMissionDailyBoxItemPres[i]
if not go then
go = SubUIManager.Open(SubUIConfig.ItemView, this.RewardPanelGrid.transform)
go.gameObject.name = "frame"..i
allMissionDailyBoxItemPres[i] = go
end
go.gameObject:SetActive(false)
end
for i = 1, #reward do
allMissionDailyBoxItemPres[i].gameObject:SetActive(true)
allMissionDailyBoxItemPres[i]:OnOpen(false,reward[i],0.75)
end
end
this.rewardMaskBtn:SetActive(true)
end
2021-05-07 14:44:50 +08:00
--界面关闭时调用(用于子类重写)
function FightLevelSingleChapterPanel:OnClose()
if this.activityBtnTime then
this.activityBtnTime:Stop()
this.activityBtnTime = nil
end
2021-05-07 14:44:50 +08:00
end
--界面销毁时调用(用于子类重写)
function FightLevelSingleChapterPanel:OnDestroy()
allMissionDailyBoxItemPres = {}
2021-05-19 17:36:43 +08:00
this.spLoader:Destroy()
2021-05-22 15:55:14 +08:00
SubUIManager.Close(this.UpView)
2021-05-07 14:44:50 +08:00
end
return FightLevelSingleChapterPanel