require("Base/BasePanel") GuildCarDelayMainPanel = Inherit(BasePanel) local this = GuildCarDelayMainPanel local testLiveGO local curIndex = 1 local orginLayer local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig) local curMonsterId = 1 local curProgress = -1 local curMonsterIdConFig = {} local TabBox = require("Modules/Common/TabBox") local _TabData={ [1] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = "公会排行" }, [2] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = "个人排行" }, } local _TabFontColor = { default = Color.New(130 / 255, 128 / 255, 120 / 255, 1), select = Color.New(243 / 255, 235 / 255, 202 / 255, 1)} this.timer = Timer.New() local challengeNum = 0 local lootNum = 0 --初始化组件(用于子类重写) function GuildCarDelayMainPanel:InitComponent() this.live2dRoot = Util.GetGameObject(self.gameObject, "live2dRoot") this.name = Util.GetGameObject(self.gameObject, "nameAndTime/name"):GetComponent("Text") this.proImage = Util.GetGameObject(self.gameObject, "nameAndTime/proImage"):GetComponent("Image") this.timeText = Util.GetGameObject(self.gameObject, "nameAndTime/timeGo/timeText"):GetComponent("Text") this.timeNumText = Util.GetGameObject(self.gameObject, "nameAndTime/timeGo/timeNumText"):GetComponent("Text") this.timeTextGo = Util.GetGameObject(self.gameObject, "nameAndTime/timeGo") this.BackBtn = Util.GetGameObject(self.gameObject, "BackBtn") this.rewardSortBtn = Util.GetGameObject(self.gameObject, "rewardSortBtn") this.lootRecordBtn = Util.GetGameObject(self.gameObject, "lootRecordBtn") 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/num"):GetComponent("Text") this.lootBtn = Util.GetGameObject(self.gameObject, "lootBtn") this.lootNum = Util.GetGameObject(self.gameObject, "lootBtn/num/num"):GetComponent("Text") 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.AddClick(this.BackBtn, function() this:ClosePanel() end) --奖励排行 Util.AddClick(this.rewardSortBtn, function() UIManager.OpenPanel(UIName.GuildCarDelayRewardSortPopup) end) --抢夺记录 Util.AddClick(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.AddClick(this.challengeBtn, function() if challengeNum <= 0 then PopupTipPanel.ShowTip("今日挑战次数已达上限!") return end if curProgress == 1 then UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.GUILD_CAR_DELEAY) else PopupTipPanel.ShowTip("当前时间不可进行挑战!") return end end) --抢夺 Util.AddClick(this.lootBtn, function() if lootNum <= 0 then PopupTipPanel.ShowTip("今日抢夺次数已达上限!") return end if curProgress == 3 then NetManager.GetCarChallenegListResponse(function (msg) --for i = 1, #msg.carChallengeItem do -- LogError("uid "..msg.carChallengeItem[i].uid) --end UIManager.OpenPanel(UIName.GuildCarDelayLootPopup,msg) end) else PopupTipPanel.ShowTip("当前时间不可进行抢夺!") return end end) --帮助按钮 Util.AddClick(this.HelpBtn, function() UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.RoleInfo,this.helpPosition.x,this.helpPosition.y) end) --boss详情 Util.AddClick(this.live2dRoot, function() UIManager.OpenPanel(UIName.GuildCarDelayFindBossPopup) end) end --添加事件监听(用于子类重写) function GuildCarDelayMainPanel:AddListener() Game.GlobalEvent:AddEvent(GameEvent.Guild.CarDelayProgressChanged,this.SwitchView) end --移除事件监听(用于子类重写) function GuildCarDelayMainPanel:RemoveListener() Game.GlobalEvent:RemoveEvent(GameEvent.Guild.CarDelayProgressChanged, this.SwitchView) end --界面打开时调用(用于子类重写) function GuildCarDelayMainPanel:OnOpen(_curIndex) curIndex = _curIndex or 1 end --界面打开或者重新打开后,界面刷新时调用(用于子类重写) function GuildCarDelayMainPanel:OnShow() this.TabCtrl:SetTabAdapter(this.TabAdapter) this.TabCtrl:SetChangeTabCallBack(this.SwitchView) this.TabCtrl:Init(this.tabBox, _TabData, curIndex) this.ShowTitleAllData() 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) this.name.text = heroConfig[curMonsterIdConFig.Boss].ReadingName this.proImage.sprite=Util.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 = challengeNum this.lootNum.text = lootNum Util.SetGray(this.lootBtn,curProgress ~= 3) local timeText = "" if curProgress == -1 then timeText = "挑战开始时间:" this.RemainTimeDown(this.timeTextGo,this.timeText,this.timeNumText,GuildCarDelayManager.battleStartTime - GetTimeStamp(),timeText) elseif curProgress == 1 then timeText = "挑战剩余时间:" this.RemainTimeDown(this.timeTextGo,this.timeText,this.timeNumText,GuildCarDelayManager.endTime - GetTimeStamp(),timeText) elseif curProgress == 2 then timeText = "抢夺开始时间:" this.RemainTimeDown(this.timeTextGo,this.timeText,this.timeNumText,GuildCarDelayManager.grabStartTime - GetTimeStamp(),timeText) elseif curProgress == 3 then timeText = "抢夺剩余时间:" this.RemainTimeDown(this.timeTextGo,this.timeText,this.timeNumText,GuildCarDelayManager.endTime - GetTimeStamp(),timeText) end if testLiveGO then poolManager:UnLoadLive(GetResourcePath(heroConfig[curMonsterIdConFig.Boss].Live), testLiveGO) end testLiveGO = poolManager:LoadLive(GetResourcePath(heroConfig[curMonsterIdConFig.Boss].Live), this.live2dRoot.transform, Vector3.one*heroConfig[curMonsterIdConFig.Boss].Scale, Vector3.zero) end -- tab节点显示自定义 function this.TabAdapter(tab, index, status) local tabLab = Util.GetGameObject(tab, "Text") Util.GetGameObject(tab,"Image"):GetComponent("Image").sprite = Util.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 if curIndex == 2 then NetManager.RequestRankInfo(RANK_TYPE.GUILD_CAR_DELEAY_SINGLE, function(msg) this.SetRankDataShow(msg) --repeated UserRank ranks = 1; --optional RankInfo myRankInfo = 2; end) elseif curIndex == 1 then NetManager.RequestRankInfo(RANK_TYPE.GUILD_CAR_DELEAY_GUILD, function(msg) this.SetRankDataShow(msg) end) end end function this.SetRankDataShow(msg) if msg.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 msg.myRankInfo.rank < 4 then sortNumTabs[msg.myRankInfo.rank]:SetActive(true) else sortNumTabs[4]:SetActive(true) Util.GetGameObject(sortNumTabs[4], "TitleText"):GetComponent("Text").text = msg.myRankInfo.rank end else this.mySortNum:SetActive(false) end this.myGuildName.text = MyGuildManager.MyGuildInfo.name this.mySore.text = msg.myRankInfo.param1 > 0 and PrintWanNum2(msg.myRankInfo.param1) or "无积分" this.ScrollView:SetData(msg.ranks, function (index, go) this.SingleRankDataShow(go, msg.ranks[index]) end) end --optional int32 uid = 1; --optional int32 level = 2; --optional int32 head = 3; --optional string userName = 4; --optional RankInfo rankInfo = 5; --optional int32 headFrame = 6;//头像框 --optional string guildName = 7;//公会名称 --optional int32 force = 8;//战力 --optional int32 guildSign = 9 ;//公会图腾 function this.SingleRankDataShow(go,userRank) 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 if curIndex == 2 then Util.GetGameObject(go, "Value0"):GetComponent("Text").text = userRank.userName this.ScrollTitleRootName.text = "个人名称" elseif curIndex == 1 then this.ScrollTitleRootName.text = "公会名称" Util.GetGameObject(go, "Value0"):GetComponent("Text").text = userRank.guildName.."("..userRank.rankInfo.param2..")" end Util.GetGameObject(go, "Value1"):GetComponent("Text").text = PrintWanNum2(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 and timeNumText then _timeTextExpert.text = timeText timeNumText.text = this.TimeStampToDateString(timeDown) end if this.timer then this.timer:Stop() this.timer = nil end this.timer = Timer.New(function() if _timeTextExpert and timeNumText then _timeTextExpert.text = timeText timeNumText.text = this.TimeStampToDateString(timeDown) end if timeDown < 0 then if _timeTextExpertgo then _timeTextExpertgo:SetActive(false) end this.timer:Stop() this.timer = nil end timeDown = timeDown - 1 end, 1, -1, true) this.timer:Start() else if _timeTextExpertgo then _timeTextExpertgo:SetActive(false) end 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 --界面关闭时调用(用于子类重写) function GuildCarDelayMainPanel:OnClose() if this.timer then this.timer:Stop() this.timer = nil end poolManager:UnLoadLive(GetResourcePath(heroConfig[curMonsterIdConFig.Boss].Live), testLiveGO) testLiveGO = nil end --界面销毁时调用(用于子类重写) function GuildCarDelayMainPanel:OnDestroy() end return GuildCarDelayMainPanel