require("Base/BasePanel") FightLevelChapterPanel = Inherit(BasePanel) local this = FightLevelChapterPanel local chapterConfig=ConfigManager.GetConfig(ConfigName.HardStageChapter) local orginLayer local curChapterId = 0 local npc --初始化组件(用于子类重写) function FightLevelChapterPanel:InitComponent() this.spLoader = SpriteLoader.New() self.btnBack = Util.GetGameObject(self.gameObject, "btnBack") -- this.hintTxt = Util.GetGameObject(self.gameObject, "hintTxt"):GetComponent("Text") -- this.maxTxt = Util.GetGameObject(self.gameObject, "maxTxt2"):GetComponent("Text") -- this.maxTxt.gameObject:SetActive(true) 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 -- 奖励按钮 self.rewardBtn = Util.GetGameObject(self.gameObject, "rewardBtn") self.rewardRedPot = Util.GetGameObject(self.gameObject, "rewardBtn/red") self.rewardTai = Util.GetGameObject(self.gameObject, "rewardBtn/Tai"):GetComponent("Image") self.rewardTextBg = Util.GetGameObject(self.gameObject, "rewardBtn/TextBg"):GetComponent("Image") self.rewardTip = Util.GetGameObject(self.gameObject, "rewardBtn/Text"):GetComponent("Text") 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") end --绑定事件(用于子类重写) function FightLevelChapterPanel:BindEvent() Util.AddClick(self.btnBack, function() FightLevelManager.curSelect = 0 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) Util.AddClick(self.rewardBtn, function() local data = FightLevelManager.GetDailyRewardData() if not data then PopupTipPanel.ShowTip("今日已领取,请明日再来!") return end UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.BuyShanHeSheJiTuGetRewardTimes,function() -- 请求领取奖励 self.rewardKeKaiQi:SetActive(false) self.rewardOpen:SetActive(false) self.rewardKaiQi:SetActive(false) self.rewardKaiQi:SetActive(false) end) 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) end function FightLevelChapterPanel:OnSortingOrderChange() Util.SetParticleSortLayer(self.rewardKaiQi, self.sortingOrder + 1) Util.SetParticleSortLayer(self.rewardKeKaiQi, self.sortingOrder + 1) 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) PlayerPrefs.SetInt(PlayerManager.uid.."openFightLevelTime",1) this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main }) -- SoundManager.PlayMusic(SoundConfig.BGM_Main) end --界面打开或者重新打开后,界面刷新时调用(用于子类重写) function FightLevelChapterPanel:OnShow() this.OnShowPanel() end function this.OnShowPanel() local curTime=GetTimeStamp() local hint local maxChapterId=4 local day=-1 local allChapterId=0 for _, config in ConfigPairs(chapterConfig) do if curTime>PlayerManager.GetServerOpenTime()+config.OpenTime*24*60*60 then hint=config.OpenNumber --if maxChapterId==0 then if day~=config.OpenTime-1 then day=config.OpenTime-1 maxChapterId=config.Id end --maxChapterId=config.Id --end end allChapterId=config.Id end --this.hintTxt.text=hint SoundManager.PlayMusic(SoundConfig.BGM_Main) this.starNumText.text = FightLevelManager.GetAllChapterStars() curChapterId = FightLevelManager.GetCurChapterId() LogError("curChapterId========="..curChapterId.." maxChapterId=="..maxChapterId) -- this.maxTxt.gameObject:SetActive(false) -- if curChapterId==maxChapterId then -- LogError("11111111111111111111111111111111111111") -- this.maxTxt.gameObject:SetActive(true) -- this.maxTxt.text="今日已达上限,关卡将与次日开启" -- end -- if curChapterId==allChapterId then -- this.maxTxt.gameObject:SetActive(true) -- this.maxTxt.text="已达最终关卡" -- end local allData = FightLevelManager.GetChapterData() this.ScrollView:SetData(allData, function (index, go) this.SingleChapterDataShow(go, allData[index],index) end,true,true) if FightLevelManager.curSelect > 0 then this.ScrollView:SetShow(FightLevelManager.curSelect) else local curIndex = FightLevelManager.GetCurChapterId() this.ScrollView:SetShow(curIndex) end -- 设置每日奖励显示 this:SetDailyRewardShow() end function this.SingleChapterDataShow(go, data,index) 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(false) end local curTime=GetTimeStamp() local isTimeOpen= curTime>=PlayerManager.GetServerOpenTime()+data.config.OpenTime*24*60*60 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) 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 end if curChapterId == data.chapterId then playerParent.gameObject:SetActive(false) else playerParent.gameObject:SetActive(false) end cur:SetActive(false) open:SetActive(false) lock:SetActive(false) 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 PopupTipPanel.ShowTip(string.format("到达%s级后解锁!",data.config.Open)) return end if not isTimeOpen then PopupTipPanel.ShowTip(string.format("开服%s天后解锁!",data.config.OpenTime)) return end if curChapterId >= data.chapterId then UIManager.OpenPanel(UIName.FightLevelSingleChapterPanel,data.chapterId) FightLevelManager.curSelect = index elseif curChapterId < data.chapterId then PopupTipPanel.ShowTip("通关上一章后解锁!") end end) end -- 设置日常奖励显示 function FightLevelChapterPanel:SetDailyRewardShow() local data = FightLevelManager.GetDailyRewardData() if data then self.rewardTip.text = string.format("%s", UIColorStr.GREEN, "可领取") self.rewardKaiQi:SetActive(false) self.rewardKeKaiQi:SetActive(false) self.rewardOpen:SetActive(false) self.rewardTai.sprite = this.spLoader:LoadSprite("s_shanhe_xiaoditu_zhongbiao") -- self.rewardTextBg.sprite = this.spLoader:LoadSprite("s_shanhe_xiaoditu_biaoxiamingzidi") else self.rewardTip.text = string.format("%s", 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") end end --界面关闭时调用(用于子类重写) function FightLevelChapterPanel:OnClose() FightLevelManager.curSelect = 0 end --界面销毁时调用(用于子类重写) function FightLevelChapterPanel:OnDestroy() if npc then npc:OnClose() end SubUIManager.Close(this.UpView) this.spLoader:Destroy() end return FightLevelChapterPanel