require("Base/BasePanel") FightLevelChapterPanel = Inherit(BasePanel) local this = FightLevelChapterPanel local orginLayer local curChapterId = 0 local npc --初始化组件(用于子类重写) function FightLevelChapterPanel:InitComponent() this.spLoader = SpriteLoader.New() self.btnBack = Util.GetGameObject(self.gameObject, "btnBack") self.sortBtn = Util.GetGameObject(self.gameObject, "sortBtn") self.helpBtn = Util.GetGameObject(self.gameObject, "helpBtn") self.helpPos = self.helpBtn:GetComponent("RectTransform").localPosition this.starNumText = Util.GetGameObject(self.gameObject, "rightUp/starNumText"):GetComponent("Text") this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft }) this.prb = Util.GetGameObject(self.gameObject, "middle/prb") this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(self.gameObject, "middle/rect").transform, this.prb, nil, Vector2.New(1080, 1865.8), 1, 1, Vector2.New(0,0)) 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() UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.FightLevel,self.helpPos.x,self.helpPos.y) end) Util.AddClick(self.sortBtn, function() UIManager.OpenPanel(UIName.RankingSingleListPanel,rankKingList[15],1) end) end function FightLevelChapterPanel:OnSortingOrderChange() orginLayer = self.sortingOrder end --界面打开时调用(用于子类重写) function FightLevelChapterPanel:OnOpen() -- LogYellow(bit.band(1,3)) -- LogYellow(bit.band(2,3)) -- LogYellow(bit.band(4,3)) -- SoundManager.PlaySound(SoundConfig.Sound_WorldMap) this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main }) -- SoundManager.PlayMusic(SoundConfig.BGM_Main) end --界面打开或者重新打开后,界面刷新时调用(用于子类重写) function FightLevelChapterPanel:OnShow() this.OnShowPanel() end function this.OnShowPanel() SoundManager.PlayMusic(SoundConfig.BGM_Main) this.starNumText.text = FightLevelManager.GetAllChapterStars() curChapterId = FightLevelManager.GetCurChapterId() local allData = FightLevelManager.GetChapterData() this.ScrollView:SetData(allData, function (index, go) this.SingleChapterDataShow(go, allData[index]) end,true,true) local curIndex = FightLevelManager.GetCurChapterId() 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") 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 Util.GetGameObject(go, "redPoint"):SetActive(FightLevelManager.GetSingleChapterRewardBoxRedPoint(data.chapterId)) if curChapterId == data.chapterId then if npc then npc:OnClose() npc = nil end local PlayerLiveViewData = { -- ride = PlayerManager.GetPlayerRide(), skin = PlayerManager.GetPlayerSkin(), sex = NameManager.roleSex, -- designation = PlayerManager.GetPlayerDesignation() } npc = PlayerLiveView:New(playerParent.transform,2, PlayerLiveViewData,this.sortingOrder) npc:OnOpen(GetPlayerRoleSingleConFig().Scale6,Vector3.New(0,0,0),WALK_DIR.IDLE_LEFT) end if curChapterId == data.chapterId then playerParent.gameObject:SetActive(true) else playerParent.gameObject:SetActive(false) end cur:SetActive(curChapterId == data.chapterId) open:SetActive(curChapterId > data.chapterId) lock:SetActive(curChapterId < data.chapterId) 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 Util.GetGameObject(go, "chapterImage"):GetComponent("Image").sprite = this.spLoader:LoadSprite(data.config.Map) Util.GetGameObject(go, "star/starNum"):GetComponent("Text").text = data.stars.."/"..data.curMaxStarNum 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) end --界面关闭时调用(用于子类重写) function FightLevelChapterPanel:OnClose() end --界面销毁时调用(用于子类重写) function FightLevelChapterPanel:OnDestroy() if npc then npc:OnClose() end SubUIManager.Close(this.UpView) this.spLoader:Destroy() end return FightLevelChapterPanel