require("Base/BasePanel") GuildCarDelayMainPanel = Inherit(BasePanel) local this = GuildCarDelayMainPanel local testLiveGO local curIndex = 1 local orginLayer local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig) local roleConfig = ConfigManager.GetConfig(ConfigName.RoleConfig) local curMonsterId = 1 local curProgress = -1 local curMonsterIdConFig = {} local TabBox = require("Modules/Common/TabBox") local _TabData={ [1] = { default = "UI_hz_zhonghe01_83", select = "UI_hz_zhonghe01_82", name = Language[11006] }, [2] = { default = "UI_hz_zhonghe01_83", select = "UI_hz_zhonghe01_82", name = Language[11007] }, } local _TabFontColor = { default = Color.New(255 / 255, 255 / 255, 255 / 255, 1), select = Color.New(0 / 255, 0 / 255, 0 / 255, 1)} this.timer = Timer.New() local challengeNum = 0 local lootNum = 0 local isPlayAnim = true local bossNum = 0 local isCanFigth=false --初始化组件(用于子类重写) function GuildCarDelayMainPanel:InitComponent() this.spLoader = SpriteLoader.New() this.live2dRoot = Util.GetGameObject(self.gameObject, "live2dRoot") this.name = Util.GetGameObject(self.gameObject, "Image/nameAndTime/content/name"):GetComponent("Text") this.proImage = Util.GetGameObject(self.gameObject, "Image/nameAndTime/content/Image/proImage"):GetComponent("Image") this.timeText = Util.GetGameObject(self.gameObject, "Image/nameAndTime/timeGo/timeText"):GetComponent("Text") this.timeText2 = Util.GetGameObject(self.gameObject, "Image/nameAndTime/timeGo/timeText (1)"):GetComponent("Text") this.timeNumText = Util.GetGameObject(self.gameObject, "Image/nameAndTime/timeGo/timeNumText"):GetComponent("Text") this.timeTextGo = Util.GetGameObject(self.gameObject, "Image/nameAndTime/timeGo") this.BackBtn = Util.GetGameObject(self.gameObject, "BackBtn") this.rewardSortBtn = Util.GetGameObject(self.gameObject, "rewardSortBtn") this.lootRecordBtn = Util.GetGameObject(self.gameObject, "lootRecordBtn") this.lootRecordBtn:SetActive(false) this.HelpBtn = Util.GetGameObject(self.gameObject, "HelpBtn") this.helpPosition=this.HelpBtn:GetComponent("RectTransform").localPosition this.challengeBtn = Util.GetGameObject(self.gameObject, "challengeBtn") this.challengeNum = Util.GetGameObject(self.gameObject, "challengeBtn/num"):GetComponent("Text") this.challengeCDTimeNum = Util.GetGameObject(self.gameObject, "challengeBtn/timeNum/num"):GetComponent("Text") this.challengeCDTimeNumGo = Util.GetGameObject(self.gameObject, "challengeBtn/timeNum") this.lootBtn = Util.GetGameObject(self.gameObject, "lootBtn") this.lootNum = Util.GetGameObject(self.gameObject, "lootBtn/num"):GetComponent("Text") this.lootCDTimeNum = Util.GetGameObject(self.gameObject, "lootBtn/timeNum/num"):GetComponent("Text") this.lootCDTimeNumGo = Util.GetGameObject(self.gameObject, "lootBtn/timeNum") this.lootBtn:SetActive(false) this.tabBox = Util.GetGameObject(self.gameObject, "TabBox") this.TabCtrl = TabBox.New() this.ScrollTitleRootName = Util.GetGameObject(self.gameObject, "RankList/ScrollTitleRoot/Name"):GetComponent("Text") this.mySortNum = Util.GetGameObject(self.gameObject, "RankList/Record/SortNum") this.myGuildName = Util.GetGameObject(self.gameObject, "RankList/Record/Rank0"):GetComponent("Text") this.mySore = Util.GetGameObject(self.gameObject, "RankList/Record/Rank1"):GetComponent("Text") this.RankListPre = Util.GetGameObject(self.gameObject, "RankList/ItemPre") local v2 = Util.GetGameObject(self.gameObject, "RankList/ScrollParentView"):GetComponent("RectTransform").rect this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(self.gameObject, "RankList/ScrollParentView").transform, this.RankListPre, nil, Vector2.New(-v2.x*2, -v2.y*2), 1, 1, Vector2.New(50,8)) this.ScrollView.moveTween.MomentumAmount = 1 this.ScrollView.moveTween.Strength = 1 end --绑定事件(用于子类重写) function GuildCarDelayMainPanel:BindEvent() Util.AddOnceClick(this.BackBtn, function() this:ClosePanel() end) --奖励排行 Util.AddOnceClick(this.rewardSortBtn, function() UIManager.OpenPanel(UIName.GuildCarDelayRewardSortPopup) end) --抢夺记录 Util.AddOnceClick(this.lootRecordBtn, function() NetManager.CarGrapRecordResponse(function (msg) --for i = 1, #msg.carChallengeItem do -- LogError("content "..msg.carChallengeItem[i].content) --end UIManager.OpenPanel(UIName.GuildCarDelayLootRecordPopup,msg) end) end) --挑战 Util.AddOnceClick(this.challengeBtn, function() if isCanFigth==false then return end if curProgress ~= 1 then PopupTipPanel.ShowTip(Language[11008]) return end if challengeNum <= 0 then PopupTipPanel.ShowTip(Language[11009]) return end if GuildCarDelayManager.ChallengeCdTime > 0 then PopupTipPanel.ShowTip(this.TimeStampToDateString2(GuildCarDelayManager.ChallengeCdTime) .. Language[11010]) return end if curProgress == 1 then UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.GUILD_CAR_DELEAY,function () CheckRedPointStatus(RedPointType.LegendExplore) end) end end) --抢夺 Util.AddOnceClick(this.lootBtn, function() if curProgress ~= 3 then PopupTipPanel.ShowTip(Language[11011]) return end if lootNum <= 0 then PopupTipPanel.ShowTip(Language[11012]) return end if GuildCarDelayManager.LootCdTime > 0 then PopupTipPanel.ShowTip(this.TimeStampToDateString2(GuildCarDelayManager.LootCdTime) .. Language[11013]) return end if curProgress == 3 then UIManager.OpenPanel(UIName.GuildCarDelayLootPopup,function() CheckRedPointStatus(RedPointType.LegendExplore) end) end end) --帮助按钮 Util.AddOnceClick(this.HelpBtn, function() UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.GuildCarDelay,this.helpPosition.x,this.helpPosition.y) end) -- --boss详情 -- Util.AddOnceClick(this.live2dRoot, function() -- UIManager.OpenPanel(UIName.GuildCarDelayFindBossPopup) -- end) end --添加事件监听(用于子类重写) function GuildCarDelayMainPanel:AddListener() Game.GlobalEvent:AddEvent(GameEvent.Guild.CarDelayProgressChanged,this.IndicationRefreshPanel) Game.GlobalEvent:AddEvent(GameEvent.Guild.CarDelayChallengeCdStar,this.CarDelayChallengeCdStar) Game.GlobalEvent:AddEvent(GameEvent.Guild.CarDelayLootCdStar,this.CarDelayLootCdStar) end --移除事件监听(用于子类重写) function GuildCarDelayMainPanel:RemoveListener() Game.GlobalEvent:RemoveEvent(GameEvent.Guild.CarDelayProgressChanged, this.IndicationRefreshPanel) Game.GlobalEvent:RemoveEvent(GameEvent.Guild.CarDelayChallengeCdStar, this.CarDelayChallengeCdStar) Game.GlobalEvent:RemoveEvent(GameEvent.Guild.CarDelayLootCdStar, this.CarDelayLootCdStar) end --界面打开时调用(用于子类重写) function GuildCarDelayMainPanel:OnOpen(_curIndex) curIndex = _curIndex or 1 end --界面打开或者重新打开后,界面刷新时调用(用于子类重写) function GuildCarDelayMainPanel:OnShow() isPlayAnim = true this.TabCtrl:SetTabAdapter(this.TabAdapter) this.TabCtrl:SetChangeTabCallBack(this.SwitchView) this.TabCtrl:Init(this.tabBox, _TabData, curIndex) this.ShowTitleAllData() this.CarDelayChallengeCdStar() this.CarDelayLootCdStar() if GuildCarDelayManager.progress == GuildCarDelayProType.Challenge then this.CarDelayChallengeCdStar() elseif GuildCarDelayManager.progress == GuildCarDelayProType.Loot then this.CarDelayLootCdStar() end this.RefrePanelRedPoint() -- 音效 SoundManager.PlayMusic(SoundConfig.BGM_Carbon) end function this.IndicationRefreshPanel() this.SwitchView() this.ShowTitleAllData() this.CarDelayChallengeCdStar() this.CarDelayLootCdStar() if GuildCarDelayManager.progress == GuildCarDelayProType.Challenge then this.CarDelayChallengeCdStar() elseif GuildCarDelayManager.progress == GuildCarDelayProType.Loot then this.CarDelayLootCdStar() end this.RefrePanelRedPoint() end function GuildCarDelayMainPanel:OnSortingOrderChange() --self.live2dRoot:GetComponent("Canvas").sortingOrder = self.sortingOrder orginLayer = self.sortingOrder end function this.ShowTitleAllData() curMonsterId = GuildCarDelayManager.bossIndexId curMonsterIdConFig = ConfigManager.GetConfigData(ConfigName.WorldBossConfig,curMonsterId) Log("curMonsterId:"..curMonsterIdConFig.Boss) this.name.text = GetLanguageStrById(heroConfig[curMonsterIdConFig.Boss].ReadingName) this.proImage.sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(heroConfig[curMonsterIdConFig.Boss].PropertyName)) curProgress = GuildCarDelayManager.progress Util.SetGray(this.challengeBtn,curProgress ~= 1) challengeNum = PrivilegeManager.GetPrivilegeRemainValue(PRIVILEGE_TYPE.GUILD_CAR_DELEAY_CHALLENGE) lootNum = PrivilegeManager.GetPrivilegeRemainValue(PRIVILEGE_TYPE.GUILD_CAR_DELEAY_LOOT) this.challengeNum.text = Language[10520]..challengeNum this.lootNum.text = Language[11014]..lootNum Util.SetGray(this.lootBtn,curProgress ~= 3) local timeText = "" this.timeNumText.text = "" this.timeText.text = "" this.timeText2.text = "" if curProgress == -5 then --LogGreen("GuildCarDelayManager.battleStartTime "..GuildCarDelayManager.battleStartTime) --if GuildCarDelayManager.battleStartTime < Today_N_OClockTimeStamp(5) + 86400 then if this.timer then this.timer:Stop() this.timer = nil end this.timeTextGo:SetActive(true) this.timeText2.text = Language[12289] --else elseif curProgress == -1 or curProgress == 2 or curProgress == 3 then timeText = Language[11016] this.RemainTimeDown(this.timeTextGo,this.timeText,this.timeNumText,GuildCarDelayManager.battleStartTime - GetTimeStamp(),timeText) --end elseif curProgress == 1 then timeText = Language[11017] this.RemainTimeDown(this.timeTextGo,this.timeText,this.timeNumText,GuildCarDelayManager.endTime - GetTimeStamp(),timeText) -- elseif curProgress == 2 then -- timeText = Language[11018] -- this.RemainTimeDown(this.timeTextGo,this.timeText,this.timeNumText,GuildCarDelayManager.grabStartTime - GetTimeStamp(),timeText) -- elseif curProgress == 3 then -- timeText = Language[11019] -- this.RemainTimeDown(this.timeTextGo,this.timeText,this.timeNumText,GuildCarDelayManager.endTime - GetTimeStamp(),timeText) end if testLiveGO then GameObject.DestroyImmediate(testLiveGO) end local pos = roleConfig[curMonsterIdConFig.Boss].offset testLiveGO = poolManager:LoadLive(GetResourcePath(heroConfig[curMonsterIdConFig.Boss].Painting), this.live2dRoot.transform, Vector3.one*roleConfig[curMonsterIdConFig.Boss].play_liveScale, Vector3.New(heroConfig[curMonsterIdConFig.Boss].Position[1], heroConfig[curMonsterIdConFig.Boss].Position[2]-150, 0)) this.live2dRoot.transform.localScale = Vector3.one if curMonsterIdConFig.Boss == 10023 then--孙悟空太大了特殊处理了 this.live2dRoot.transform.localPosition = Vector3.New(0,80,0) else this.live2dRoot.transform.localPosition = Vector3.New(0,170,0) end this.RefrePanelRedPoint() end -- tab节点显示自定义 function this.TabAdapter(tab, index, status) local tabLab = Util.GetGameObject(tab, "Text") Util.GetGameObject(tab,"Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabData[index][status]) tabLab:GetComponent("Text").text = _TabData[index].name tabLab:GetComponent("Text").color = _TabFontColor[status] end --切换视图 function this.SwitchView(index) curIndex = index or curIndex isPlayAnim = true if curIndex == 2 then -- NetManager.RequestRankInfo(RANK_TYPE.GUILD_CAR_DELEAY_SINGLE, function(msg) -- this.SetRankDataShow(msg) -- this.myGuildName.text = PlayerManager.nickName -- end) RankingManager.InitData(RANK_TYPE.GUILD_CAR_DELEAY_SINGLE,function() local ranks,myRank = RankingManager.GetRankingInfo() isCanFigth=true this.SetRankDataShow(ranks,myRank,true) this.myGuildName.text = PracticeManager.SetNameColor(PlayerManager.nickName,PracticeManager.PracticeLevel) end,nil,1) elseif curIndex == 1 then -- NetManager.RequestRankInfo(RANK_TYPE.GUILD_CAR_DELEAY_GUILD, function(msg) -- this.SetRankDataShow(msg) -- this.myGuildName.text = MyGuildManager.MyGuildInfo.name -- end) RankingManager.InitData(RANK_TYPE.GUILD_CAR_DELEAY_GUILD,function() isCanFigth=true local ranks,myRankInfo = RankingManager.GetRankingInfo() this.SetRankDataShow(ranks,myRankInfo,true) this.myGuildName.text = MyGuildManager.MyGuildInfo.name end,nil,1) end end function this.SetRankDataShow(ranks,myRankInfo,isTop) if myRankInfo.rank > 0 then this.mySortNum:SetActive(true) local sortNumTabs = {} for i = 1, 4 do sortNumTabs[i] = Util.GetGameObject(this.mySortNum, "SortNum ("..i..")") sortNumTabs[i]:SetActive(false) end if myRankInfo.rank < 4 then sortNumTabs[myRankInfo.rank]:SetActive(true) else sortNumTabs[4]:SetActive(true) Util.GetGameObject(sortNumTabs[4], "TitleText"):GetComponent("Text").text = myRankInfo.rank end else this.mySortNum:SetActive(false) end this.mySore.text = myRankInfo.param1 > 0 and PrintWanNum3(myRankInfo.param1) or Language[10141] this.ScrollView:SetData(ranks, function (index, go) this.SingleRankDataShow(go, ranks[index]) if index==#ranks then RankingManager.RequestNextWarPowerPageData(function() local ranks,myRankInfo = RankingManager.GetRankingInfo() this.SetRankDataShow(ranks,myRankInfo,false) end) end end,not isTop,true) if isPlayAnim then SecTorPlayAnimByScroll(this.ScrollView) isPlayAnim = false end end function this.SingleRankDataShow(go,userRank) -- if isPlayAnim then -- go.gameObject:SetActive(false) -- else -- go.gameObject:SetActive(true) -- end local sortNumTabs = {} for i = 1, 4 do sortNumTabs[i] = Util.GetGameObject(go, "SortNum/SortNum ("..i..")") sortNumTabs[i]:SetActive(false) end if userRank.rankInfo.rank < 4 then sortNumTabs[userRank.rankInfo.rank]:SetActive(true) else sortNumTabs[4]:SetActive(true) Util.GetGameObject(sortNumTabs[4], "TitleText"):GetComponent("Text").text = userRank.rankInfo.rank end local serverName = PlayerManager.isCross == 1 and "("..userRank.serverName..") " or "" if curIndex == 2 then Util.GetGameObject(go, "Value0"):GetComponent("Text").text = serverName..userRank.userName this.ScrollTitleRootName.text = Language[11020] elseif curIndex == 1 then this.ScrollTitleRootName.text = Language[11021] Util.GetGameObject(go, "Value0"):GetComponent("Text").text = serverName..userRank.guildName.."("..userRank.rankInfo.param2..")" end Util.GetGameObject(go, "Value1"):GetComponent("Text").text = PrintWanNum3(userRank.rankInfo.param1) end --刷新倒计时显示 function this.RemainTimeDown(_timeTextExpertgo,_timeTextExpert,timeNumText,timeDown,timeText) if timeDown > 0 then if _timeTextExpertgo then _timeTextExpertgo:SetActive(true) end if _timeTextExpert then _timeTextExpert.text = timeText end if timeNumText then timeNumText.text = this.TimeStampToDateString(timeDown) end if this.timer then this.timer:Stop() this.timer = nil end this.timer = Timer.New(function() if _timeTextExpert then _timeTextExpert.text = timeText end if timeNumText then timeNumText.text = this.TimeStampToDateString(timeDown) end if timeDown < 0 then if _timeTextExpertgo then _timeTextExpertgo:SetActive(false) end this.timer:Stop() this.timer = nil this.RefrePanelRedPoint() end timeDown = timeDown - 1 end, 1, -1, true) this.timer:Start() else if _timeTextExpertgo then _timeTextExpertgo:SetActive(false) end this.RefrePanelRedPoint() end end function this.TimeStampToDateString(second) local day = math.floor(second / (24 * 3600)) local minute = math.floor(second / 60) % 60 local sec = second % 60 local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600) return string.format("%02d:%02d:%02d", hour, minute, sec) end --挑战cd function this.CarDelayChallengeCdStar() this.lootCDTimeNumGo:SetActive(false) this.challengeCDTimeNumGo:SetActive(false) if challengeNum > 0 then this.RemainTimeDown2(this.challengeCDTimeNumGo,this.challengeCDTimeNum,GuildCarDelayManager.ChallengeCdTime) end end --抢夺cd function this.CarDelayLootCdStar() this.lootCDTimeNumGo:SetActive(false) this.challengeCDTimeNumGo:SetActive(false) if lootNum > 0 then this.RemainTimeDown2(this.lootCDTimeNumGo,this.lootCDTimeNum,GuildCarDelayManager.LootCdTime) end end this.timer2 = Timer.New() --刷新倒计时显示 function this.RemainTimeDown2(_timeTextExpertgo,timeNumText) local timeDown = 0 if GuildCarDelayManager.progress == GuildCarDelayProType.Challenge then timeDown = GuildCarDelayManager.ChallengeCdTime elseif GuildCarDelayManager.progress == GuildCarDelayProType.Loot then timeDown = GuildCarDelayManager.LootCdTime end if timeDown > 0 then if _timeTextExpertgo then _timeTextExpertgo:SetActive(true) end if timeNumText then timeNumText.text = this.TimeStampToDateString2(timeDown) end if this.timer2 then this.timer2:Stop() this.timer2 = nil end this.timer2 = Timer.New(function() if timeNumText then timeNumText.text = this.TimeStampToDateString2(timeDown) end if timeDown < 0 then if _timeTextExpertgo then _timeTextExpertgo:SetActive(false) end this.timer2:Stop() this.timer2 = nil this.RefrePanelRedPoint() end if GuildCarDelayManager.progress == GuildCarDelayProType.Challenge then timeDown = GuildCarDelayManager.ChallengeCdTime elseif GuildCarDelayManager.progress == GuildCarDelayProType.Loot then timeDown = GuildCarDelayManager.LootCdTime end end, 1, -1, true) this.timer2:Start() else if _timeTextExpertgo then _timeTextExpertgo:SetActive(false) end this.RefrePanelRedPoint() end end function this.TimeStampToDateString2(second) local minute = math.floor(second / 60) % 60 local sec = second % 60 return string.format("%02d:%02d", minute, sec) end --界面关闭时调用(用于子类重写) function GuildCarDelayMainPanel:OnClose() if this.timer then this.timer:Stop() this.timer = nil end isCanFigth=false if this.timer2 then this.timer2:Stop() this.timer2 = nil end poolManager:UnLoadLive(GetResourcePath(heroConfig[curMonsterIdConFig.Boss].Painting), testLiveGO) testLiveGO = nil end function this.RefrePanelRedPoint() Util.GetGameObject(this.challengeBtn,"redPoint"):SetActive(GuildCarDelayManager.RefreshRedPoint(GuildCarDelayProType.Challenge)) Util.GetGameObject(this.lootBtn,"redPoint"):SetActive(GuildCarDelayManager.RefreshRedPoint(GuildCarDelayProType.Loot)) CheckRedPointStatus(RedPointType.LegendExplore) Util.SetGray(Util.GetGameObject(this.challengeBtn,"redPoint"),false) Util.SetGray(Util.GetGameObject(this.lootBtn,"redPoint"),false) end --界面销毁时调用(用于子类重写) function GuildCarDelayMainPanel:OnDestroy() this.spLoader:Destroy() end return GuildCarDelayMainPanel