miduo_client/Assets/ManagedResources/~Lua/Modules/RatioNumber/RatioNumberLevelPanel.lua

851 lines
36 KiB
Lua

require("Base/BasePanel")
RatioNumberLevelPanel = Inherit(BasePanel)
local this = RatioNumberLevelPanel
local sortingOrder = 0
local boxList = {}
local levelList = {}
local SpecialConfig = ConfigManager.GetConfigData(ConfigName.SpecialConfig, 184)
local maxTime = tonumber(SpecialConfig.Value) * 60
local chapterId = 0
local chapterData = {}
local allMissionDailyBoxItemPres = {}
local mainLevleBg = { [1] = "s_shanhe_xiaoditu_dabiao", [2] = "s_shanhe_xiaoditu_dabiao_01" }
local LevleTitleBg = { [1] = "xiaoyouxi_gk_dc_bj_001", [2] = "xiaoyouxi_gk_dc_bj_002" }
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 mainPointList = nil
local allSmallPoint = nil
local tabList = nil
--初始化组件(用于子类重写)
function RatioNumberLevelPanel: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, "chapterBtn/rewardBg/btnList")
this.progressBottom = Util.GetGameObject(self.gameObject, "chapterBtn/rewardBg/progressBottom/Image"):GetComponent(
"Image")
for i = 1, 3 do
boxList[i] = Util.GetGameObject(self.gameObject, "chapterBtn/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[10798]
--无用小点显示
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.tabPre = Util.GetGameObject(self.gameObject, "chapterBtn/tabbox/tab")
this.box = Util.GetGameObject(self.gameObject, "chapterBtn/tabbox/box")
this.bgImg = Util.GetGameObject(self.gameObject, "bg"):GetComponent("Image")
this.titleImg = Util.GetGameObject(self.gameObject, "title"):GetComponent("Image")
this.btn_help = Util.GetGameObject(self.gameObject, "btn_help")
this.helpPosition = this.btn_help:GetComponent("RectTransform").localPosition
this.rewardList = {}
this.rewardItemPre = Util.GetGameObject(self.gameObject, "rewardContent/item")
this.rewardGrid = Util.GetGameObject(self.gameObject, "rewardContent")
this.rewardTxt = Util.GetGameObject(self.gameObject, "getBoxReward/time/Text"):GetComponent("Text")
this.rewardRed = Util.GetGameObject(self.gameObject, "getBoxReward/rewardBoxRedPoint")
this.btn_reward = Util.GetGameObject(self.gameObject, "getBoxReward")
end
--绑定事件(用于子类重写)
function RatioNumberLevelPanel:BindEvent()
Util.AddClick(this.btn_reward, function()
if RatioNumberManager.gameIndex == 1 then
PopupTipPanel.ShowTip(Language[11890])
return
end
LogError("GetTimeStamp()==" .. GetTimeStamp() .. " showTime==" .. RatioNumberManager.rewardStartTime)
if GetTimeStamp() - RatioNumberManager.rewardStartTime < 360 then
PopupTipPanel.ShowTip(Language[11891])
return
end
NetManager.CompareNumRewardRequest(function()
RatioNumberManager.rewardStartTime = GetTimeStamp()
this.GetBoxShowState(GetTimeStamp())
end)
end)
Util.AddOnceClick(self.btnBack, function()
self:ClosePanel()
UIManager.OpenPanel(UIName.CarbonsPanel)
end)
Util.AddOnceClick(this.btn_help, function()
UIManager.OpenPanel(UIName.HelpPopup, 131, this.helpPosition.x, this.helpPosition.y)
end)
-- Util.AddClick(this.leftBtnClick, function()
-- this.LeftOrRightBtnClickEvent(1)
-- end)
-- Util.AddClick(this.rightBtnClick, function()
-- this.LeftOrRightBtnClickEvent(2)
-- end)
Util.AddOnceClick(this.rewardMaskBtn, function()
this.rewardMaskBtn:SetActive(false)
end)
end
function RatioNumberLevelPanel: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 RatioNumberLevelPanel:OnOpen()
this.mask:SetActive(false)
-- SoundManager.PlaySound(SoundConfig.Sound_WorldMap)
-- this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main })
end
function this.IntiReward()
local rewardData
local config = ConfigManager.GetConfigData(ConfigName.CompareNumSetting, RatioNumberManager.gameIndex)
rewardData = config.Income
for i = 1, #rewardData do
if not this.rewardList[i] then
local go = {}
go.item = newObjToParent(this.rewardItemPre, this.rewardGrid)
go.icon = Util.GetGameObject(go.item, "iconBg/icon"):GetComponent("Image")
go.text = Util.GetGameObject(go.item, "rewardbg/context"):GetComponent("Text")
go.infoTxt = Util.GetGameObject(go.item, "rewardbg/rate"):GetComponent("Text")
--go.infoTxt.gameObject:SetActive(false)
this.rewardList[i] = go
end
this.rewardList[i].icon.sprite = SetIcon(this.spLoader, rewardData[i][1])
local addValue = 0 --FightPointPassManager.GetItemVipValue(rewardData[i][1])
local baseValue = rewardData[i][2]
this.rewardList[i].infoTxt.text = string.format(Language[12548], config.IncomeTime)
if addValue - 1 <= 0 then
this.rewardList[i].text.text = "+" .. rewardData[i][2] --..string.format(Language[12548],config.IncomeTime)
else
local valueShow = math.round((addValue - 1) * baseValue)
this.rewardList[i].text.text = string.format("+%s\n<color=#1CC853>(+%s)</color>", baseValue, valueShow)
end
end
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function RatioNumberLevelPanel:OnShow()
chapterId = RatioNumberManager.selectChapterId
--LogError("RatioNumberManager.levelId=="..RatioNumberManager.levelId)
-- SoundManager.PlayMusic(SoundChapterConfig[chapterId])
if mainPointList then
this.LevelShowHandle_UP()
else
mainPointList = {}
allSmallPoint = {}
this.LevelShowHandle()
end
if allSmallPoint then
this.UselessPointHandle_Up()
end
if tabList then
this.MenuBtnShowUp()
else
tabList = {}
this.MenuBtnShow()
end
this.SetlevelBox()
this.ChapterBgInfoUp()
-- this.OnShowPanel()
-- this.LeftOrRightBtnClickEvent()
this.rewardMaskBtn:SetActive(false)
this.IntiReward()
LogError("RatioNumberManager.rewardStartTime==" .. RatioNumberManager.rewardStartTime)
local showTime = RatioNumberManager.rewardStartTime
this.GetBoxShowState(showTime)
end
function this.GetBoxShowState(hangupTime)
LogError("挂机时长 hangupTime " .. hangupTime)
if RatioNumberManager.gameIndex == 0 then
this.rewardTxt.text = TimeToHM(0)
return 0
end
local state = 0
local curTime = GetTimeStamp()
LogError("curTime==========" .. curTime .. " hangupTime== " .. hangupTime)
if hangupTime > 0 then
local addTime = curTime - hangupTime
if addTime > maxTime then
hangupTime = maxTime
else
hangupTime = addTime
end
end
LogError("hangupTime===========================" .. hangupTime)
if hangupTime < AdventureManager.adventureRefresh then
state = 0
elseif hangupTime >= AdventureManager.adventureRefresh and hangupTime < AdventureManager.adventureBoxShow[1] then
state = 1
elseif hangupTime >= AdventureManager.adventureRefresh and hangupTime < AdventureManager.adventureBoxShow[2] then
state = 2
else
state = 3
end
if hangupTime < 0 then
hangupTime = 0
end
this.rewardTxt.text = TimeToHM(hangupTime)
return state
end
--1---------------------------------
function this.LevelShowHandle()
local chapter = RatioNumberLevelManager.GetChapterInfo(chapterId)
local levelInfo = chapter.levelInfo
for i = 1, #levelInfo do
local config = levelInfo[i]
local LevelPointPosition = config.LevelPointPosition
local lock = { levelLimit = config.LevelLimit, passReward = config.PassReward }
local UselessPoint = config.UselessPoint
this.LevelPointHandle(LevelPointPosition, lock, i)
if UselessPoint[1][1] ~= 0 then
this.UselessPointHandle(UselessPoint, i)
end
end
end
function this.LevelPointHandle(pos, lock, index)
local pre = newObject(this.prb)
pre.transform:SetParent(this.rect.transform)
pre.transform.localScale = Vector2.one
pre.transform.localPosition = Vector2.New(pos[1], pos[2])
pre.name = index
mainPointList[index] = { pre = pre, lock = lock, state = 1, tip = "" }
this.SetPreStats(index, lock)
Util.AddOnceClick(pre, function()
this.PreClickEvent(index)
end)
end
function this.SetPreStats(index)
local preTab = mainPointList[index]
local lock = preTab.lock
local pre = preTab.pre
local prb1 = Util.GetGameObject(pre, "prb1")
local prb2 = Util.GetGameObject(pre, "prb2")
local prb3 = Util.GetGameObject(pre, "prb3")
local js = Util.GetGameObject(pre, "js"):GetComponent("Text")
local nameBg = Util.GetGameObject(prb1, "nameBg"):GetComponent("Image")
local levelName = Util.GetGameObject(nameBg.gameObject, "levelName"):GetComponent("Text")
prb2:SetActive(false)
prb3:SetActive(false)
local bxIcon = Util.GetGameObject(prb2, "Icon")
local kkq = Util.GetGameObject(prb2, "kkq")
kkq:SetActive(false)
-- local lq = Util.GetGameObject(prb2,"lq")
-- lq:SetActive(false)
bxIcon:SetActive(true)
js.gameObject:SetActive(false)
levelName.text = index
preTab.state = 1
if chapterId >= RatioNumberManager.chapterId then
if index >= RatioNumberManager.levelId then
for i = 1, #lock.levelLimit do
local tj = lock.levelLimit[i]
if tj[1] == 1 then
if PlayerManager.level < tj[2] then
js.text = tj[2] .. Language[12549]
preTab.state = 2
preTab.tip = js.text
js.gameObject:SetActive(true)
break
end
elseif tj[1] == 2 then
if not FightPointPassManager.IsFightPointPass(tj[2]) then
local gk = GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.MainLevelConfig, tj[2]).Name)
js.text = Language[12550] .. gk .. Language[12551]
preTab.state = 2
js.gameObject:SetActive(true)
preTab.tip = js.text
break
end
end
end
if index > RatioNumberManager.levelId and preTab.state ~= 2 then
preTab.state = 2
preTab.tip = Language[12552]
end
end
if preTab.state == 1 then
if index == RatioNumberManager.levelId then
prb2:SetActive(true)
kkq:SetActive(true)
bxIcon:SetActive(false)
prb3:SetActive(true)
end
end
end
nameBg.sprite = this.spLoader:LoadSprite(LevleTitleBg[preTab.state])
end
function this.PreClickEvent(index)
local preTab = mainPointList[index]
if preTab.state == 2 then
PopupTipPanel.ShowTip(preTab.tip)
Log("未开启:" .. preTab.tip)
else
Log("进入" .. RatioNumberManager.chapterId .. "" .. index .. "")
RatioNumberManager.selectLevelId = index
RatioNumberManager.RestartGame()
UIManager.OpenPanel(UIName.RatioNumberGamePanel)
end
end
function this.UselessPointHandle(posArr, index)
local pointList = {}
local showMod = 2
if chapterId < RatioNumberManager.chapterId then
showMod = 1
elseif chapterId == RatioNumberManager.chapterId and index <= RatioNumberManager.levelId then
showMod = 1
end
for i = 1, #posArr do
local pos = posArr[i]
local pointPre = newObject(this.pointPre)
local img = pointPre:GetComponent("Image")
pointPre.transform:SetParent(this.rect.transform)
pointPre.transform.localScale = Vector2.one
pointPre.transform.localPosition = Vector2.New(pos[1], pos[2])
pointPre.name = index .. "_" .. i
img.sprite = this.spLoader:LoadSprite(point[showMod])
table.insert(pointList, pointPre)
end
allSmallPoint[index] = pointList
end
function this.UselessPointHandle_Up()
for i = 2, #allSmallPoint do
local showMod = 2
if chapterId < RatioNumberManager.chapterId then
showMod = 1
elseif chapterId == RatioNumberManager.chapterId and i <= RatioNumberManager.levelId then
showMod = 1
end
local pointArr = allSmallPoint[i]
for j = 1, #pointArr do
local pointPre = pointArr[j]
local img = pointPre:GetComponent("Image")
img.sprite = this.spLoader:LoadSprite(point[showMod])
end
end
end
--2-----------------------------------------
function this.MenuBtnShow()
local chapterData = RatioNumberLevelManager.GetAllChapterInfo()
for i = 1, #chapterData do
local chapter = chapterData[i]
local tab = newObject(this.tabPre)
tab.transform:SetParent(this.box.transform)
tab.transform.localScale = Vector2.one
tab.transform.localPosition = Vector3.New(tab.transform.localPosition.x, tab.transform.localPosition.y, 0)
tab.name = "tab_" .. i
tabList[i] = { tab = tab, chapter = chapter, state = 1, tip = "" }
this.SetBtnInfo(i)
Util.AddOnceClick(tab, function()
this.TabClickEvent(i)
end)
end
end
function this.MenuBtnShowUp()
for i = 1, #tabList do
this.SetBtnInfo(i)
end
end
function this.SetBtnInfo(index)
local btninfo = tabList[index]
local limit = btninfo.chapter.Limit
local resourceIconID = btninfo.chapter.ResourceIconID
local btn = btninfo.tab
local img = btn:GetComponent("Image")
local lock = Util.GetGameObject(btn, "lock")
local stateImgStr = ConfigManager.GetConfigData(ConfigName.ArtResourcesConfig, resourceIconID[3]).Name
if index == chapterId then
stateImgStr = ConfigManager.GetConfigData(ConfigName.ArtResourcesConfig, resourceIconID[4]).Name
end
btninfo.state = 1
img.sprite = this.spLoader:LoadSprite(stateImgStr)
lock:SetActive(false)
if RatioNumberManager.chapterId > index then
lock:SetActive(false)
elseif RatioNumberManager.chapterId <= index then
for i = 1, #limit do
local tj = limit[i]
if tj[1] == 1 then
if PlayerManager.level < tj[2] then
btninfo.state = 2
btninfo.tip = Language[10352] .. tj[2] .. Language[10777]
lock:SetActive(true)
break
end
elseif tj[1] == 2 then
if not FightPointPassManager.IsFightPointPass(tj[2]) then
local gk = ConfigManager.GetConfigData(ConfigName.MainLevelConfig, tj[2]).Name
btninfo.tip = Language[10352] .. gk .. Language[10777]
btninfo.state = 2
lock:SetActive(true)
break
end
end
end
if RatioNumberManager.chapterId < index and btninfo.state == 1 then
btninfo.state = 2
btninfo.tip = Language[12553]
lock:SetActive(true)
end
end
end
function this.TabClickEvent(index)
local btninfo = tabList[index]
if btninfo.state == 1 then
Log("Click Chapter:" .. index)
chapterId = index
RatioNumberManager.selectChapterId = index
this.TabClickHandle(index)
this.LevelShowHandle_UP()
this.UselessPointHandle_Up()
this.SetlevelBox()
this.ChapterBgInfoUp()
Log("切换:" .. index)
else
Log("未开启:" .. btninfo.tip)
PopupTipPanel.ShowTip(btninfo.tip)
end
end
function this.TabClickHandle(index)
for i = 1, #tabList do
local btninfo = tabList[i]
local resourceIconID = btninfo.chapter.ResourceIconID
local btn = btninfo.tab
local img = btn:GetComponent("Image")
local stateImgStr_1 = ConfigManager.GetConfigData(ConfigName.ArtResourcesConfig, resourceIconID[3]).Name
local stateImgStr_2 = ConfigManager.GetConfigData(ConfigName.ArtResourcesConfig, resourceIconID[4]).Name
if i == index then
img.sprite = this.spLoader:LoadSprite(stateImgStr_2)
else
img.sprite = this.spLoader:LoadSprite(stateImgStr_1)
end
end
end
function this.LevelShowHandle_UP()
local chapter = RatioNumberLevelManager.GetChapterInfo(chapterId)
local levelInfo = chapter.levelInfo
for i = 1, #levelInfo do
local config = levelInfo[i]
local mainPoint = mainPointList[i]
local lock = { levelLimit = config.LevelLimit, passReward = config.PassReward }
mainPoint.lock = lock
local UselessPoint = config.UselessPoint
this.SetPreStats(i)
-- this.UselessPointHandle(UselessPoint,i)
end
end
function this.ChapterBgInfoUp()
local chapter = tabList[chapterId].chapter
local titleStr = ConfigManager.GetConfigData(ConfigName.ArtResourcesConfig, chapter.ResourceIconID[1]).Name
local bgStr = ConfigManager.GetConfigData(ConfigName.ArtResourcesConfig, chapter.ResourceIconID[2]).Name
this.titleImg.sprite = this.spLoader:LoadSprite(titleStr)
this.bgImg.sprite = this.spLoader:LoadSprite(bgStr)
end
function this.OnShowPanel()
SoundManager.PlayMusic(SoundConfig.BGM_Main)
chapterData = RatioNumberLevelManager.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("<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(RatioNumberLevelManager.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(Language[12554])
elseif isOpen == 1 then
PopupTipPanel.ShowTip(Language[10800]) --(Language[10800])
elseif isOpen == 2 then
PopupTipPanel.ShowTip(string.format(Language[12555], levelDatas[i].config.LevelLimit) ..
Language[12556])
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()
RatioNumberLevelManager.FightLevelFightBattle(levelData, function()
this.OnShowPanel()
this.LeftOrRightBtnClickEvent()
this.mask:SetActive(false)
end)
end, 1, 1, true):Start()
elseif levelData.state == 1 then
PopupTipPanel.ShowTip(Language[10801]) --(Language[10801])
end
elseif isOpen == -1 then
PopupTipPanel.ShowTip(Language[12554])
elseif isOpen == 1 then
PopupTipPanel.ShowTip(Language[10800]) --(Language[10800])
elseif isOpen == 2 then
PopupTipPanel.ShowTip(string.format(Language[12555], levelDatas[i].config.LevelLimit) ..
Language[12556])
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(Language[12554])
elseif isOpen == 1 then
PopupTipPanel.ShowTip(Language[10800]) --(Language[10800])
elseif isOpen == 2 then
PopupTipPanel.ShowTip(string.format(Language[12555], levelDatas[i].config.LevelLimit) ..
Language[12556])
end
end)
end
end
end
function this.SetlevelBox()
if RatioNumberManager.selectChapterId < RatioNumberManager.chapterId or (RatioNumberManager.selectChapterId == RatioNumberLevelManager.chapterCount and RatioNumberManager.levelId >= 15) then
this.totalPro.text = "16/16"
this.progressBottom.fillAmount = 1
elseif RatioNumberManager.selectChapterId == RatioNumberManager.chapterId then
-- body
this.totalPro.text = (RatioNumberManager.levelId - 1) .. "/16"
this.progressBottom.fillAmount = (RatioNumberManager.levelId - 1) / 16
end
for i = 1, 3 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
local reward = RatioNumberLevelManager.GetChapterReward()
local curRardId = RatioNumberManager.chapterId * 1000 + RatioNumberManager.levelId - 1
--LogError("RatioNumberManager.chapterId=="..RatioNumberManager.chapterId.." RatioNumberManager.levelId== "..RatioNumberManager.levelId)
for i = 1, 3 do
local rewardArr = reward[i]
local rewardID = rewardArr[2]
--LogError("RatioNumberManager.selectChapterId=="..RatioNumberManager.selectChapterId)
local index = RatioNumberManager.selectChapterId * 1000 + rewardArr[1]
local rewardState = RatioNumberManager.GetRewardState(index)
--LogError("index=="..index.." rewardState=="..tostring(rewardState).." currewardID=="..curRardId)
boxList[i]:SetActive(true)
Util.GetGameObject(boxList[i], "getFinish"):SetActive(rewardState)
Util.GetGameObject(boxList[i], "redPoint"):SetActive(curRardId >= index and not rewardState)
Util.AddOnceClick(boxList[i], function()
this.FindBoxRewardInfo(rewardID, rewardArr[1])
local rewardState = RatioNumberManager.GetRewardState(index)
Log("NetManager.CompareNumBonusRequest")
if curRardId >= index and not rewardState then
NetManager.CompareNumBonusRequest(index, function(msg)
UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1, function()
Util.GetGameObject(boxList[i], "getFinish"):SetActive(true)
Util.GetGameObject(boxList[i], "redPoint"):SetActive(false)
end)
end)
end
end)
end
end
--左右按钮
function this.LeftOrRightBtnClickEvent(index)
--index 为空时 刷新下左右按钮的显示 下一章节未开启的时候不显示右按钮 相反
local upChapterId = chapterData.chapterId - 1
local upChapterData = RatioNumberLevelManager.GetChapterData(upChapterId)
local canLeft = true
if upChapterData and upChapterId <= RatioNumberLevelManager.GetCurChapterId() then
this.leftBtn:SetActive(true)
else
canLeft = false
this.leftBtn:SetActive(false)
end
local downChapterId = chapterData.chapterId + 1
local downChapterData = RatioNumberLevelManager.GetChapterData(downChapterId)
local canRight = true
if downChapterData and downChapterId <= RatioNumberLevelManager.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
this.OnShowPanel()
this.LeftOrRightBtnClickEvent()
elseif index and index == 2 and canRight then --右
chapterId = downChapterId
chapterData = downChapterData
this.OnShowPanel()
this.LeftOrRightBtnClickEvent()
end
end
function this.GetCurLevelIsOpen(levelDatas)
if levelDatas.config.LevelLimit == -1 then
return -1
end
if levelDatas.nodeId > RatioNumberLevelManager.GetCurChapterLevelId() then
--特殊判断 分主关卡和副关卡
local upMainLevelConfig = RatioNumberLevelManager.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(rewardID, star)
this.RewardPanelGetInfo.text = string.format(Language[12557], star)
local showItem = ConfigManager.GetConfigData(ConfigName.RewardGroup, rewardID)
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 RatioNumberLevelPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function RatioNumberLevelPanel:OnDestroy()
allMissionDailyBoxItemPres = {}
mainPointList = nil
tabList = nil
allSmallPoint = nil
this.spLoader:Destroy()
-- SubUIManager.Close(this.UpView)
end
return RatioNumberLevelPanel