--UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UISyncFourCountryWarSelectHeroPanel, nil, Const_UI_Lua.UIEnum.UISyncTeamPVPSelectHeroPanel) --UIManager.CloseView(Const_UI_Lua.UIEnum.UISyncFourCountryWarSelectHeroPanel) local UITeamSelectHeroBasePanel = require("View.FairPlay.UITeamSelectHeroBasePanel") local UISyncFourCountryWarSelectHeroPanel = UIViewClass(UITeamSelectHeroBasePanel) local CountryBG = { ConstAssetPathConfig.AssetPath214, ConstAssetPathConfig.AssetPath215, ConstAssetPathConfig.AssetPath216, ConstAssetPathConfig.AssetPath217, } local CountryTitleBG = { ConstAssetPathConfig.AssetPath218, ConstAssetPathConfig.AssetPath219, ConstAssetPathConfig.AssetPath220, ConstAssetPathConfig.Path47, } function UISyncFourCountryWarSelectHeroPanel:OnOpened(context) self.gameTime = MDL.SyncFourCountryWar.GetTickTime() - UTL.Time.GetServerTimestamp() self.isSelfReady = MDL.SyncTeamPVP.GetSelfReadyState() if self.isSelfReady then self:ShowAlreadyPrepared() else self:OnCancelReady() end self.countryId = context.countryId self.obj_mask.gameObject:SetActive(false) self.countryState:SetState(1) self.state_Country:SetState(self.countryId - 1) UIUtils.SetImageByAssetBundle(self.img_BG01, CountryTitleBG[self.countryId]) UIUtils.SetImageByAssetBundle(self.img_BG02, CountryBG[self.countryId]) UIUtils.SetActive(self.group_PVPData, false) UIUtils.SetActive(self.group_SFCWData, false) self.fairPlayType = MDL.FairPlay.FairPlayType.FourCountryWar MDL.FairPlay.FairGetFixAttrReq(MDL.FairPlay.FairPlayType.FourCountryWar) end function UISyncFourCountryWarSelectHeroPanel:InitVoice() self.voiceRoomType = MDL.VoiceRoom.VoiceRoomType.Room_SyncFourCountry UITeamSelectHeroBasePanel.InitVoice(self) CTL.ChannelChat.TryCreateDynamicChannel(MDL.ChannelChat.ChannelCfgId.MyCamp) end local function SortHeroFunc(a, b) if a.isFree == b.isFree then local aHeroData = DataSheetManager.HeroNum:GetDataByID(a.heroId) local bHeroData = DataSheetManager.HeroNum:GetDataByID(b.heroId) if aHeroData.HeroIntelligence == bHeroData.HeroIntelligence then return a.heroId > b.heroId end return aHeroData.HeroIntelligence > bHeroData.HeroIntelligence else return a.isFree end end function UISyncFourCountryWarSelectHeroPanel:InitHeroList() self.heroList = {} self.countryId = self.context.countryId local heroList = MDL.HeroSelect.GetHasHeroList() for i, v in ipairs(heroList) do local heroData = DataSheetManager.HeroNum:GetDataByID(v.heroId) if heroData.Kingdom == self.countryId then table.insert(self.heroList, { heroId = v.heroId, isFree = false }) end end local freeHeroList = MDL.SyncFourCountryWar.GetFreeHeroList()[self.countryId].FreeHeroIds for i, v in ipairs(freeHeroList) do local itemData = DataSheetManager.ItemData:GetDataByID(v) local heroId = itemData.BelongToHero if not self:ContainHeroId(self.heroList, heroId) then table.insert(self.heroList, { heroId = heroId, isFree = true }) end end table.sort(self.heroList, SortHeroFunc) CTL.HeroAwaken.TryFillAwakenHeroData(self.heroList, false) for i, v in ipairs(self.heroList) do self.loopscroll_Head:AddData(v, 0) end end function UISyncFourCountryWarSelectHeroPanel:InitCellextra(scrollRect, index, cellTable, data) UIUtils.SetActive(cellTable.img_FreeBg, data.isFree) UIUtils.SetActive(cellTable.img_TestBg, false) end function UISyncFourCountryWarSelectHeroPanel:GetTeamMembersInfo() self.teamMembers = MDL.SyncFourCountryWar.GetMatchResult().friendlyFighters for k, v in pairs(self.teamMembers) do if v.acid ~= BattleDataGetter.GetAcID() then if self.role1Info == nil then self.role1Info = v elseif self.role2Info == nil then self.role2Info = v return end end end end return UISyncFourCountryWarSelectHeroPanel