local Country_Controller = {} local private = {} local HanCountryIndex = 5 local HanCountryId = 99 local EventSystem = require('Event/EventSystem') local Const_WorshipSqr = FP.newV1(9) -- 膜拜半径3米 local ColliderManager = require("Battle/Logic/Level/ColliderManager") local Const_StatueSize = 2 local leaderEntityID = nil local enterTrigger = false local CountryKingTitleID = 300503 local CountryMuteTime = DataSheetManager.ConstData:GetDataByID("CountryMuteTime").IntValue local HanMapID = 55 local HanMapCityID = 8 local StatueLevelItemID = 6012 local NormalColor = "#ffffff" local GrayColor = "#9d9d9d" --参数类型 需要解析 string format local SRParamType = { ItemIDNum = 1, --list int string list长度2的倍数 id 数量 Str = 2, --str RewardID = 3, --int 奖励id PositionID = 4, --int 职位 NameAcid = 5, --list string string 长度2 name acid } local CountryToCountryType = { MyCountryToChangAn = 1, --本国去长安=传送 MyCountryToEnemyCountry = 2, -- 本国去敌国=寻路去长安配置的点+步行 EnemyCountryToMyCountry = 3, -- 敌国回本国=传送(时间延长) EnemyCountryToChangAn = 4, -- 敌国回长安=传送(时间延长) EnemyCountryToEnemyCountry= 5, -- 敌国去敌国=寻路去长安配置的点+步行 OtherToChangAn = 6, -- 剩余场景去长安= 传送 OtherToMyCountry = 7, --剩余场景去本国 传送 OtherToEnemyCountry = 8, --剩余场景去敌国 -- 弹窗 传送到长安 然后再寻路过去 ChangAnToMyCountry = 9, --长安去本国 传送(时间延长) ChangAnToEnemyCountry = 10, -- 长安去敌国 走路 ---剩余场景包括长安皇宫 普通主城 跨服主城 等等一系列主城 } function Country_Controller.OnStartup() EventSystem.Regist(EventID.New_Day_Refresh, private.OnNewDayChanged) EventSystem.Regist(EventID.Task_ShowTaskTrigger, Country_Controller.OnCreateStatue) EventSystem.Regist(EventID.Country_WorshipClick, private.WorshipClick) EventSystem.Regist(EventID.CountryJob_BetterBuff, private.OnGetBetterBuff) EventSystem.Regist(EventID.Country_OnGetFoundCountry, private.SetActivityRedPoint) end function Country_Controller.SetCountryImageByComp(imgCountryLogo, imgCountryName, countryID) local countryData = DataSheetManager.CountryBase:GetDataByID(countryID) if imgCountryLogo then UIUtils.SetImageByAssetBundle(imgCountryLogo, countryData.LogoPath) end if imgCountryName then UIUtils.SetLocalizationImage(imgCountryName, countryData.NamePath) end end function Country_Controller.SetCountryImage(collection, country) local countryData = DataSheetManager.CountryBase:GetDataByID(country) UIUtils.SetImageByAssetBundle(collection.img_Flag, countryData.LogoPath) UIUtils.SetLocalizationImage(collection.img_Country, countryData.NamePath) end function Country_Controller.SetCountryInRank(img_Flag, txt, country) local countryData = DataSheetManager.CountryBase:GetDataByID(country) UIUtils.SetImageByAssetBundle(img_Flag, countryData.SquareLogo) UIUtils.SetLabelText(txt, Const_IDS[countryData.CountryTC]) end --- 图片上带国家和区分颜色的logo function Country_Controller.SetCountryFlagImg(img_Flag, countryID) local countryData = DataSheetManager.CountryBase:GetDataByID(countryID) UIUtils.SetImageByAssetBundle(img_Flag, countryData.UIFlag) end function Country_Controller.SetCountrySquareIconInRank(collection, countryID) local countryData if countryID and countryID>0 then countryData = DataSheetManager.CountryBase:GetDataByID(countryID) end UIUtils.SetActive(collection.gameObject, true) if countryData then UIUtils.SetActive(collection.img_Country.gameObject, true) UIUtils.SetImageByAssetBundle(collection.img_Country, countryData.SquareLogo) UIUtils.SetLabelText(collection.txt_Guild, Const_IDS[countryData.CountryTC]) else UIUtils.SetActive(collection.img_Country.gameObject, false) end end function Country_Controller.SetCountryJob(job_Img, country_Img, country, jobId) local countryData = DataSheetManager.CountryBase:GetDataByID(country) local jobData = jobId>0 and DataSheetManager.CountryJob:GetDataByID(jobId) or nil if jobData and not string.isNilOrEmpty(jobData.LogoPath) then UIUtils.SetImageByAssetBundle(job_Img, jobData.LogoPath) job_Img.enabled = true else job_Img.enabled = false end UIUtils.SetImageByAssetBundle(country_Img, countryData.NamePlatePath) end function Country_Controller.SetOverseasCountryImage(state, labText, country, jobId) if state ~= 0 then local countryData = DataSheetManager.CountryBase:GetDataByID(country) UIUtils.SetLabelText(labText, Const_IDS[countryData.CountryTC]) local jobData = DataSheetManager.CountryJob:GetDataByID(jobId) if jobData and not string.isNilOrEmpty(jobData.LogoPath) then UIUtils.SetLocalPosition(labText, 0, -24, 0) else UIUtils.SetLocalPosition(labText, 0, -27, 0) end end end function Country_Controller.SetHeadCountryUI(labText, country_Img, country) local countryData = DataSheetManager.CountryBase:GetDataByID(country) UIUtils.SetLabelText(labText, Const_IDS[countryData.CountryTC]) UIUtils.SetImageByAssetBundle(country_Img, countryData.NamePlatePath) end function Country_Controller.GetCountryNameIDS(country) local countryData = DataSheetManager.CountryBase:GetDataByID(country) return Const_IDS[countryData.CountryName] end function Country_Controller.GetCountryName(country) local ids = Country_Controller.GetCountryNameIDS(country) return UIUtils.GetLocalizedTxt(ids) end --- @return ["魏"] function Country_Controller.GetCountryNameWithColorAndColon(countryID) local colorHex = DataSheetManager.CountryBase:GetDataByID(countryID).CountryFontColor return UTL.Color.FormatTextByColor(colorHex, string.format("[%s]", Country_Controller.GetCountryName(countryID))) end function Country_Controller.GetCountryFullName(country) local countryData = DataSheetManager.CountryBase:GetDataByID(country) return UIUtils.GetLocalizedTxt(Const_IDS[countryData.CountryFullName]) end --- @return 带颜色的 X国 function Country_Controller.GetCountryFullNameWithColor(country) local countryData = DataSheetManager.CountryBase:GetDataByID(country) return UTL.Color.GetColorfulText(countryData.CountryFontColor, countryData.CountryFullName) end function Country_Controller.SetCdTime(cdTimeComp, timeValue, concatIDS) if timeValue > UTL.Time.TotalSecondsOneDay then local str = string.FormatByIdsId(concatIDS, UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_Time2)) cdTimeComp:SetCustomString(str, 1, 1) else local str = string.FormatByIdsId(concatIDS, UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_Time1)) cdTimeComp:SetCustomString(str, 1, 2) end cdTimeComp:ResetAndBeginTimer(false, timeValue, 0) end function Country_Controller.SetTitleShow(collection) local titleData = DataSheetManager.Title:GetDataByID(CountryKingTitleID) UIUtils.SetActive(collection.gameObject, true) CTL.Title.SetTitleShow(collection, titleData) end function Country_Controller.ClickCountryBtn() local curStage = MDL.Country.GetCurStage() if curStage == nil then if CTL.WarZone.GetTimeState() == CTL.WarZone.TimeState.Preview then UIManager.OpenView(Const_UI_Lua.UIEnum.UICountryForeshow) else local timeInfo = MDL.WarZone.GetTimeInfo() local offsetTime = timeInfo.startTime - UTL.Time.GetServerTimestamp() if offsetTime > 0 then CTL.Tips.AddTipsMsgAndPlaySound(string.FormatByIdsId(Const_IDS.IDS_Country_MuteChatTip, UTL.Time.FormatTimeBySecondsToHour(offsetTime))) end end elseif curStage >= MDL.Country.Stage.CountryBuild then if MDL.Guild.IsHasGuild() then local myCountryId = MDL.Country.GetMyCountryId() if myCountryId and myCountryId > 0 then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UICountryBase) else UIManager.OpenView(Const_UI_Lua.UIEnum.UICountryAfterChooseView) end else CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS.IDS_ERRORCODE_1319_InfoCode_Guild_PlayerNotInGuild) CTL.Guild.OpenGuildMain() end else if MDL.Guild.IsHasGuild() then UIManager.OpenView(Const_UI_Lua.UIEnum.UICountryChooseView) else CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS.IDS_ERRORCODE_1319_InfoCode_Guild_PlayerNotInGuild) CTL.Guild.OpenGuildMain() end end end function private.GetCurCountryToCountryType(destCountry) local curLevelId = BattleDataGetter.GetCurLevelID() local destCountryData = DataSheetManager.CountryBase:GetDataByID(destCountry) local myCountryData = DataSheetManager.CountryBase:GetDataByID(MDL.Country.GetMyCountryId()) if destCountryData and myCountryData then local destLevelId = destCountryData.SceneId local myCountryLevelId = myCountryData.SceneId if private.AllCountryLevelIds == nil then private.AllCountryLevelIds = {} for _, data in DataSheetManager.CountryBase:GetEnumerator() do table.insert(private.AllCountryLevelIds, data.SceneId) end end if destCountry == HanCountryId then if curLevelId == myCountryLevelId then return CountryToCountryType.MyCountryToChangAn elseif table.containValue(private.AllCountryLevelIds, curLevelId) then return CountryToCountryType.EnemyCountryToChangAn else return CountryToCountryType.OtherToChangAn end end if destLevelId == myCountryLevelId then if curLevelId == HanCountryId then return CountryToCountryType.ChangAnToMyCountry elseif table.containValue(private.AllCountryLevelIds, curLevelId) then return CountryToCountryType.EnemyCountryToMyCountry else return CountryToCountryType.OtherToMyCountry end end if table.containValue(private.AllCountryLevelIds, destLevelId) then if curLevelId == myCountryLevelId then return CountryToCountryType.MyCountryToEnemyCountry elseif curLevelId == HanCountryId then return CountryToCountryType.ChangAnToEnemyCountry elseif table.containValue(private.AllCountryLevelIds, curLevelId) then return CountryToCountryType.EnemyCountryToEnemyCountry else return CountryToCountryType.OtherToEnemyCountry end end logging.error(LTAG.ERROR, "有没考虑到的情况 ? ", curLevelId, destLevelId, myCountryLevelId) end end function private.GoCountryMapByType(type, countryId) local transCastTime = DataSheetManager.ConstData:GetDataByID("CountryTransCastTime").IntValue print(transCastTime) if type == CountryToCountryType.MyCountryToChangAn then CTL.Level.StartConveyProgress(HanMapCityID) EventSystem.Dispatch(EventID.UI_CloseAndRecoverView, Const_UI_Lua.UIEnum.UICountryBase) elseif type == CountryToCountryType.MyCountryToEnemyCountry then private.GoCountryMapWithMsgBox(countryId, type) elseif type == CountryToCountryType.EnemyCountryToMyCountry then local countryData = DataSheetManager.CountryBase:GetDataByID(countryId) CTL.Level.StartConveyProgress(countryData.SceneId, nil, transCastTime) EventSystem.Dispatch(EventID.UI_CloseAndRecoverView, Const_UI_Lua.UIEnum.UICountryBase) elseif type == CountryToCountryType.EnemyCountryToChangAn then CTL.Level.StartConveyProgress(HanMapCityID, nil, transCastTime) EventSystem.Dispatch(EventID.UI_CloseAndRecoverView, Const_UI_Lua.UIEnum.UICountryBase) elseif type == CountryToCountryType.EnemyCountryToEnemyCountry then private.GoCountryMapWithMsgBox(countryId, type) elseif type == CountryToCountryType.OtherToChangAn then CTL.Level.StartConveyProgress(HanMapCityID) EventSystem.Dispatch(EventID.UI_CloseAndRecoverView, Const_UI_Lua.UIEnum.UICountryBase) elseif type == CountryToCountryType.OtherToMyCountry then local countryData = DataSheetManager.CountryBase:GetDataByID(countryId) CTL.Level.StartConveyProgress(countryData.SceneId) EventSystem.Dispatch(EventID.UI_CloseAndRecoverView, Const_UI_Lua.UIEnum.UICountryBase) elseif type == CountryToCountryType.OtherToEnemyCountry then private.GoCountryMapWithMsgBox(countryId, type) elseif type == CountryToCountryType.ChangAnToMyCountry then local countryData = DataSheetManager.CountryBase:GetDataByID(countryId) CTL.Level.StartConveyProgress(countryData.SceneId, nil, transCastTime) EventSystem.Dispatch(EventID.UI_CloseAndRecoverView, Const_UI_Lua.UIEnum.UICountryBase) elseif type == CountryToCountryType.ChangAnToEnemyCountry then private.GoCountryMapWithMsgBox(countryId, type) end end function Country_Controller.GoCountryMap(countryId,isWantedTask) if isWantedTask then private.GoCountryMapOfWantedTask = true else private.GoCountryMapOfWantedTask = nil end local countryData = DataSheetManager.CountryBase:GetDataByID(countryId) if BattleDataGetter.GetCurLevelID() == countryData.SceneId then CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS.IDS_InThisScene) else private.GoCountryMapByType(private.GetCurCountryToCountryType(countryId), countryId) end end function private.GoCountryMapWithMsgBox(countryId, type) local countryData = DataSheetManager.CountryBase:GetDataByID(countryId) if private.isShowConfirmBox == nil or private.isShowConfirmBox then local desc = string.FormatByIdsId(Const_IDS.IDS_Country_GoToEnemyCountryConfirm, UIUtils.GetLocalizedTxt(Const_IDS[countryData.CountryFullName])) UTL.MessageBox.ShowOKCancelToggleBox(nil, desc, nil, function() private.GoCountryMap(countryData) end, Country_Controller.DisableConfirmBox) else private.GoCountryMap(countryData) end end function private.GoCountryMap(countryData) if BattleDataGetter.GetCurLevelID() == HanMapCityID then NotSyncBattleSetter.FindPathByLevelItemIDAndRide(countryData.SceneId, countryData.PosId, nil) else private.destSceneData = countryData local hanCountryData = DataSheetManager.CountryBase:GetDataByID(HanCountryId) NotSyncBattleSetter.FindPathByLevelItemIDAndRide(HanMapCityID, private.destSceneData.PatrolPosId, private.OnEnterHanScene) end EventSystem.Dispatch(EventID.UI_CloseAndRecoverView, Const_UI_Lua.UIEnum.UICountryBase) end function private.OnEnterHanScene() --悬赏任务这里特殊处理到了中立国之后的情况 if private.GoCountryMapOfWantedTask then CTL.CountryWantedTask.OnEnterHanScene() private.GoCountryMapOfWantedTask = nil return end TimerUtil.TimeOut(function () if BattleDataGetter.GetCurLevelID() == HanMapCityID then NotSyncBattleSetter.FindPathByLevelItemIDAndRide(private.destSceneData.SceneId, private.destSceneData.PosId, nil) end private.destSceneData = nil end) end function Country_Controller.GetIsShowConfirmBox() return private.isShowConfirmBox end function Country_Controller.DisableConfirmBox(value) private.isShowConfirmBox = not value end function Country_Controller.GetCountryIdByIndex(index) if index == HanCountryIndex then return HanCountryId end return index end function Country_Controller.GetCountryIndexById(id) if id == HanCountryId then return HanCountryIndex end return id end --头顶国家职位 function Country_Controller.GetColorHeadJobName(countryId, jobId) local jobData = DataSheetManager.CountryJob:GetDataByID(jobId) local jobName = jobData.Title_Table[countryId].JobName return UTL.Color.FormatGradient("fff1c8", "ffba60", string.FormatByIdsId(Const_IDS.IDS_HeadInfoUI_OfficialPosition, UIUtils.GetLocalizedTxt(Const_IDS[jobName]))) end function Country_Controller.CancelJob(targetAcid) if not CTL.Country.ShowResetState() then local officialInfo = MDL.Country.GetOfficialInfo() local targetOfficialInfo = nil for i, v in ipairs(officialInfo.officialList) do if v.showInfo.acid == targetAcid then targetOfficialInfo = v end end local jobName = MDL.Country.GetJobColorName(targetOfficialInfo.position) local name = targetOfficialInfo.showInfo.name local serverId = targetOfficialInfo.showInfo.ShowServerId local str = string.FormatByIdsId(Const_IDS.IDS_Country_DismissOfficerConfirm, CTL.CrossServer.GetServerShowStr(serverId), name, jobName, name) private.cancelJobCbParam = targetAcid UTL.MessageBox.ShowOKCancelBox("", str, private.CancelJobMessageBoxCb) end end function private.CancelJobMessageBoxCb() MDL.Country.CountrySetOfficialReq(private.cancelJobCbParam, MDL.Country.CountryJob.CountryPopulace) end function Country_Controller.OnRefreshCountryInfo(stage, preStage) if stage >= MDL.Country.Stage.CountryBuild then if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UICountryChooseView) then UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryChooseView) MDL.Country.CountryGetMainPanelInfoReq() else MDL.Country.CountryGetMainPanelInfoReq() end if stage == MDL.Country.Stage.CountryReset then local data = MDL.Country.GetCountrySignData() if data == nil then MDL.Country.CountryGetSignInfoReq() MDL.Country.C2GCountryGetStatue() end if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UICountryResetNoticePanel) then UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryResetNoticePanel) end end else if preStage == MDL.Country.Stage.CountryReset then UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryResetExhibitPanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryResetTip) Country_Controller.OnLeaveGuild() end end EventSystem.Dispatch(EventID.Country_OnCountryResetChange) end function Country_Controller.RefreshRedPoint(data) if #data.Days < data.LoginDay then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Country_SignIn) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Country_SignIn) end end function Country_Controller.RefreshWorshipRedPoint() local worshipCount = MDL.Country.GetRemainWorship() if MDL.Country.IsHasCountry() and worshipCount and worshipCount > 0 then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Country_Worship) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Country_Worship) end end function Country_Controller.OnJoinCountry() UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryAfterChooseView) UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UICountryBase) end function Country_Controller.OpenCountryResetPanel() if MDL.Country.GetCurStage() == MDL.Country.Stage.CountryBuildPreBalance then UIManager.OpenView(Const_UI_Lua.UIEnum.UICountryResetNoticePanel) elseif MDL.Country.GetCurStage() == MDL.Country.Stage.CountryReset then UIManager.OpenView(Const_UI_Lua.UIEnum.UICountryResetExhibitPanel) end end function Country_Controller.OnLeaveGuild() UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryChooseView) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryAfterChooseView) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryDefectedPanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryGuildListPanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryGuildRankView) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryRecruitPanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryPopupNationalAppoint) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryPopupContribute) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryPopupGuildAppoint) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryVotePanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryGuildListPanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryPopupNationalList) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountrySetPanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryRenamePanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryNoticePanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryPublicNotice) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryPopupGuildList) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountrySalaryBase) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountrySalarySend) UIManager.CloseView(Const_UI_Lua.UIEnum.UIMessageBoxView) CTL.CountryWantedTask.CloseAllWantedTaskView() EventSystem.Dispatch(EventID.UI_Activity_Close) EventSystem.Dispatch(EventID.UI_CloseAndRecoverView, Const_UI_Lua.UIEnum.UICountryBase) MDL.Country.ResetJoinCountryTime() CTL.ChannelChat.ExitCountry() CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Country_Worship) if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.CrossServerTown) then CTL.Level.TryBreakConveyProgress() if BattleDataGetter.GetAutoFindPathInTownState() then NotSyncBattleSetter.StopAutoFightPathInTown() end end CTL.ChangAnSiege.CloseChangAnSiegeView() end function Country_Controller.FindPathWorshipKing() if MDL.Country.IsHasCountry() then NotSyncBattleSetter.FindPathByLevelItemIDAndRide(HanMapID, StatueLevelItemID, nil) else CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS.IDS_Country_WorshipJoinCountry) end end function private.OnNewDayChanged() if MDL.Country.GetCurStage() == MDL.Country.Stage.CountryReset then MDL.Country.CountryGetSignInfoReq() MDL.Country.C2GCountryGetStatue() end UIManager.CloseView(Const_UI_Lua.UIEnum.UICountryPopupContribute) UIManager.CloseView(Const_UI_Lua.UIEnum.UIMessageBoxView) UIManager.CloseView(Const_UI_Lua.UIEnum.UICountrySalarySend) if leaderEntityID then local entity = BattleDataGetter.GetEntityByEntityID(leaderEntityID) if entity then NotSyncBattleSetter.DeleteInteract(entity, LuaConst.InteractSpecialID.Country_Worship) NotSyncBattleSetter.AddInteract(entity, LuaConst.InteractSpecialID.Country_Worship) end end end function Country_Controller.OnCreateStatue() local CurLevelID = LevelManager.GetCurLevelID() -- 当前场景ID if CurLevelID == HanMapID and MDL.Country.GetCurStage() == MDL.Country.Stage.CountryReset then if leaderEntityID == nil then if MDL.Country.GetRemainWorship() == nil then MDL.Country.C2GCountryGetStatue() else leaderEntityID = private.AddStatueByRoleSceneBasic(MDL.Country.GetStatueBasicInfo()) end end end if MDL.Country.GetCurStage() == MDL.Country.Stage.CountryReset and private.IsFirstOpenExhibitPanel() then if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Country) then CTL.HomeMain.AddTownHomeDelayFunc(private.OpenResetExhibit) end end end function private.OpenResetExhibit() if MDL.Country.GetCurStage() == MDL.Country.Stage.CountryReset then UIManager.OpenView(Const_UI_Lua.UIEnum.UICountryResetExhibitPanel, {playAnimation = true}) end end function private.IsFirstOpenExhibitPanel() local timeValue = PersistentData.PlayerData:Get("NextResetExhibitTime", 0) if timeValue == 0 or timeValue < UTL.Time.GetServerTimestamp() then local closeTime = MDL.Country.GetAllStageTime()[MDL.Country.Stage.CountryReset + 1] PersistentData.PlayerData:Set("NextResetExhibitTime", closeTime.stageEnd, true) return true end return false end function Country_Controller.GetStatueGuildInfoByAcid(acid) if LevelManager.GetCurLevelID() == HanMapID and MDL.Country.GetCurStage() == MDL.Country.Stage.CountryReset then local basicInfo = MDL.Country.GetStatueBasicInfo() for i, v in ipairs(basicInfo) do if v.accid == acid then return v end end end end function private.AddStatueByRoleSceneBasic(roleBasicList) local leaderId = nil local jobIndexDict = {} if roleBasicList then for i, roleBasic in ipairs(roleBasicList) do local jobData = DataSheetManager.CountryJob:GetDataByID(roleBasic.countryInfo.countryJobId) local levelItemID =jobData.StatueID jobIndexDict[roleBasic.countryInfo.countryJobId] = jobIndexDict[roleBasic.countryInfo.countryJobId] or 0 jobIndexDict[roleBasic.countryInfo.countryJobId] = jobIndexDict[roleBasic.countryInfo.countryJobId] + 1 local levelItem = BattleDataGetter.GetLevelItemByID(levelItemID[jobIndexDict[roleBasic.countryInfo.countryJobId]]) local itemData = levelItem.ItemData local pos = itemData.ItemPos local dir = itemData.ItemDir local info = MDL.Country.GetKingCountry() local isLeader = roleBasic.countryInfo.countryJobId == MDL.Country.CountryJob.CountryKing local scale = isLeader and 3 or nil local entityId, entity = SyncMoveManager.AddStatueByRoleSceneBasic(roleBasic, pos, dir, jobData.StatueTitleID, scale) if isLeader then NotSyncBattleSetter.AddInteract(entity, LuaConst.InteractSpecialID.Country_Worship) end if isLeader then leaderId = entityId end end return leaderId end end function Country_Controller.OnGetAllCountryInfo() if MDL.Country.GetCurStage() == MDL.Country.Stage.CountryReset then Country_Controller.OnCreateStatue() end end function Country_Controller.ClearStatues() leaderEntityID = nil end function Country_Controller.GetCountryInfo() local curStage = MDL.Country.GetCurStage() if curStage ~= nil and curStage>= MDL.Country.Stage.CountryBuild then MDL.Country.CountryGetMainPanelInfoReq() end end function Country_Controller.SendMsg(isNotice, text) local str = nil if isNotice then str = string.FormatByIdsId(Const_IDS.IDS_CountrySetting_CountryNoticeMsg, text) CTL.ChannelChat.SendTextMsg(str, MDL.ChannelChat.GetChannelIdByCfgID(MDL.ChannelChat.ChannelCfgId.Country)) else str = string.FormatByIdsId(Const_IDS.IDS_CountrySetting_CountryAnnounceMsg, text) CTL.ChannelChat.SendTextMsg(str, MDL.ChannelChat.GetChannelIdByCfgID(MDL.ChannelChat.ChannelCfgId.WarZone)) end end function Country_Controller.GetRecordParams(paramList) local params = {} for i, v in ipairs(paramList) do if v.type == SRParamType.RewardID then local rewardData = DataSheetManager.CountryRewards:GetDataByID(v.value.uint32Param) local itemData = DataSheetManager.ItemData:GetDataByID(rewardData.ItemID) local colorText = UTL.Color.FormatQualityText(UTL.Item.GetItemDataSpliceByType(rewardData.ItemID).Name, itemData.Color) table.insert(params, colorText) elseif v.type == SRParamType.ItemIDNum then local list = Country_Controller.GetRecordParams(v.value.ParamInfo) local itemStr = nil for i = 1, #list, 2 do local curStr = list[i].."x"..list[i+1] if itemStr == nil then itemStr = curStr else itemStr = itemStr.."、"..curStr end end table.insert(params, itemStr) elseif v.type == SRParamType.PositionID then local jobData = DataSheetManager.GuildJob:GetDataByID(v.value.uint32Param) local str = UIUtils.GetLocalizedTxt(Const_IDS[jobData.JobName]) table.insert(params, str) elseif v.type == SRParamType.NameAcid then local list = Country_Controller.GetRecordParams(v.value.ParamInfo) local str = string.format("%s", list[2], list[1]) table.insert(params, str) else if string.find(v.value.stringParam, "IDS_", 1, true) then table.insert(params, UIUtils.GetLocalizedTxt(Const_IDS[v.value.stringParam])) elseif not string.isNilOrEmpty(v.value.stringParam) then table.insert(params, v.value.stringParam) end end end return params end function Country_Controller.OnCountryWorshipStatue(remainWorship) if remainWorship == 0 then local entity = BattleDataGetter.GetEntityByEntityID(leaderEntityID) NotSyncBattleSetter.DeleteInteract(entity, LuaConst.InteractSpecialID.Country_Worship) end end function Country_Controller.CountryMute(acid, name) if not CTL.Country.ShowResetState() then local count = MDL.Country.GetRemainMute() if count > 0 then local str = string.FormatByIdsId(Const_IDS.IDS_Country_MuteConfirm, name, CountryMuteTime, MDL.Country.GetRemainMute()) UTL.MessageBox.ShowOKCancelBox("", str, function () MDL.Country.CountryMuteReq(acid) end) else CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS.IDS_Country_MuteNumLimit) end end end function Country_Controller.CountryUnMute(acid, name) if not CTL.Country.ShowResetState() then local str = string.FormatByIdsId(Const_IDS.IDS_Country_UnmuteConfirm, name) UTL.MessageBox.ShowOKCancelBox("", str, function() MDL.Country.CountryUnmuteReq(acid) end) end end function private.WorshipClick() if MDL.Country.GetRemainWorship() == nil or MDL.Country.GetRemainWorship() > 0 then MDL.Country.CountryWorshipStatueReq() end end function private.OnGetBetterBuff(name, countryJobData, countryId) if countryId == BattleDataGetter.GetMyCountryID() and countryJobData.BuffID > 0 then local jobName = countryJobData.Title_Table[countryId].JobName local buffData = DataSheetManager.BuffData:GetDataByBuffID(countryJobData.BuffID) local tipsStr = string.FormatByIdsKey("IDS_Country_BattleAura",UIUtils.GetLocalizedTxt(Const_IDS[jobName]), name, UIUtils.GetLocalizedTxt(Const_IDS[buffData.BuffName])) EventSystem.Dispatch(EventID.UI_MainShowTips, tipsStr) end end function Country_Controller.OnFirstEnterScene() if CTL.WarZone.IsWarZoneOpen() then MDL.Country.C2GCountrySelectInfo() end end function Country_Controller.IsUnlockCountry() return MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Country) and CTL.WarZone.GetTimeState() >= CTL.WarZone.TimeState.Preview end function Country_Controller.IsShutUp(channelCfgID) if channelCfgID == MDL.ChannelChat.ChannelCfgId.Country then local muteTime = MDL.Country.GetMuteEndTime() if muteTime > 0 then local nextSendTime = muteTime - UTL.Time.GetServerTimestamp() if nextSendTime > 0 then CTL.Tips.AddTipsMsgAndPlaySound(string.FormatByIdsId(Const_IDS.IDS_Country_MuteChatTip, UTL.Time.FormatTimeBySecondsToHour(nextSendTime))) return true end end end end function private.SortRecordFunc(a, b) return a.RecordTime > b.RecordTime end function Country_Controller.SortRecordList(recordList, typeId) local list = {} for i, v in ipairs(recordList) do local excelData = DataSheetManager.StockroomEvent:GetDataByID(v.EventId) if excelData.EventType == typeId then table.insert(list, v) end end table.sort(list, private.SortRecordFunc) return list end function Country_Controller.ShowResetState() if MDL.Country.GetCurStage() == MDL.Country.Stage.CountryReset then local info = MDL.Country.GetKingCountry() if info.countryID ~= MDL.Country.GetMyCountryId() then CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS.IDS_Country_OnlyWinner) return true end end return false end function Country_Controller.CountryAppointPost(roleInfo) if not CTL.Country.ShowResetState() then UIManager.OpenView(Const_UI_Lua.UIEnum.UICountryChangePosition, {roleInfo = roleInfo}) end end function Country_Controller.SetCountyBgImage(img, isGray) if isGray then UIUtils.SetImageColor(img, GrayColor) UIUtils.SetGray(img, true) else UIUtils.SetGray(img, false) UIUtils.SetImageColor(img, NormalColor) end end function private.CountryPVPSendBattleResult(msg) NetManager.SendMessage(MessageEnums.MessageC2GUploadCountryPvpResult, msg) end function Country_Controller.ClickChooseHref() if MDL.Country.GetCurStage() == MDL.Country.Stage.CoreChoose then Country_Controller.ClickCountryBtn() else CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS.IDS_Country_InviteLinkError) end end function Country_Controller.SetCountryState(state_Country, countryID) if countryID == MDL.Country.CountryType.Wei then state_Country:SetState(2) elseif countryID == MDL.Country.CountryType.Shu then state_Country:SetState(1) elseif countryID == MDL.Country.CountryType.Wu then state_Country:SetState(3) elseif countryID == MDL.Country.CountryType.Qun then state_Country:SetState(0) end end --判断是否是吕布诛天皮肤 武将id22 皮肤id13 function Country_Controller.LvBuMoShenPlayAni(heroId, heroAppearanceID) if heroId == 22 and heroAppearanceID == 13 then local parent = UnityEngine.GameObject.Find(ConstAssetPathConfig.Path3) parent = parent.transform:Find("StageNode/ActorNode") local modelObj = parent.transform:GetChild(0) UIModelUtils.PlayAnimByTrigger("idle_1_loop", "idle_1_loop", modelObj.transform) end end --这个是国家界面说明信息时间格式化方法 返回值有 顺序敏感 改表后要改代码 -- 周五 九点半 desc5, timeStr5 -- 5:00 timeStr6 timeStr61 一个是当日 一个是次日 function Country_Controller.OpenCountryMainNoteView() local param1 = DataSheetManager.ConstData:GetDataByID("CountrySeasonEndPreviewDay").IntValue local param2 = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("CountryDominatingDecayRatio").FloatValue * 100) local desc6, timeStr6 = UTL.Time.GetDateDescAndTime({[1] = 1660}) local desc61, timeStr61 = UTL.Time.GetDateDescAndTime({[1] = 1661}) local desc5, timeStr5 = UTL.Time.GetDateDescAndTime({[1] = 1714}) UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.CountryMain, params = {desc5.." "..timeStr5, param1, string.Concat(desc6, timeStr6), param2}}) end function Country_Controller.OpenCountryChooseNoteView() local param1 = DataSheetManager.ConstData:GetDataByID("GuildActivityPowerOfflineTimeLimit").IntValue local param2 = DataSheetManager.ConstData:GetDataByID("CountryQuitPunishTime").IntValue / UTL.Time.TotalSecondsOneHour UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.CountryChoose, params = {param1 , param2}}) end function Country_Controller.OpenCountrySalaryNoteView() local desc1, timeStr1 = UTL.Time.GetDateDescAndTime({[1] = 1}) local desc2, timeStr2 = UTL.Time.GetDateDescAndTime({[1] = 1716}) UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.CountrySalary, params = {desc2..timeStr2 , desc1..timeStr1}}) end function Country_Controller.GetCountryTimeOpen() local timeInfo = MDL.WarZone.GetTimeInfo() if timeInfo then return timeInfo.startTime - UTL.Time.GetServerTimestamp() + UTL.Time.TotalSecondsOneMinute end end function Country_Controller.CheckConveyCountryMap(mapId) if mapId == HanMapCityID then local curStage = MDL.Country.GetCurStage() if curStage and curStage >= MDL.Country.Stage.CountryBuild then if not MDL.Country.IsHasCountry() then CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS.IDS_Country_NotJoinCountry) else Country_Controller.GoCountryMap(HanCountryId) end else CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS.IDS_Country_CountryNotOpen) end return true end return false end function Country_Controller.CheckIfCanGoToCountryMap() local curStage = MDL.Country.GetCurStage() if curStage and curStage >= MDL.Country.Stage.CountryBuild then if MDL.Country.IsHasCountry() then return true end end return false end function Country_Controller.GetRenderID(heroId) local isSuccess, data = DataSheetManager.CountryHeroModel:TryGetDataByID(heroId) return isSuccess and data.ParamId or 2000 --2000是国家RT默认配置 end function Country_Controller.SetRenderModel(handle, renderModelComp, heroInfo) UTL.UIRender.DisposeSceneTrans(handle) local sceneTrans = renderModelComp:CreateModelObject(ConstAssetPathConfig.Path3, nil) UTL.UIRender.SetCountryBossSceneTrans(handle, sceneTrans) sceneTrans:SetLocalPosition(1600, 1600, 0) local modelPath, equipTable, modelScale, lightPath, heroEffectPath = UTL.UIRender.LoadShowOtherHeroShowModel(heroInfo) local modelParentTrans = sceneTrans:Find("StageNode/ActorNode") local lightParentTrans = sceneTrans:Find("StageNode/LightNode") local lightTrans = renderModelComp:CreateModelObject(lightPath, lightParentTrans) if GameAppInfo.IsVersionGreaterThan16000() then UIModelUtils.SetManualLightHelperActive(lightTrans, false) else local lightComp = lightTrans:GetComponent(typeof(UnityEngine.MonoBehaviour)) lightComp.enabled = false lightTrans:SetLocalEulerAngles(0, 0, 0) end local renderEntity = UTL.UIRender.CreateRenderEntity(modelParentTrans, modelPath, modelScale, UTL.UIRender.GetAnimationCtlPath(modelPath), true) local entityId = renderModelComp:AddEntity(renderEntity) renderEntity.Transform:SetLocalPosition(0, 0, 0) renderEntity.Transform:SetLocalEulerAngles(0, 0, 0) local weaponId = heroInfo.WeaponAppearanceID > 0 and heroInfo.WeaponAppearanceID or heroInfo.HeroID UTL.UIRender.LoadMagicWeapon(heroInfo.HeroID, heroInfo.WeaponAppearanceID, heroInfo.MagicWeaponBreak, heroInfo.IsActiveMagicWeapon, renderEntity, true) --天命 local weaponSoul = CTL.DivineWeaponForgeSoul.GetWeaponSoulSkillByWeaponSoulSceneInfo(heroInfo.HeroID, heroInfo.weaponSoulInfo) if weaponSoul then UTL.UIRender.LoadWeaponSoulByEntity(handle, renderEntity, weaponSoul) end UTL.UIRender.SetRenderEntityDye(renderEntity, heroInfo.HeroAppearanceID, heroInfo.dyeCurPartList, 2) renderModelComp:SetRenderModel(renderModelComp.transform, sceneTrans, modelParentTrans, lightParentTrans, CTL.Country.GetRenderID(heroInfo.HeroID)) renderModelComp:OnLayerActive(true) end --是否在国战场景内 function Country_Controller.IsInCountryScene() local curLevelId = BattleDataGetter.GetCurLevelID() for i,v in DataSheetManager.CountryBase:GetEnumerator() do if curLevelId == v.SceneId then return true end end return false end function private.SetActivityRedPoint() if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Country) then local info = MDL.Country.GetKingCountry() if info then local time = MDL.RedPoint.GetRedPointTimeByType(MDL.RedPoint.RedPointType.CountrySalaryReward) if time and time > 0 and UTL.Time.IsTimestampSameDay(time) then CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Country_SalaryReward) else CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Country_SalaryReward) end end else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Country_SalaryReward) end end return Country_Controller