miduo_client/Assets/ManagedResources/~Lua/Modules/FightLevel/FightLevelChapterPanel.lua

125 lines
5.2 KiB
Lua
Raw Normal View History

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
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-05-07 14:44:50 +08:00
end
function FightLevelChapterPanel:OnSortingOrderChange()
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-05-07 14:44:50 +08:00
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function FightLevelChapterPanel:OnShow()
this.OnShowPanel()
end
function this.OnShowPanel()
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)
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-05-11 15:12:37 +08:00
local curIndexImage = Util.GetGameObject(go, "curIndexImage")
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-05-11 15:12:37 +08:00
npc:OnOpen(GetPlayerRoleSingleConFig().Scale6,Vector3.New(0,0,0),WALK_DIR.IDLE_LEFT)
end
cur:SetActive(curChapterId == data.chapterId)
open:SetActive(curChapterId > data.chapterId)
lock:SetActive(curChapterId < data.chapterId)
curIndexImage:SetActive(curChapterId >= data.chapterId)
curIndexImage:GetComponent("Image").sprite = this.spLoader:LoadSprite(data.config.BigNumber)--self.spLoader:LoadSprite(GetResourcePath(data.config.BigNumber))
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
--界面关闭时调用(用于子类重写)
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