484 lines
23 KiB
Lua
484 lines
23 KiB
Lua
require("Base/BasePanel")
|
||
FightLevelSingleChapterPanel = Inherit(BasePanel)
|
||
local this = FightLevelSingleChapterPanel
|
||
local sortingOrder = 0
|
||
local boxList = {}
|
||
local levelList = {}
|
||
local chapterId = 0
|
||
local chapterData = {}
|
||
local allMissionDailyBoxItemPres = {}
|
||
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"}
|
||
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"}
|
||
local allSmallPoint = {}
|
||
--初始化组件(用于子类重写)
|
||
function FightLevelSingleChapterPanel:InitComponent()
|
||
this.spLoader = SpriteLoader.New()
|
||
self.btnBack = Util.GetGameObject(self.gameObject, "btnBack")
|
||
this.chapterNameText = Util.GetGameObject(self.gameObject, "rightUp/chapterNameText"):GetComponent("Text")
|
||
this.chapterNameImage = Util.GetGameObject(self.gameObject, "rightUp/starInfoBg/Image/Image"):GetComponent("Text")
|
||
this.totalPro = Util.GetGameObject(self.gameObject, "rewardBg/totalProImage/totalPro"):GetComponent("Text")
|
||
|
||
this.prb = Util.GetGameObject(self.gameObject, "middle/prb")
|
||
this.rect = Util.GetGameObject(self.gameObject, "middle/rect")
|
||
levelList = {}
|
||
this.rewardBoxParent = Util.GetGameObject(self.gameObject, "middle/rewardBg/btnList")
|
||
this.progressBottom = Util.GetGameObject(self.gameObject, "middle/rewardBg/progressBottom/Image"):GetComponent("Image")
|
||
for i = 1, 3 do
|
||
boxList[i] = Util.GetGameObject(self.gameObject, "middle/rewardBg/btnList/BoxBtn"..i)
|
||
end
|
||
this.leftBtn=Util.GetGameObject(self.gameObject,"middle/leftBtn")
|
||
this.rightBtn=Util.GetGameObject(self.gameObject,"middle/rightBtn")
|
||
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]
|
||
|
||
--无用小点显示
|
||
allSmallPoint = {}
|
||
this.pointPre = Util.GetGameObject(self.gameObject, "middle/pointPre")
|
||
this.pointParent = Util.GetGameObject(self.gameObject, "middle/pointParent")
|
||
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")
|
||
end
|
||
|
||
--绑定事件(用于子类重写)
|
||
function FightLevelSingleChapterPanel:BindEvent()
|
||
Util.AddClick(self.activityEnterBtn, function()
|
||
JumpManager.GoJump(26002)
|
||
end)
|
||
Util.AddClick(self.btnBack, function()
|
||
self:ClosePanel()
|
||
end)
|
||
Util.AddClick(this.leftBtnClick, function()
|
||
this.LeftOrRightBtnClickEvent(1)
|
||
end)
|
||
Util.AddClick(this.rightBtnClick, function()
|
||
this.LeftOrRightBtnClickEvent(2)
|
||
end)
|
||
Util.AddClick(this.rewardMaskBtn, function()
|
||
this.rewardMaskBtn:SetActive(false)
|
||
end)
|
||
end
|
||
function FightLevelSingleChapterPanel:OnSortingOrderChange()
|
||
--特效层级重设
|
||
if levelList and #levelList > 0 then
|
||
for i=1,#levelList do
|
||
Util.SetParticleSortLayer(levelList[i], self.sortingOrder + 1)
|
||
end
|
||
sortingOrder = self.sortingOrder
|
||
end
|
||
end
|
||
--界面打开时调用(用于子类重写)
|
||
function FightLevelSingleChapterPanel:OnOpen(_chapterId)
|
||
chapterId = _chapterId
|
||
this.mask:SetActive(false)
|
||
-- SoundManager.PlaySound(SoundConfig.Sound_WorldMap)
|
||
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main })
|
||
end
|
||
|
||
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
||
function FightLevelSingleChapterPanel:OnShow()
|
||
|
||
this.OnShowPanel()
|
||
this.LeftOrRightBtnClickEvent()
|
||
this.rewardMaskBtn:SetActive(false)
|
||
this.showActivityBtn()
|
||
|
||
end
|
||
|
||
function this.showActivityBtn()
|
||
if ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.ShanHeShiLian) then
|
||
this.activityEnterBtn.gameObject:SetActive(true)
|
||
else
|
||
this.activityEnterBtn.gameObject:SetActive(false)
|
||
end
|
||
this.activityBtnTimeShow()
|
||
end
|
||
|
||
function this.activityBtnTimeShow()
|
||
if this.activityBtnTime then
|
||
this.activityBtnTime:Stop()
|
||
this.activityBtnTime = nil
|
||
end
|
||
local remainTime = ActivityGiftManager.GetTaskRemainTime(ActivityTypeDef.ShanHeShiLian)
|
||
local s = function()
|
||
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,-1,false)
|
||
this.activityBtnTime:Start()
|
||
end
|
||
|
||
|
||
function this.OnShowPanel()
|
||
|
||
SoundManager.PlayMusic(SoundConfig.BGM_Main)
|
||
chapterData = FightLevelManager.GetChapterData(chapterId)
|
||
this.chapterNameText.text = chapterData.config.Name
|
||
this.chapterNameImage.text = chapterData.config.Id
|
||
if chapterData.node and LengthOfTable(chapterData.node) > 0 then
|
||
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)
|
||
sortingOrder = this.sortingOrder
|
||
end
|
||
if chapterData.reward and LengthOfTable(chapterData.reward) > 0 then
|
||
this.SetlevelBox(chapterData.reward)
|
||
end
|
||
this.ShowChapterPoint()
|
||
end
|
||
function this.ShowChapterPoint()
|
||
|
||
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)
|
||
local points = {}
|
||
for i = 1, #allNodeDatas do
|
||
if allNodeDatas[i].config.UselessPoint then
|
||
local isOpen = this.GetCurLevelIsOpen(allNodeDatas[i])-- -1 未开启 0 开启 1 需解锁上一关 2 等级不足
|
||
for j = 1, #allNodeDatas[i].config.UselessPoint do
|
||
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
|
||
end
|
||
end
|
||
end
|
||
for i = 1, math.max(#allSmallPoint , #points) do
|
||
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
|
||
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])
|
||
end
|
||
|
||
end
|
||
function this.SetSingleLevel(levelDatas)
|
||
for i = math.max(#levelDatas , #levelList), 1, -1 do
|
||
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
|
||
for i = 1, #levelDatas do
|
||
local levelData = levelDatas[i]
|
||
levelList[i]:SetActive(true)
|
||
levelList[i].transform.localPosition = Vector3.New(levelDatas[i].config.LevelPointPosition[1],levelDatas[i].config.LevelPointPosition[2],0)
|
||
local prb1 = Util.GetGameObject(levelList[i], "prb1")--主
|
||
local prb2 = Util.GetGameObject(levelList[i], "prb2")--副奖励
|
||
local prb3 = Util.GetGameObject(levelList[i], "prb3")--副战斗
|
||
local UI_Effect_Kuang_JinSe = Util.GetGameObject(levelList[i], "UI_Effect_Kuang_JinSe")
|
||
local isFarstEffect = Util.GetGameObject(levelList[i], "isFirst")
|
||
local isOpen = this.GetCurLevelIsOpen(levelDatas[i])-- -1 未开启 0 开启 1 需解锁上一关 2 等级不足
|
||
prb1:SetActive(false)
|
||
prb2:SetActive(false)
|
||
prb3:SetActive(false)
|
||
UI_Effect_Kuang_JinSe:SetActive(isOpen == 0 and levelData.config.StageType == FIGHTLEVEL_STAGETYPE.MainLevel)
|
||
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)
|
||
end
|
||
Util.SetParticleSortLayer(UI_Effect_Kuang_JinSe,this.sortingOrder + 1)
|
||
if levelData.config.StageType == FIGHTLEVEL_STAGETYPE.MainLevel then --主关卡
|
||
prb1:SetActive(true)
|
||
-- 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("%s", levelData.config.Name) or string.format("%s", 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)
|
||
end
|
||
Util.AddOnceClick(levelList[i], function()
|
||
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
|
||
end)
|
||
elseif levelData.config.StageType == FIGHTLEVEL_STAGETYPE.AssistantLevelReward then--副关卡奖励
|
||
prb2:SetActive(true)
|
||
local prb2Icon = Util.GetGameObject(prb2, "Icon")
|
||
prb2:GetComponent("Image").sprite = this.spLoader:LoadSprite(isOpen == 0 and assistantLevleDiBg[1] or assistantLevleDiBg[2])
|
||
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)
|
||
Util.AddOnceClick(levelList[i], function()
|
||
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()
|
||
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)
|
||
elseif levelData.config.StageType == FIGHTLEVEL_STAGETYPE.AssistantLevel then--副关卡战斗
|
||
prb3:SetActive(true)
|
||
prb3:GetComponent("Image").sprite = this.spLoader:LoadSprite(isOpen == 0 and assistantLevleDiBg[1] or assistantLevleDiBg[2])
|
||
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)
|
||
Util.AddOnceClick(levelList[i], function()
|
||
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
|
||
end)
|
||
end
|
||
end
|
||
end
|
||
function this.SetlevelBox(_rewardBoxDatas)
|
||
this.totalPro.text = chapterData.stars.."/"..chapterData.curMaxStarNum
|
||
this.progressBottom.fillAmount=chapterData.stars/chapterData.curMaxStarNum
|
||
for i = 1, math.max(#_rewardBoxDatas, #boxList) do
|
||
local go = boxList[i]
|
||
if not go then
|
||
go = newObject(boxList[1])
|
||
go.transform:SetParent(this.rewardBoxParent.transform)
|
||
go.name = "BoxBtn"..i
|
||
go.transform.localScale = Vector3.one
|
||
go.transform.localPosition = Vector3.zero
|
||
boxList[i] = go
|
||
end
|
||
go.gameObject:SetActive(false)
|
||
end
|
||
for i, v in pairs(_rewardBoxDatas) do
|
||
boxList[i]:SetActive(true)
|
||
local missionConfigData = _rewardBoxDatas[i].config
|
||
boxList[i]:GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(missionConfigData.RewardIcon))
|
||
Util.GetGameObject(boxList[i], "num"):GetComponent("Text").text = missionConfigData.Star
|
||
Util.GetGameObject(boxList[i], "redPoint"):SetActive( _rewardBoxDatas[i].state == 0 and chapterData.stars > _rewardBoxDatas[i].config.Star)
|
||
-- 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)
|
||
Util.GetGameObject(boxList[i], "getFinish"):SetActive(false)
|
||
Util.GetGameObject(boxList[i], "redPoint"):SetActive(false)
|
||
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)
|
||
--自己刷新一下宝箱数据
|
||
FightLevelManager.SetChapterBoxRewardData(chapterData.chapterId,missionConfigData.Id,1)
|
||
CheckRedPointStatus(RedPointType.FightLevelBoxReward)
|
||
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop, 1,function()--isBackBattle true时 为回放不走回调
|
||
if chapterData.reward and LengthOfTable(chapterData.reward) > 0 then
|
||
this.SetlevelBox(chapterData.reward)
|
||
end
|
||
end)
|
||
end)
|
||
end)
|
||
else
|
||
Util.GetGameObject(boxList[i], "redPoint"):SetActive(false)
|
||
Util.AddOnceClick(boxList[i], function()
|
||
this.FindBoxRewardInfo(missionConfigData)
|
||
end)
|
||
end
|
||
elseif _rewardBoxDatas[i].state == 1 then
|
||
Util.GetGameObject(boxList[i], "getFinish"):SetActive(true)
|
||
Util.AddOnceClick(boxList[i], function()
|
||
this.FindBoxRewardInfo(missionConfigData)
|
||
end)
|
||
end
|
||
|
||
end
|
||
end
|
||
|
||
--左右按钮
|
||
function this.LeftOrRightBtnClickEvent(index)
|
||
--index 为空时 刷新下左右按钮的显示 下一章节未开启的时候不显示右按钮 相反
|
||
local upChapterId = chapterData.chapterId - 1
|
||
local upChapterData = FightLevelManager.GetChapterData(upChapterId)
|
||
local canLeft = true
|
||
if upChapterData and upChapterId <= FightLevelManager.GetCurChapterId() then
|
||
this.leftBtn:SetActive(true)
|
||
else
|
||
canLeft = false
|
||
this.leftBtn:SetActive(false)
|
||
end
|
||
|
||
local downChapterId = chapterData.chapterId + 1
|
||
local downChapterData = FightLevelManager.GetChapterData(downChapterId)
|
||
|
||
local canRight = true
|
||
if downChapterData and downChapterId <= FightLevelManager.GetCurChapterId() then
|
||
this.rightBtn:SetActive(true)
|
||
else
|
||
canRight = false
|
||
this.rightBtn:SetActive(false)
|
||
end
|
||
if index and index == 1 and canLeft then--左
|
||
chapterId = upChapterId
|
||
chapterData = upChapterData
|
||
FightLevelManager.curSelect = FightLevelManager.curSelect - 1
|
||
this.OnShowPanel()
|
||
this.LeftOrRightBtnClickEvent()
|
||
elseif index and index == 2 and canRight then--右
|
||
chapterId = downChapterId
|
||
chapterData = downChapterData
|
||
FightLevelManager.curSelect = FightLevelManager.curSelect + 1
|
||
this.OnShowPanel()
|
||
this.LeftOrRightBtnClickEvent()
|
||
end
|
||
end
|
||
|
||
function this.GetCurLevelIsOpen(levelDatas)
|
||
if levelDatas.config.LevelLimit == -1 then
|
||
return -1
|
||
end
|
||
if levelDatas.nodeId > FightLevelManager.GetCurChapterLevelId() then
|
||
--特殊判断 分主关卡和副关卡
|
||
local upMainLevelConfig = FightLevelManager.GetChapterLevelData(levelDatas.config.Chapter,levelDatas.config.NextLevel)
|
||
if not upMainLevelConfig.isPass then
|
||
return 1
|
||
end
|
||
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
|
||
--界面关闭时调用(用于子类重写)
|
||
function FightLevelSingleChapterPanel:OnClose()
|
||
if this.activityBtnTime then
|
||
this.activityBtnTime:Stop()
|
||
this.activityBtnTime = nil
|
||
end
|
||
end
|
||
|
||
--界面销毁时调用(用于子类重写)
|
||
function FightLevelSingleChapterPanel:OnDestroy()
|
||
allMissionDailyBoxItemPres = {}
|
||
this.spLoader:Destroy()
|
||
SubUIManager.Close(this.UpView)
|
||
end
|
||
|
||
return FightLevelSingleChapterPanel |