2021-05-07 14:44:50 +08:00
|
|
|
|
require("Base/BasePanel")
|
|
|
|
|
FightLevelChapterPanel = Inherit(BasePanel)
|
|
|
|
|
local this = FightLevelChapterPanel
|
|
|
|
|
local orginLayer
|
2021-05-11 15:12:37 +08:00
|
|
|
|
local curChapterId = 0
|
|
|
|
|
local npc
|
2021-05-07 14:44:50 +08:00
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
function FightLevelChapterPanel: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")
|
|
|
|
|
self.sortBtn = Util.GetGameObject(self.gameObject, "sortBtn")
|
2021-05-14 15:03:48 +08:00
|
|
|
|
self.helpBtn = Util.GetGameObject(self.gameObject, "helpBtn")
|
2021-05-11 15:12:37 +08:00
|
|
|
|
self.helpPos = self.helpBtn:GetComponent("RectTransform").localPosition
|
2021-05-07 14:44:50 +08:00
|
|
|
|
this.starNumText = Util.GetGameObject(self.gameObject, "rightUp/starNumText"):GetComponent("Text")
|
|
|
|
|
|
2021-05-11 15:12:37 +08:00
|
|
|
|
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft })
|
2021-05-07 14:44:50 +08:00
|
|
|
|
this.prb = Util.GetGameObject(self.gameObject, "middle/prb")
|
2021-05-11 15:12:37 +08:00
|
|
|
|
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(self.gameObject, "middle/rect").transform,
|
2021-05-21 19:07:46 +08:00
|
|
|
|
this.prb, nil, Vector2.New(1080, 1865.8), 1, 1, Vector2.New(0,0))
|
2021-05-07 14:44:50 +08:00
|
|
|
|
this.ScrollView.moveTween.MomentumAmount = 1
|
|
|
|
|
this.ScrollView.moveTween.Strength = 1
|
2021-10-18 18:06:47 +08:00
|
|
|
|
|
|
|
|
|
-- 奖励按钮
|
|
|
|
|
self.rewardBtn = Util.GetGameObject(self.gameObject, "rewardBtn")
|
|
|
|
|
self.rewardRedPot = Util.GetGameObject(self.gameObject, "rewardBtn/red")
|
2021-10-19 18:01:50 +08:00
|
|
|
|
self.rewardTai = Util.GetGameObject(self.gameObject, "rewardBtn/Tai"):GetComponent("Image")
|
|
|
|
|
self.rewardTextBg = Util.GetGameObject(self.gameObject, "rewardBtn/TextBg"):GetComponent("Image")
|
2021-10-18 18:06:47 +08:00
|
|
|
|
self.rewardTip = Util.GetGameObject(self.gameObject, "rewardBtn/Text"):GetComponent("Text")
|
2021-10-19 18:01:50 +08:00
|
|
|
|
self.rewardKaiQi = Util.GetGameObject(self.gameObject, "rewardBtn/BoxBtn1/UI_Effect_BaoXiang_KaiQi")
|
|
|
|
|
self.rewardKeKaiQi = Util.GetGameObject(self.gameObject, "rewardBtn/BoxBtn1/UI_Effect_BaoXiang_KeKaiQi")
|
|
|
|
|
self.rewardOpen = Util.GetGameObject(self.gameObject, "rewardBtn/BoxBtn1/open")
|
2021-05-07 14:44:50 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
function FightLevelChapterPanel:BindEvent()
|
|
|
|
|
|
|
|
|
|
Util.AddClick(self.btnBack, function()
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(self.helpBtn, function()
|
2021-05-14 15:03:48 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.FightLevel,self.helpPos.x,self.helpPos.y)
|
2021-05-07 14:44:50 +08:00
|
|
|
|
end)
|
2021-05-13 09:56:11 +08:00
|
|
|
|
Util.AddClick(self.sortBtn, function()
|
|
|
|
|
UIManager.OpenPanel(UIName.RankingSingleListPanel,rankKingList[15],1)
|
|
|
|
|
end)
|
2021-10-18 18:06:47 +08:00
|
|
|
|
Util.AddClick(self.rewardBtn, function()
|
2021-10-19 18:01:50 +08:00
|
|
|
|
local data = FightLevelManager.GetDailyRewardData()
|
|
|
|
|
if not data.state or data.state ~= 0 then
|
|
|
|
|
PopupTipPanel.ShowTip("今日已领取,请明日再来!")
|
|
|
|
|
return
|
|
|
|
|
end
|
2021-10-18 18:06:47 +08:00
|
|
|
|
-- 请求领取奖励
|
2021-10-19 18:01:50 +08:00
|
|
|
|
self.rewardKeKaiQi:SetActive(false)
|
|
|
|
|
self.rewardOpen:SetActive(false)
|
|
|
|
|
self.rewardKaiQi:SetActive(false)
|
|
|
|
|
self.rewardKaiQi:SetActive(true)
|
|
|
|
|
Timer.New(function()
|
|
|
|
|
FightLevelManager.RequestGetDailyReward()
|
|
|
|
|
end, 1):Start()
|
2021-10-18 18:06:47 +08:00
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function FightLevelChapterPanel:AddListener()
|
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.FightLevel.DailyRewardStateChange, self.SetDailyRewardShow, self)
|
|
|
|
|
|
|
|
|
|
BindRedPointObject(RedPointType.FightLevelDailyReward, self.rewardRedPot)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function FightLevelChapterPanel:RemoveListener()
|
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.FightLevel.DailyRewardStateChange, self.SetDailyRewardShow, self)
|
|
|
|
|
|
|
|
|
|
ClearRedPointObject(RedPointType.FightLevelDailyReward, self.rewardRedPot)
|
2021-05-07 14:44:50 +08:00
|
|
|
|
end
|
|
|
|
|
function FightLevelChapterPanel:OnSortingOrderChange()
|
2021-10-19 18:01:50 +08:00
|
|
|
|
Util.SetParticleSortLayer(self.rewardKaiQi, self.sortingOrder + 1)
|
|
|
|
|
Util.SetParticleSortLayer(self.rewardKeKaiQi, self.sortingOrder + 1)
|
2021-05-07 14:44:50 +08:00
|
|
|
|
orginLayer = self.sortingOrder
|
|
|
|
|
end
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
|
function FightLevelChapterPanel:OnOpen()
|
2021-05-13 09:56:11 +08:00
|
|
|
|
-- LogYellow(bit.band(1,3))
|
|
|
|
|
-- LogYellow(bit.band(2,3))
|
|
|
|
|
-- LogYellow(bit.band(4,3))
|
2021-05-07 14:44:50 +08:00
|
|
|
|
-- SoundManager.PlaySound(SoundConfig.Sound_WorldMap)
|
2021-05-11 15:12:37 +08:00
|
|
|
|
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main })
|
2021-06-09 18:17:22 +08:00
|
|
|
|
-- SoundManager.PlayMusic(SoundConfig.BGM_Main)
|
2021-05-07 14:44:50 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
|
|
|
function FightLevelChapterPanel:OnShow()
|
|
|
|
|
this.OnShowPanel()
|
|
|
|
|
end
|
|
|
|
|
function this.OnShowPanel()
|
|
|
|
|
|
2021-06-09 18:17:22 +08:00
|
|
|
|
SoundManager.PlayMusic(SoundConfig.BGM_Main)
|
2021-05-11 15:12:37 +08:00
|
|
|
|
this.starNumText.text = FightLevelManager.GetAllChapterStars()
|
|
|
|
|
curChapterId = FightLevelManager.GetCurChapterId()
|
|
|
|
|
local allData = FightLevelManager.GetChapterData()
|
2021-05-07 14:44:50 +08:00
|
|
|
|
this.ScrollView:SetData(allData, function (index, go)
|
|
|
|
|
this.SingleChapterDataShow(go, allData[index])
|
2021-05-26 14:59:25 +08:00
|
|
|
|
end,true,true)
|
2021-05-11 15:12:37 +08:00
|
|
|
|
local curIndex = FightLevelManager.GetCurChapterId()
|
2021-05-07 14:44:50 +08:00
|
|
|
|
this.ScrollView:SetShow(curIndex)
|
2021-10-19 16:36:49 +08:00
|
|
|
|
|
|
|
|
|
-- 设置每日奖励显示
|
|
|
|
|
this:SetDailyRewardShow()
|
2021-05-07 14:44:50 +08:00
|
|
|
|
end
|
|
|
|
|
function this.SingleChapterDataShow(go, data)
|
|
|
|
|
|
|
|
|
|
local playerParent = Util.GetGameObject(go, "playerParent")
|
|
|
|
|
local cur = Util.GetGameObject(go, "cur")
|
|
|
|
|
local open = Util.GetGameObject(go, "open")
|
|
|
|
|
local lock = Util.GetGameObject(go, "lock")
|
2021-06-10 14:43:45 +08:00
|
|
|
|
local curIndexImageParent = Util.GetGameObject(go, "curIndexImageParent")
|
|
|
|
|
local curCurIndexImageList = {}
|
|
|
|
|
for i = 1, 3 do
|
|
|
|
|
curCurIndexImageList[i] = Util.GetGameObject(curIndexImageParent, "curIndexImage (" .. i .. ")")
|
|
|
|
|
curCurIndexImageList[i]:SetActive(#data.config.BigNumber == i)
|
|
|
|
|
end
|
2021-05-14 15:03:48 +08:00
|
|
|
|
Util.GetGameObject(go, "redPoint"):SetActive(FightLevelManager.GetSingleChapterRewardBoxRedPoint(data.chapterId))
|
2021-05-11 15:12:37 +08:00
|
|
|
|
if curChapterId == data.chapterId then
|
|
|
|
|
if npc then
|
|
|
|
|
npc:OnClose()
|
|
|
|
|
npc = nil
|
|
|
|
|
end
|
2021-05-26 14:59:25 +08:00
|
|
|
|
local PlayerLiveViewData = {
|
|
|
|
|
-- ride = PlayerManager.GetPlayerRide(),
|
|
|
|
|
skin = PlayerManager.GetPlayerSkin(),
|
|
|
|
|
sex = NameManager.roleSex,
|
|
|
|
|
-- designation = PlayerManager.GetPlayerDesignation()
|
|
|
|
|
}
|
|
|
|
|
npc = PlayerLiveView:New(playerParent.transform,2, PlayerLiveViewData,this.sortingOrder)
|
2021-10-19 19:03:02 +08:00
|
|
|
|
-- npc:OnOpen(GetPlayerRoleSingleConFig().Scale6,Vector3.New(0,0,0),WALK_DIR.IDLE_LEFT)
|
|
|
|
|
if data.userMount and data.userMount > 0 and data.userMount ~= PlayerRide.YUJIAN then
|
|
|
|
|
npc:OnOpen(GetPlayerRoleSingleConFig().Scale6,Vector3.New(0,0,0),WALK_DIR.IDLE_LEFT)
|
|
|
|
|
else
|
|
|
|
|
npc:OnOpen(GetPlayerRoleSingleConFig().Scale6,Vector3.New(0,0,0),WALK_DIR.IDLE_FRONT)
|
|
|
|
|
end
|
|
|
|
|
|
2021-05-11 15:12:37 +08:00
|
|
|
|
end
|
2021-05-26 20:47:41 +08:00
|
|
|
|
if curChapterId == data.chapterId then
|
|
|
|
|
playerParent.gameObject:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
playerParent.gameObject:SetActive(false)
|
|
|
|
|
end
|
2021-05-11 15:12:37 +08:00
|
|
|
|
cur:SetActive(curChapterId == data.chapterId)
|
|
|
|
|
open:SetActive(curChapterId > data.chapterId)
|
|
|
|
|
lock:SetActive(curChapterId < data.chapterId)
|
2021-06-10 14:43:45 +08:00
|
|
|
|
curIndexImageParent:SetActive(curChapterId >= data.chapterId)
|
|
|
|
|
if curCurIndexImageList[#data.config.BigNumber] then
|
|
|
|
|
for i = 1, #data.config.BigNumber do
|
|
|
|
|
Util.GetGameObject(curCurIndexImageList[#data.config.BigNumber], "curIndexImage (0" .. i .. ")"):GetComponent("Image").sprite = this.spLoader:LoadSprite(data.config.BigNumber[i])
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-05-19 15:06:02 +08:00
|
|
|
|
Util.GetGameObject(go, "chapterImage"):GetComponent("Image").sprite = this.spLoader:LoadSprite(data.config.Map)
|
2021-05-11 15:12:37 +08:00
|
|
|
|
Util.GetGameObject(go, "star/starNum"):GetComponent("Text").text = data.stars.."/"..data.curMaxStarNum
|
2021-05-19 17:36:43 +08:00
|
|
|
|
|
2021-05-11 15:12:37 +08:00
|
|
|
|
Util.GetGameObject(go, "chapterName"):GetComponent("Text").text = data.config.Name
|
|
|
|
|
Util.SetGray(go, curChapterId < data.chapterId)
|
|
|
|
|
Util.AddOnceClick(go, function()
|
|
|
|
|
if data.config.Open == -1 then
|
|
|
|
|
PopupTipPanel.ShowTip(Language[11131])
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if PlayerManager.level >= data.config.Open then
|
|
|
|
|
if curChapterId >= data.chapterId then
|
|
|
|
|
UIManager.OpenPanel(UIName.FightLevelSingleChapterPanel,data.chapterId)
|
|
|
|
|
elseif curChapterId < data.chapterId then
|
|
|
|
|
PopupTipPanel.ShowTip("通关上一章后解锁!")
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
PopupTipPanel.ShowTip(string.format("到达%s级后解锁!",data.config.Open))
|
|
|
|
|
end
|
|
|
|
|
end)
|
2021-05-07 14:44:50 +08:00
|
|
|
|
end
|
2021-10-18 18:06:47 +08:00
|
|
|
|
|
|
|
|
|
-- 设置日常奖励显示
|
|
|
|
|
function FightLevelChapterPanel:SetDailyRewardShow()
|
|
|
|
|
local data = FightLevelManager.GetDailyRewardData()
|
|
|
|
|
if data and data.state == 0 then
|
2021-10-19 18:01:50 +08:00
|
|
|
|
self.rewardTip.text = string.format("<color=%s>%s</color>", UIColorStr.GREEN, "可领取")
|
|
|
|
|
self.rewardKaiQi:SetActive(false)
|
|
|
|
|
self.rewardKeKaiQi:SetActive(true)
|
|
|
|
|
self.rewardOpen:SetActive(false)
|
|
|
|
|
self.rewardTai.sprite = this.spLoader:LoadSprite("s_shanhe_xiaoditu_zhongbiao")
|
|
|
|
|
self.rewardTextBg.sprite = this.spLoader:LoadSprite("s_shanhe_xiaoditu_biaoxiamingzidi")
|
2021-10-18 18:06:47 +08:00
|
|
|
|
else
|
2021-10-19 18:01:50 +08:00
|
|
|
|
self.rewardTip.text = string.format("<color=%s>%s</color>", UIColorStr.YELLOW, "明日刷新")
|
|
|
|
|
self.rewardKaiQi:SetActive(false)
|
|
|
|
|
self.rewardKeKaiQi:SetActive(false)
|
|
|
|
|
self.rewardOpen:SetActive(true)
|
|
|
|
|
self.rewardTai.sprite = this.spLoader:LoadSprite("s_shanhe_xiaoditu_zhongbiao_01")
|
|
|
|
|
self.rewardTextBg.sprite = this.spLoader:LoadSprite("s_shanhe_xiaoditu_biaoxiamingzidi_01")
|
2021-10-18 18:06:47 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-05-07 14:44:50 +08:00
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function FightLevelChapterPanel:OnClose()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function FightLevelChapterPanel:OnDestroy()
|
2021-05-11 15:12:37 +08:00
|
|
|
|
if npc then
|
|
|
|
|
npc:OnClose()
|
|
|
|
|
end
|
|
|
|
|
SubUIManager.Close(this.UpView)
|
2021-05-19 17:36:43 +08:00
|
|
|
|
this.spLoader:Destroy()
|
2021-05-07 14:44:50 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return FightLevelChapterPanel
|