185 lines
8.5 KiB
Lua
185 lines
8.5 KiB
Lua
require("Base/BasePanel")
|
|
FightLevelSingleChapterPanel = Inherit(BasePanel)
|
|
local this = FightLevelSingleChapterPanel
|
|
local sortingOrder = 0
|
|
local boxList = {}
|
|
local levelList = {}
|
|
local chapterId = 0
|
|
local chapterData = {}
|
|
--初始化组件(用于子类重写)
|
|
function FightLevelSingleChapterPanel:InitComponent()
|
|
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("Image")
|
|
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")
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function FightLevelSingleChapterPanel:BindEvent()
|
|
|
|
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)
|
|
end
|
|
function FightLevelSingleChapterPanel:OnSortingOrderChange()
|
|
--特效层级重设
|
|
-- for i=1,#boxList do
|
|
-- Util.AddParticleSortLayer(boxList[i], sortingOrder)
|
|
-- end
|
|
sortingOrder = self.sortingOrder
|
|
end
|
|
--界面打开时调用(用于子类重写)
|
|
function FightLevelSingleChapterPanel:OnOpen(_chapterId)
|
|
chapterId = _chapterId
|
|
-- SoundManager.PlaySound(SoundConfig.Sound_WorldMap)
|
|
end
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
function FightLevelSingleChapterPanel:OnShow()
|
|
|
|
this.OnShowPanel()
|
|
end
|
|
function this.OnShowPanel()
|
|
chapterData = FightLevelManager.GetChapterData(chapterId)
|
|
this.chapterNameText.text = chapterData.config.Name
|
|
this.chapterNameImage.sprite = Util.LoadSprite(chapterData.config.BigNumber)
|
|
if chapterData.node and LengthOfTable(chapterData.node) > 0 then
|
|
this.SetSingleLevel(chapterData.node)
|
|
end
|
|
if chapterData.reward and LengthOfTable(chapterData.reward) > 0 then
|
|
this.SetlevelBox(chapterData.reward)
|
|
end
|
|
end
|
|
function this.SetSingleLevel(levelDatas)
|
|
for i = 1, math.max(#levelDatas, #levelList) 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, v in pairs(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")
|
|
prb1:SetActive(false)
|
|
prb2:SetActive(false)
|
|
Util.SetGray(prb1, levelDatas[i].nodeId > FightLevelManager.GetCurChapterLevelId())
|
|
Util.SetGray(prb2, levelDatas[i].nodeId > FightLevelManager.GetCurChapterLevelId())
|
|
-- levelList[i]:SetActive(not (levelDatas[i].nodeId > FightLevelManager.GetCurChapterLevelId()))
|
|
if levelData.config.StageType == FIGHTLEVEL_STAGETYPE.MainLevel then --主关卡
|
|
prb1:SetActive(true)
|
|
Util.GetGameObject(prb1, "nameBg/levelName"):GetComponent("Text").text = levelData.config.Name
|
|
for j = 1, 3 do
|
|
local curIndexStarGo = Util.GetGameObject(levelList[i], "prb1/star/star (" ..j.. ")")
|
|
curIndexStarGo:SetActive(FightLevelManager.GetCurLevelStarState(levelData.state,j))
|
|
end
|
|
Util.AddOnceClick(levelList[i], function()
|
|
LogYellow("关卡类型 1 主 2 副奖励 3 副战斗 "..levelData.config.StageType)
|
|
UIManager.OpenPanel(UIName.FightLevelSingleLevelInfoPopup,FIGHTLEVEL_POPUP_TYPE.MainLevel,levelData)
|
|
end)
|
|
elseif levelData.config.StageType == FIGHTLEVEL_STAGETYPE.AssistantLevelReward then--副关卡奖励
|
|
prb2:SetActive(true)
|
|
Util.AddOnceClick(levelList[i], function()
|
|
LogYellow("关卡类型 1 主 2 副奖励 3 副战斗 "..levelData.config.StageType)
|
|
FightLevelManager.FightLevelFightBattle(levelData, function()
|
|
|
|
end)
|
|
end)
|
|
elseif levelData.config.StageType == FIGHTLEVEL_STAGETYPE.AssistantLevel then--副关卡战斗
|
|
prb2:SetActive(true)
|
|
Util.AddOnceClick(levelList[i], function()
|
|
LogYellow("关卡类型 1 主 2 副奖励 3 副战斗 "..levelData.config.StageType)
|
|
UIManager.OpenPanel(UIName.FightLevelSingleLevelInfoPopup,FIGHTLEVEL_POPUP_TYPE.AssistantLevel,levelData)
|
|
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 = Util.LoadSprite(GetResourcePath(missionConfigData.config.RewardIcon))
|
|
Util.GetGameObject(boxList[i], "num"):GetComponent("Text").text = missionConfigData.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 missionConfigData.state == 0 then
|
|
Util.AddOnceClick(boxList[i], function()
|
|
FightLevelManager.GetHardStageChapterReward(chapterData.chapterId,missionConfigData.config.Id,function()
|
|
|
|
end)
|
|
end)
|
|
elseif missionConfigData.state == 0 and chapterData.stars >= missionConfigData.Star then
|
|
Util.GetGameObject(boxList[i], "redPoint"):SetActive(true)
|
|
elseif missionConfigData.state == 1 then
|
|
Util.GetGameObject(boxList[i], "getFinish"):SetActive(true)
|
|
end
|
|
|
|
end
|
|
end
|
|
|
|
--左右按钮
|
|
function this.LeftOrRightBtnClickEvent(index)
|
|
--index 为空时 刷新下左右按钮的显示 下一章节未开启的时候不显示右按钮 相反
|
|
|
|
if index and index == 1 then--左
|
|
|
|
elseif index and index == 2 then--右
|
|
|
|
end
|
|
end
|
|
--界面关闭时调用(用于子类重写)
|
|
function FightLevelSingleChapterPanel:OnClose()
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function FightLevelSingleChapterPanel:OnDestroy()
|
|
|
|
end
|
|
|
|
return FightLevelSingleChapterPanel |