local UICountryAfterChooseView = UIViewClass() function UICountryAfterChooseView:OnOpened(context) self.hasDominateCountry = false self.countryArray = { self.panel_CountryWei, self.panel_CountryShu, self.panel_CountryWu, self.panel_CountryQun } self:RegistSystemEvent(EventID.Country_OnGetFoundCountry, self.SetAllCountry) MDL.Country.CountryGetMainPanelInfoReq() UIUtils.SetActive(self.group_Country.gameObject, false) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_Country_FunctionName) end function UICountryAfterChooseView:SetAllCountry() local allCountry = MDL.Country.GetCountryInfo() if allCountry then for i, v in ipairs(allCountry) do local collection = self.countryArray[CTL.Country.GetCountryIndexById(v.countryID)] UIUtils.SetActive(collection.group_Overlord , v.isDominate) if v.isDominate then self.hasDominateCountry = true end end end self:OnButtonClicked(self.countryArray[1].map_Btn) if not MDL.Guild.GetMyGuildInfo().isEndTriaRun then UIUtils.SetLabelText(self.group_Country.txt_Tria, Const_IDS.IDS_Country_TrialGuildCannotJoin) UIUtils.SetActive(self.group_Country.btn_Join, false) UIUtils.SetActive(self.group_Country.btn_Random, false) return end self:DominateCountryShow() self:SetNextTime() end function UICountryAfterChooseView:DominateCountryShow() if not self.hasDominateCountry then UIUtils.SetActive(self.group_Country.btn_Join, false) local cdTime = os.difftime(MDL.Country.GetNextDominatingTime(), UTL.Time.GetServerTimestamp()) CTL.Country.SetCdTime(self.group_Country.txt_Tips, cdTime, Const_IDS.IDS_CountrySelection_FreeSelectionNotOpen) self:StartRepeatFunc(self.DominateCountryBuild, cdTime + 3, 1) end end function UICountryAfterChooseView:DominateCountryBuild() MDL.Country.CountryGetMainPanelInfoReq() end function UICountryAfterChooseView:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView() elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.group_Country.btn_Random then if not MDL.Guild.CheckLeader(1) then CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS.IDS_Guild_OnlyLead) elseif self.isInCD then local nextJoinCountryTime = MDL.Country.GetNextJoinCountryTime() local cdTime = os.difftime(nextJoinCountryTime, UTL.Time.GetServerTimestamp()) CTL.Tips.AddTipsMsg(Const_IDS["IDS_CountrySelection_InPunishTime"], UTL.Time.FormatTimeBySecondsToHour(cdTime)) else UTL.MessageBox.ShowOKCancelBox("", Const_IDS.IDS_CountrySelection_SystemSelectConfirm, function() MDL.Country.CountryGuildJoinReq(0, true) end) end elseif comp == self.group_Country.btn_Join then if not MDL.Guild.CheckLeader(1) then CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS.IDS_Guild_OnlyLead) elseif self.isInCD then local nextJoinCountryTime = MDL.Country.GetNextJoinCountryTime() local cdTime = os.difftime(nextJoinCountryTime, UTL.Time.GetServerTimestamp()) CTL.Tips.AddTipsMsg(Const_IDS["IDS_CountrySelection_InPunishTime"], UTL.Time.FormatTimeBySecondsToHour(cdTime)) else self:ClickJoin(self.selectIndex) end elseif comp == self.group_Country.group_Officer.boss_Chat then CTL.Friend.PrivateTalkToAcid(self.leaderAcid) elseif comp == self.group_Country.group_Officer.neishi_Chat then CTL.Friend.PrivateTalkToAcid(self.neishiAcid) elseif comp == self.btn_Rank then CTL.Rank.OpenRankPanelByType(MDL.Rank.RankType.Country) elseif comp == self.UITemplateTitlePanel.btn_Info then CTL.Country.OpenCountryMainNoteView() else for i, v in ipairs(self.countryArray) do if v.map_Btn == comp then self.selectIndex = i self:ShowCountry(i) break end end end end function UICountryAfterChooseView:ShowCountry(index) UIUtils.SetActive(self.group_Country.gameObject, true) local data = MDL.Country.GetFoundCountryInfo(index) UIUtils.SetActive(self.group_Country.img_Overlord, data.isDominate) self.group_Country.txt_Info1.text = data.dominating self.group_Country.txt_Info2.text = data.money self.group_Country.txt_Notice.text = MDL.Country.GetCountryAnnouncement(data.declaration, data.countryID) CTL.Country.SetCountryImage(self.group_Country, data.countryID) local countryData = DataSheetManager.CountryBase:GetDataByID(data.countryID) UIUtils.SetImageByAssetBundle(self.group_Country.img_FlagBg, countryData.CountryPlatePath) self.group_Country.txt_Country.text = MDL.Country.GetCountryTitle(data.reignTitle, data.countryID) local leaderRoleInfo = MDL.Country.GetCountryLeader(data.officialList).showInfo local leaderCollection = self.group_Country.group_Officer CTL.Player.OperateGenderImage(leaderCollection.leader_Gender, leaderRoleInfo.sex) leaderCollection.txt_JobPlayerName.text = leaderRoleInfo.name self.leaderAcid = leaderRoleInfo.acid local yushiCollection = self.group_Country.group_Officer local yushiResult = MDL.Country.GetCountryOfficial(data.officialList, MDL.Country.CountryJob.CountryCommander1) if yushiResult and #yushiResult > 0 then local roleInfo = yushiResult[1].showInfo UIUtils.SetActive(leaderCollection.neishi_Gender, true) UIUtils.SetActive(leaderCollection.neishi_Empty, false) UIUtils.SetActive(leaderCollection.neishi_Chat, true) CTL.Player.OperateGenderImage(leaderCollection.neishi_Gender, roleInfo.sex) leaderCollection.txt_NeishiName.text = roleInfo.name self.neishiAcid = roleInfo.acid else UIUtils.SetLabelText(leaderCollection.neishi_Empty, Const_IDS.IDS_GuildApply_Label7) UIUtils.SetActive(leaderCollection.neishi_Gender, false) UIUtils.SetActive(leaderCollection.neishi_Empty, true) UIUtils.SetActive(leaderCollection.neishi_Chat, false) leaderCollection.txt_NeishiName.text = nil self.neishiAcid = nil end self.selectState:SetState(index - 1) local jobData = DataSheetManager.CountryJob:GetDataByID(MDL.Country.CountryJob.CountryCommander1) UIUtils.SetLabelText(yushiCollection.txt_JobBoss, Const_IDS[jobData.Title_Table[index].JobName]) local jobData = DataSheetManager.CountryJob:GetDataByID(MDL.Country.CountryJob.CountryKing) UIUtils.SetLabelText(yushiCollection.txt_JobLeader, Const_IDS[jobData.Title_Table[index].JobName]) end function UICountryAfterChooseView:SetNextTime() local nextJoinCountryTime = MDL.Country.GetNextJoinCountryTime() if nextJoinCountryTime and nextJoinCountryTime > 0 then local cdTime = os.difftime(nextJoinCountryTime, UTL.Time.GetServerTimestamp()) self.isInCD = cdTime > 0 if not self.isInCD then self:RefreshCD() else CTL.Country.SetCdTime(self.group_Country.txt_Tips, cdTime, Const_IDS.IDS_CountrySelection_PunishTimeCountdown) self:StartRepeatFunc(self.RefreshCD, cdTime + 1, 1) end end end function UICountryAfterChooseView:RefreshCD() self.isInCD = false if self.hasDominateCountry then UIUtils.SetActive(self.group_Country.btn_Join, true) self.group_Country.txt_Tria.text = nil else self:DominateCountryShow() end end function UICountryAfterChooseView:ClickJoin(index) local countryName = string.FormatByIdsId(Const_IDS.IDS_CountrySelection_GuildLeaderSelectConfirm, CTL.Country.GetCountryFullName(index)) local data = MDL.Country.GetFoundCountryInfo(index) if data.isDominate then CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS.IDS_CountrySelection_CannotSelectEmperorCountry) return end UTL.MessageBox.ShowOKCancelBox("", countryName, function() MDL.Country.CountryGuildJoinReq(index, false) end ) end return UICountryAfterChooseView