local UITownHome = UIViewClass() local EventSystem = require('Event/EventSystem') function UITownHome:OnOpened() self:RegistSystemEvent(EventID.UI_RefreshExp, self.RefreshExp) self:RegistSystemEvent(EventID.TeamLevelUpdate, self.OnTeamLevelUpdate) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.OnFunctionUnlockUpdate) self:RegistSystemEvent(EventID.ChangeTeamShowModel, self.InitPlayerInfo) self:RegistSystemEvent(EventID.UI_ChangeName, self.InitPlayerInfo) self:RegistSystemEvent(EventID.UI_PlayerHeadPortraitAndBox_RefreshCur, self.InitPlayerInfo) self:RegistSystemEvent(EventID.TimeLine_Update, self.OnTimeLineActive) self:RegistSystemEvent(EventID.UI_RefreshOfficialPositionInfo, self.RefreshTitle) self:RegistSystemEvent(EventID.CharacterTeamGsChange, self.RefreshTeamGs) self:RegistSystemEvent(EventID.UI_TownHome_Btn_Exchange, self.ExchangeBtn) self:RegistSystemEvent(EventID.UI_UpdateTitleApplyFlag, self.RefreshTitleApply) self:RegistSystemEvent(EventID.UI_UpdateFunctionUnlockAward, self.UpdateFunctionNoticeShow) self:RegistSystemEvent(EventID.UI_UpdateRebelStrike_Select, self.OnTargetSelect) self:RegistSystemEvent(EventID.UI_TownHome_TipsShow, self.OnShowTownHomeTips) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.HeroBtn, self.RefreshHeroBtnRp) -- 刷新武将红点 self:RegistSystemEvent(EventID.UI_UpdateBuff_Town, self.UpdateBuff) self:RegistSystemEvent(EventID.UI_TownHome_HideLeftBtn, self.ShowOrHideCenterLeftButton) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.SetActivityPreviewBtn) --红点消息 self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Formation, self.RefreshFormationRp) -- 刷新阵容红点 self:RegistSystemEvent(CTL.RedPoint.RedPointKey.OfficialPosition, self.RefreshOfficialPositionBtnRp) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.TownHead, self.RefreshTownHeadRp) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.FunctionNotice, self.RefreshFunctionNoticeBtnRp) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.ActivityPreview, self.RefreshActivityPreview) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Nobility, self.RefreshNobilityRp) -- 进爵红点 ---右下角折叠按钮红点 self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Equipment, self.RefreshExchangeBRRp) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.WarHorse, self.RefreshExchangeBRRp) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.WeaponBtn, self.RefreshExchangeBRRp) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Guild, self.RefreshGuildRp) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Country, self.RefreshCountrySignIn) self:RegistSystemEvent(EventID.UI_GuildAuctionBtnState_Refresh, self.RefreshGuildAuctionBtnInfo) --十四日礼刷新,拆分前在RefreshOperationActivityButton里,现在这个方法拆出去了,所以这里补上刷新 self:RegistSystemEvent(EventID.UI_OperationActivity_InfoChanged, self.ShowSignInSecondDayHintBtn) self:RegistSystemEvent(EventID.UI_LevelSelect_LevelFinished, self.ShowSignInSecondDayHintBtn) self:RegistSystemEvent(EventID.TeamLevelUpdate, self.ShowSignInSecondDayHintBtn) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.ShowSignInSecondDayHintBtn) self:RegistSystemEvent(EventID.UI_DirectGift_GiftInfoUpdate,self.ShowSignInSecondDayHintBtn) self:RegistSystemEvent(EventID.UI_StageSignIn_AcquireReward, self.ShowSignInSecondDayHintBtn) --世界boss提醒 CTL.WorldBoss.OpenNextRemind(true) self.canvas_TownGuide:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UITownGuide)) self.ActivityPanel:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UITownHome_ActivityEntry)) self:ShowSignInSecondDayHintBtn() --十四日礼刷新,按钮在townhome预制里,所以在这儿刷新 self:InitBtns() self:InitBtnsRp() self:InitPlayerInfo() self:RefreshTitle() self:RefreshTitleApply() self:SetActivityPreviewBtn() self:SetVN18LogoConfig() CTL.RedPoint.UpdateOneTimeRedPoint() --叛军突袭按钮 local info = MDL.RebelStrike.GetSelectInfo() self.RebelStrikeIsNear = info ~= nil UIUtils.SetActive(self.event_NpcInteractive, self.RebelStrikeIsNear) if GameAppInfo.IsPCOrMacPackage() then CTL.Setting.SetPCViewScale(self.gameObject.transform) EventSystem.Dispatch(EventID.UI_OnTownHomeView_Open) end self:UpdateFunctionNoticeShow() --有体力时,才上报用户信息 self:InitExchangeBtn() --buff self:UpdateBuff() UIUtils.SetActive(self.group_HideTopRight, true) self:SetReturnBtn() -- 设置返回按钮 self:CheckDeeplink() end --检测deeplink function UITownHome:CheckDeeplink() --延迟一下,避免显示问题 self:StartRepeatFunc(self.DelayCheckDeeplink, 1, 1) end function UITownHome:DelayCheckDeeplink() local url = PersistentData.DeviceData:Get(LuaConst.DEEPLINKURLKEY) if string.isNilOrEmpty(url) then return end --进主城后有缓存的url,派发并清掉 local key, param = UTL.String.CheckDeeplink(url) EventSystem.Dispatch(EventID.DeepLink_Event, key, param) PersistentData.DeviceData:Remove(LuaConst.DEEPLINKURLKEY,true) end -- 显隐左侧新功能按钮 function UITownHome:ShowOrHideCenterLeftButton(isShow) UIUtils.SetActive(self.CenterLeftButtonArea, isShow) end function UITownHome:UpdateBuff() local buffList = MDL.HomeMain.GetBuffList() if buffList and #buffList > 0 then if self.buffPanel == nil then self.buffPanel = self.node_Buff:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UITownBuff), nil, "Battle/UIBattleBuffPanel") end else if self.buffPanel then self.buffPanel:CloseView() self.buffPanel = nil end end end function UITownHome:OnClosed() self.canvas_TownGuide:CloseView(Const_UI_Lua.UIEnum.UITownGuide) self.progressMat = nil end function UITownHome:InitBtns() self:UpdateBtns(MDL.Unlock.FunctionType.Formation, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Formation)) self:UpdateBtns(MDL.Unlock.FunctionType.Guild, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Guild)) self:UpdateNobilityEntry() end -- 玩法解锁状态刷新内容 function UITownHome:OnFunctionUnlockUpdate(id, state) self:UpdateBtns(id, state) self:UpdateFunctionNoticeShow() end --爵位系统入口 function UITownHome:UpdateNobilityEntry() UIUtils.SetActive(self.event_Nobility, MDL.Nobility.GetIsActive()) end function UITownHome:OnTeamLevelUpdate() self:UpdateNobilityEntry() self:UpdateLevel() self:RefreshExp() end function UITownHome:UpdateLevel() local teamLevel = MDL.Player.GetRoleInfo() local tlData = DataSheetManager.TeamLevelData:GetDataByTeamLevel(teamLevel) local _levelStr = UTL.Item.GetNobilityByTeamLevel(tlData.TeamLevel) -- 爵位转换 local teamLevelName = string.FormatByIdsId(Const_IDS[tlData.TeamLevelName], _levelStr) UIUtils.SetLabel(self.labLocal_Level, teamLevelName) end --**_Lock是右下角面板遮罩的显隐,event_**是按钮本身的显隐,请注意 function UITownHome:UpdateBtns(id, state) if id == MDL.Unlock.FunctionType.Formation then UIUtils.SetActive(self.event_NoHideFormation.gameObject, state) self:RefreshFormationRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Formation)) elseif id == MDL.Unlock.FunctionType.Guild then UIUtils.SetActive(self.event_NoHideGuild.gameObject, state) end end --isFoldIn:false展开功能面板, true则收起 function UITownHome:OnClickExchangeBR(isFoldIn, isEvent) if not isEvent then if isFoldIn then CTL.Sound.PlayGameSound("UI_fold") else CTL.Sound.PlayGameSound("UI_expand") end end if isFoldIn then if self.RebelStrikeIsNear then UIUtils.SetActive(self.event_NpcInteractive,true) end if self.exchangeBRClose then self:PlayUIAnimation(self.exchangeBRClose) else self.exchangeBRClose = self:PlayUIAnimation("ExchangeBRClose") end UIUtils.SetActive(self.img_Bottom, false) self:RefreshExchangeBRRp() MDL.HomeMain.SetTownHomeUIFoldStateByType(MDL.HomeMain.TownFoldType.RightBottom, false) self.group_HideBottomRight:CloseView(Const_UI_Lua.UIEnum.UITownHome_FunctionEntry) self:NeedHideBtn(true) EventSystem.Dispatch(EventID.UI_TownHome_BtnState_Changed, MDL.HomeMain.TownFoldType.RightBottom, true) else if self.RebelStrikeIsNear then UIUtils.SetActive(self.event_NpcInteractive,false) end UIUtils.SetActive(self.img_Bottom, true) if self.exchangeBR then self:PlayUIAnimation(self.exchangeBR) else self.exchangeBR = self:PlayUIAnimation("ExchangeBR") end self:RefreshExchangeBRRp() MDL.HomeMain.SetTownHomeUIFoldStateByType(MDL.HomeMain.TownFoldType.RightBottom, true) self.group_HideBottomRight:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UITownHome_FunctionEntry)) self:NeedHideBtn(false) EventSystem.Dispatch(EventID.UI_TownHome_BtnState_Changed, MDL.HomeMain.TownFoldType.RightBottom, false) end end function UITownHome:NeedHideBtn(isShow) UIUtils.SetActive(self.group_NoHide, isShow) UIUtils.SetActive(self.group_TopRight, isShow) UIUtils.SetActive(self.event_Nobility, MDL.Nobility.GetIsActive()) EventSystem.Dispatch(EventID.GuildEscort_Town_HideSelf, isShow) EventSystem.Dispatch(EventID.UI_MiniMap_HideSelf, isShow) EventSystem.Dispatch(EventID.UI_ActivityNotice_HideSelf, isShow) EventSystem.Dispatch(EventID.Country_HideBattleList,not isShow) end function UITownHome:ExchangeBtn(foldType, value, isForce) local state = MDL.HomeMain.GetTownHomeUIFoldStateByType(foldType) if state ~= value or isForce == true then if foldType == MDL.HomeMain.TownFoldType.RightBottom then self:OnClickExchangeBR(not value,true) end end end function UITownHome:InitExchangeBtn() for i, v in pairs(MDL.HomeMain.TownFoldType) do local value = MDL.HomeMain.GetTownHomeUIFoldStateByType(v) self:ExchangeBtn(v, value, true) end end function UITownHome:OnButtonClicked(obj) if obj ~= self.event_ExchangeBR then if obj == self.img_Bottom then CTL.Sound.PlayGameSound("UI_fold") end self:OnClickExchangeBR(true,true) end if obj == self.event_Nobility then --进爵 CTL.Nobility.OpenMainView() ---显隐额外按钮 elseif obj == self.event_ExchangeBR then local isShowBottomRight = MDL.HomeMain.GetTownHomeUIFoldStateByType(MDL.HomeMain.TownFoldType.RightBottom) if isShowBottomRight then -- 关闭 if self.exchangeBRClose then self:PlayUIAnimation(self.exchangeBRClose) else self.exchangeBRClose = self:PlayUIAnimation("ExchangeBRClose") end self:OnClickExchangeBR(true) EventSystem.Dispatch(EventID.Country_HideBattleList,false) else -- 打开 if self.exchangeBROpen then self:PlayUIAnimation(self.exchangeBROpen) else self.exchangeBROpen = self:PlayUIAnimation("ExchangeBROpen") end self:OnClickExchangeBR(false) EventSystem.Dispatch(EventID.Country_HideBattleList,true) EventSystem.Dispatch(EventID.UI_ActivityNotice_HideSelf,false) end elseif obj == self.event_NoHideShowHero then --主城里的英雄选择 UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIHeroSelectPanel) elseif obj == self.event_NoHideFormation then --主城里的阵容 UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIHeroFormationPanel, nil) elseif obj == self.event_OfficialPositionTitle then CTL.OfficialPosition.OpenMainPanel() ---特殊 elseif obj == self.event_OpenCharacter then --左上战队信息 if not BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.DragonArteryRegistArea) then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UICharacter) end elseif obj == self.event_NoHideGuild then --主城里的势力 CTL.Guild.OpenGuildMain() elseif obj == self.group_NewFunction then CTL.FunctionNotice.OpenFunctionPreview() CTL.Sound.PlayGameSound("UI_kaiqi") elseif obj == self.event_NpcInteractive then if CTL.CountryNightBoss.CurInteractBossID and CTL.CountryNightBoss.CurInteractBossID ~= 0 then CTL.CountryNightBoss.EnterBattle(CTL.CountryNightBoss.CurInteractBossID) else CTL.RebelStrike.EnterBattle() end elseif obj == self.event_ReturnServer then if BattleDataGetter.IsSatelliteTown() then CTL.Setting.BackToTown() elseif BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.CrossHeroMatchTown) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.CrossHeroMatchTown3V3) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.CrossFairSoloTournamentTown) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SingleFairSoloTournamentTown) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.TeamFairChampionshipTown) then CTL.HeroMatch1v1.QuitFromMatchLobby() elseif BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.DragonArteryRegistArea) then MDL.Level.SendRoleLeaveFubenFromSetting() else CTL.GuildEscort.GuildEscortQuit(function() CTL.MiniMap.GoToMap(CTL.Level.GetMainCityId()) end) end elseif obj == self.btn_ActivityPreview then UIManager.OpenView(Const_UI_Lua.UIEnum.UIActivitiesPreview) elseif obj == self.btn_SignInSecondDayHint then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIWelfareBasePanel, {welfareId = CTL.Welfare.WelfareType.SignInGift}) end end function UITownHome:RefreshExp() local teamLevel, teamLevelExp, teamRankID = MDL.Player.GetRoleInfo() local tlData = DataSheetManager.TeamLevelData:GetDataByTeamLevel(teamLevel) if tlData ~= nil then --经验条 self.sprite_ExpFg_Show.value = teamLevelExp / tlData.LevelExp else self.obj_GradeIcon.gameObject:SetActive(false) end end function UITownHome:OnTimeLineActive(value) self.isInTimeline = not value if value then UIUtils.SetActive(self.event_NpcInteractive,MDL.RebelStrike.GetSelectInfo() ~= nil) else UIUtils.SetActive(self.event_NpcInteractive, false) end end function UITownHome:InitPlayerInfo() self.lab_RoleName.text = BattleDataGetter.GetPlayerName() CTL.Character.SetSelfPortraitAndFrame(self.UIHeroHead) UIUtils.SetCanvasSortingOrderByMainCanvas(self.UIHeroHead.effectUpCanvas, self.HeadEffectUp, CTL.Character.UpOrder.Common) UIUtils.SetImageByAssetBundle(self.sprite_RoleNameBg, MDL.Decoration.GetCurDecoratingResource(MDL.Decoration.DecorationType.NameDye)) self:RefreshExp() self:UpdateLevel() self:RefreshTeamGs() end function UITownHome:RefreshOfficialPositionBtnRp(active) self.event_OfficialPositionTitle:SetRedPoint(MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.OfficialPosition) and active) end --头像红点 function UITownHome:RefreshTownHeadRp(active) self.event_OpenCharacter:SetRedPoint(active) end --更新官职显示 function UITownHome:RefreshTitle() local titleData = MDL.OfficialPosition.GetCurTitleData() if titleData then local txt = UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[titleData.Name1]), titleData.QualityColor) self.lab_OfficialPositionTitle.text = txt else UIUtils.SetLabelText(self.lab_OfficialPositionTitle, Const_IDS.IDS_OfficialPosition_Civilian) end end --官职"可报名"标识 function UITownHome:RefreshTitleApply() UIUtils.SetActive(self.section_Kebaoming, CTL.OfficialPosition.GetApplyFlagShow()) end function UITownHome:RefreshTeamGs() self.txt_CE.text = MDL.Player.GetLineUpGs() end --region 红点 function UITownHome:InitBtnsRp() self:RefreshHeroBtnRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.HeroBtn)) -- 初始化武将红点 self:RefreshFormationRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Formation)) -- 初始化阵容红点 self:RefreshGuildRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Guild)) self:RefreshOfficialPositionBtnRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.OfficialPosition)) self:RefreshTownHeadRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.TownHead)) self:RefreshFunctionNoticeBtnRp(MDL.FunctionNotice.GetIfAwardLeft()) self:RefreshActivityPreview(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.ActivityPreview)) self:RefreshNobilityRp(MDL.Nobility.GetRedPoint()) if not self.group_HideBottomRight:IsViewOpened(Const_UI_Lua.UIEnum.UITownHome_FunctionEntry) then self:RefreshExchangeBRRp() end end -- 武将按钮 function UITownHome:RefreshHeroBtnRp(active, userData) self.event_NoHideShowHero:SetRedPoint(active) end -- 阵容红点 function UITownHome:RefreshFormationRp(active) self.event_NoHideFormation:SetRedPoint(MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Formation) and active) -- 阵容红点 end function UITownHome:RefreshGuildRp(active) self.event_NoHideGuild:SetRedPoint(active) end ---@public 进爵红点 function UITownHome:RefreshNobilityRp(active) self.event_Nobility:SetRedPoint(active) end function UITownHome:RefreshExchangeBRRp() local active = CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.HeroBtn) and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.HeroLevelUp) or CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Bag) and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Bag) or CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Equipment) and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Equipment) or CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Formation) and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Formation) or CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Treasure) and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Treasure) or CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.WarHorse) and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.WarHorse) or CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Guild) and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Guild) or CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.WeaponBtn) and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Weapon) or CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Library) and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Library) or CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.OfficialPosition) and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.OfficialPosition) or MDL.Achievement.IsShowEnterRedPoint() and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Achievement) or MDL.FormationResonance.IsCanLevelupMainResonance() and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Resonance) or CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Setting) or CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Rank) and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Rank) or CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Reborn) and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Reborn) self.event_ExchangeBR:SetRedPoint(active) end --功能预告显示 function UITownHome:UpdateFunctionNoticeShow() if MDL.FunctionNotice.GetIfShowEntry() then UIUtils.SetActive(self.group_NewFunction, true) local funcID = math.max(MDL.FunctionNotice.GetNextFuncID(), MDL.FunctionNotice.GetCurFuncID()) local config = DataSheetManager.FunctionPredictionData:GetDataByFunctionPredictionID(funcID) UIUtils.SetImageByAssetBundle(self.img_Icon, config.FunctionIcon) UIUtils.SetLabelText(self.txt_FunctionName, Const_IDS[config.FunctionName]) if MDL.Unlock.IsUnlock(config.FucID) then UIUtils.SetLabelText(self.lab_Open, Const_IDS.IDS_FunctionUnlock_Hint3) else UIUtils.SetLabelText(self.lab_Open, Const_IDS.IDS_BossChallenge_AboutToOpen) end --越南单独处理势力、百战雄关、名将列传、衣诏共讨、叛军围剿的显示方式 if GameAppInfo.IsVietnamPackage() then --越南这个名字不走读表,因为表里面的IDS其他地方也会用 local idsStr if config.FunctionName == "IDS_RebelStrike_Title1" then idsStr = "IDS_RebelStrike_VN_Title1" elseif config.FunctionName == "IDS_FunctionName_Guild" then idsStr = "IDS_FunctionName_VN_Guild" elseif config.FunctionName == "IDS_ActivityName_ClimbTower" then idsStr = "IDS_ActivityName_VN_ClimbTower" elseif config.FunctionName == "IDS_ActivityName_HeroBiography" then idsStr = "IDS_ActivityName_VN_HeroBiography" elseif config.FunctionName == "IDS_ActivityName_WorldBoss" then idsStr = "IDS_ActivityName_VN_WorldBoss" end UIUtils.SetLabelText(self.txt_FunctionName, Const_IDS[idsStr]) UIUtils.SetActive(self.lab_Open, false) end else UIUtils.SetActive(self.group_NewFunction, false) end end function UITownHome:RefreshFunctionNoticeBtnRp(active) UIUtils.SetActive(self.rect_BoxIcon, active) end function UITownHome:RefreshActivityPreview(active) self.btn_ActivityPreview:SetRedPoint(active) end --endregion 红点 function UITownHome:OnTargetSelect(info) if self.isInTimeline then return end if info ~= nil then self.RebelStrikeIsNear = true else self.RebelStrikeIsNear = false end if not self.group_HideBottomRight:IsViewOpened(Const_UI_Lua.UIEnum.UITownHome_FunctionEntry) then UIUtils.SetActive(self.event_NpcInteractive,info ~= nil) if info ~= nil then CTL.Sound.PlayGameSound("UI_rebels") end end end function UITownHome:OnFocusChanged(isFocus) CTL.HomeMain.SetFocusTarget(isFocus and Const_UI_Lua.UIEnum.UITownHome or nil) if isFocus then EventSystem.Dispatch(EventID.UI_Delay_FocusOnTownHome) end end function UITownHome:ShowSignInSecondDayHintBtn() local isShow, leftTime, displayIconPath = CTL.SignIn.IsShowSecondDayHint() UIUtils.SetActive(self.btn_SignInSecondDayHint, isShow) if isShow then self.txt_SignInSecondDayHintTime:SetDHMSStr(UIUtils.GetLocalizedTxt(Const_IDS.IDS_PreviewTime1),UIUtils.GetLocalizedTxt(Const_IDS.IDS_PreviewTime2), UIUtils.GetLocalizedTxt(Const_IDS.IDS_PreviewTime3),UIUtils.GetLocalizedTxt(Const_IDS.IDS_PreviewTime4)) self.txt_SignInSecondDayHintTime:ResetAndBeginCustomTimer(false, leftTime, 0, nil) UIUtils.SetImageByAssetBundle(self.img_SignInSecondDayReward, displayIconPath) else self.txt_SignInSecondDayHintTime:EndTimer() end end function UITownHome:OnShowTownHomeTips(desc) self.txt_Tip.text = desc self:PlayUIAnimation("tips") end function UITownHome:SetReturnBtn() if CTL.CrossServer.IsInCrossServerScene() then UIUtils.SetActive(self.event_ReturnServer, true) UIUtils.SetLabelText(self.lab_ReturnServer, Const_IDS.IDS_ZoneTown_Quit) elseif BattleDataGetter.IsSingleEscortTown() then UIUtils.SetActive(self.event_ReturnServer, true) UIUtils.SetLabelText(self.lab_ReturnServer, Const_IDS.IDS_Escort_GoBackCity) elseif BattleDataGetter.IsSatelliteTown() then UIUtils.SetActive(self.event_ReturnServer, true) UIUtils.SetLabelText(self.lab_ReturnServer, Const_IDS.IDS_LoginSystem_Register_Return) elseif BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.CrossHeroMatchTown) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.CrossHeroMatchTown3V3) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.CrossFairSoloTournamentTown) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SingleFairSoloTournamentTown) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.TeamFairChampionshipTown) then UIUtils.SetActive(self.event_ReturnServer, true) UIUtils.SetLabelText(self.lab_ReturnServer, Const_IDS.IDS_HeroMatch1v1_LeaveCity) elseif BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.DragonArteryRegistArea) then UIUtils.SetActive(self.event_ReturnServer, true) UIUtils.SetLabelText(self.lab_ReturnServer, Const_IDS.IDS_LoginSystem_Register_Return) else UIUtils.SetActive(self.event_ReturnServer, false) end end function UITownHome:SetActivityPreviewBtn() local activityPreviewIdList = CTL.Activities.GetActivityPreviewIdList() if #activityPreviewIdList > 0 then UIUtils.SetActive(self.btn_ActivityPreview, true) local startTimeId, endTimeId = 0, 0 for _, v in DataSheetManager.ActivationCalendar:GetEnumerator() do if startTimeId == 0 and v.ActivaionType == CTL.Activities.CalendarType.Normal then startTimeId = v.TimeID end if endTimeId == 0 and v.ActivaionType == CTL.Activities.CalendarType.Country then endTimeId = v.TimeID end end local curTimestamp = UTL.Time.GetServerTimestamp() local startTimestamp = UTL.Time.GetConfigTimestampById(startTimeId) local endTimestamp = self:GetCountryTimestampById(endTimeId) if curTimestamp == nil or startTimestamp == nil or endTimestamp == nil then -- 这里bugly报错了,不清楚哪个字段是nil。加个log跟一下 logging.error(LTAG.ERROR, "周历活动预告时间为空了!!!!!!! curTimestamp,startTimestamp,endTimestamp, startTimeId, endTimeId ", curTimestamp, startTimestamp, endTimestamp, startTimeId, endTimeId) end if curTimestamp >= startTimestamp and curTimestamp < endTimestamp then self.effect_PushGift:PlayUIEffect() else self.effect_PushGift:StopUIEffect() if curTimestamp < startTimestamp then self:StartRepeatFunc(self.SetActivityPreviewBtn, startTimestamp - curTimestamp) end end else UIUtils.SetActive(self.btn_ActivityPreview, false) end end function UITownHome:SetVN18LogoConfig() --越南版本开启 其他版本默认关闭 if not UNITY_EDITOR and GameAppInfo.IsVietnamPackage() then UIUtils.SetLocalizationImage(self.icon_VN_AgeLimit18, "icon_VN_AgeLimit18.png") UIUtils.SetActive(self.icon_VN_AgeLimit18, GameAppInfo.IsShowVietnam18Logo()) end end --获取周活动龙脉争夺战的开始时间当作活动预告的结束时间 function UITownHome:GetCountryTimestampById(endTimeId) local data = DataSheetManager.TimeRefresh:GetDataByID(endTimeId) local timestamp = UTL.Time.GetServerZeroTimestamp() timestamp = timestamp + data.HMS --默认从周一 0 点开始计算 local diffTimestamp = (0 - UTL.Time.GetServerWeekday() + data.Day) * UTL.Time.TotalSecondsOneDay return timestamp + diffTimestamp + UTL.Time.GetDisplayDiffLocalTimeZone() end return UITownHome