-- GVE布阵界面 local UIFreeLineupSelectOfficer = require("View/FreeLineUp/UIFreeLineupSelectOfficer") local UISlgGvESelectOfficer = UIViewClass(UIFreeLineupSelectOfficer) function UISlgGvESelectOfficer:Init() self.UIState_NationClimbTower:SetState(0) self:RegistSystemEvent(EventID.UI_SlgGvE_LineUpLockOrClear, self.CloseLineUpView) -- 确定阵容 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_DemonGod_UI_9) self.teamNums = MDL.FreeLineUp.TeamNums.Multi --缓存的队伍数量(多队) self.curKingdom = MDL.Country.CountryType.Han --无国别限制 self.kingdomLimitType = CTL.FreeLineUp.KingdomLimitShowType.SingleFlag --布阵国别限制的旗帜表现 self.gsIdsType = CTL.FreeLineUp.GsBasicType.Military --布阵战力的包装 CTL.SlgGvE.SetCurSelectTeamId(self.teamId) self:SetOriginLineUpData() end function UISlgGvESelectOfficer:SetOriginLineUpData() self.isOriginLineUpEmpty = true self.originLineInfo = self:GetLineUpsInfoArr() if self.originLineInfo and self.originLineInfo.heroInfos then for _, v in ipairs(self.originLineInfo.heroInfos) do if v.heroId ~= 0 then self.isOriginLineUpEmpty = false end end end end function UISlgGvESelectOfficer:RefreshKingdomState() UIUtils.SetActive(self.group_Flag, false) UIUtils.SetActive(self.group_CountryLimit, false) end function UISlgGvESelectOfficer:InitTeamSlotUnlock() for index, v in ipairs(self.group_Buttons) do v.btn_team:SetGray(false, true) if self.selectTeamId == index then v.state_Button:SetState(1) else v.state_Button:SetState(0) end UIUtils.SetActive(v.img_Lock, false) end end function UISlgGvESelectOfficer:RefreshSelectOfficerView() UIUtils.SetActive(self.hideOtherTeamHero.gameObject, true) self:InitCountrySelectToggle() self:RefreshTeamInfo() self:RefreshFilterCountryHeroList() UIUtils.SetActive(self.img_TipBg, true) end function UISlgGvESelectOfficer:GetLineUpsInfoArr() for _, lineInfo in ipairs(MDL.FreeLineUp.GetLineUpInfoByFunctionType(self.freeLineupFuncType)) do if lineInfo.lineNumber == self.teamId then return lineInfo end end end function UISlgGvESelectOfficer:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseLineUpView(false) elseif comp == self.UITemplateTitlePanel.btn_Home then self.isServerClose = false CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, { id = LuaConst.NoteID.SlgGvELineUp}) elseif comp == self.btn_Formation then UIManager.OpenView( Const_UI_Lua.UIEnum.UISlgGveFreeLineupDetailPanel, {id = MDL.FreeLineUp.FuncType.SlgGvE, heroList = self.allHeroList, lineNumber = self.teamId}, Const_UI_Lua.UIEnum.UIFreeLineupDetailPanel ) elseif comp == self.btn_Fight then self:ExecuteFightFunc() else self:OnTeamSlotBtnClick(comp) end end function UISlgGvESelectOfficer:CloseLineUpView(isServerClose) self.isServerClose = isServerClose self:CloseView() end function UISlgGvESelectOfficer:ExecuteFightFunc() -- 检查阵容上将情况 if self:CheakLineUp() then if self.isOriginLineUpEmpty then UTL.MessageBox.ShowOKCancelBox(nil, UIUtils.GetLocalizedTxt(Const_IDS.IDS_SlgGve_BattleArray_Hint_12), function() MDL.FreeLineUp.FreeLineUpLockOrClearReq(MDL.FreeLineUp.FuncType.SlgGvE, true) end) return end if self:IsHasHeroDownLineup() then UTL.MessageBox.ShowOKCancelBox(nil, UIUtils.GetLocalizedTxt(Const_IDS.IDS_SlgGve_BattleArray_Hint_1), function() MDL.FreeLineUp.FreeLineUpLockOrClearReq(MDL.FreeLineUp.FuncType.SlgGvE, true) end) return end MDL.FreeLineUp.FreeLineUpLockOrClearReq(MDL.FreeLineUp.FuncType.SlgGvE, true) end end function UISlgGvESelectOfficer:IsHasHeroDownLineup() if self.originLineInfo and self.originLineInfo.heroInfos then for _, v in ipairs(self.originLineInfo.heroInfos) do if v.heroId > 0 and not table.containValue(self.allHeroList, v.heroId) then return true end end end return false end -- 左侧槽位刷新 function UISlgGvESelectOfficer:OnTeamSlotBtnClick(btnComp) for k,v in ipairs(self.group_Buttons) do if btnComp == v.btn_team then if self.selectTeamId ~= k then v.state_Button:SetState(1) self.group_Buttons[self.selectTeamId].state_Button:SetState(0) self.selectTeamId = k self:RefreshTeamInfo() end end end end -- 面板右侧显示 function UISlgGvESelectOfficer:RefreshRightPanelInfo() UIUtils.SetLabel(self.txt_BR, 0) UIUtils.SetActive(self.group_Sopt1.img_Lock, false) UIUtils.SetActive(self.group_Sopt2.img_Lock, false) UIUtils.SetActive(self.img_ScoreBg, false) UIUtils.SetLabel(self.txt_Tips, "") end function UISlgGvESelectOfficer:SetLineUps() MDL.FreeLineUp.FreeLineUpSetRequest( self.freeLineupFuncType, MDL.FreeLineUp.GetFreeLineUpLineNumber(self.freeLineupFuncType), MDL.FreeLineUp.SetType.Simulate, self.allHeroList ) end --检查是否可以保存布阵 function UISlgGvESelectOfficer:CheakLineUp() if self:GetTeamPos(1, 1) > 0 then for i = 2, 3 do if self:GetTeamPos(1, i) <= 0 and self:GetTeamPos(2, i) > 0 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_SiegeCity_LineupTips_2"]) self:OnTeamSlotBtnClick(self.group_Buttons[i].btn_team) return false end end return true else CTL.Tips.AddTipsMsg(Const_IDS["IDS_SiegeCity_LineupTips_1"]) self:OnTeamSlotBtnClick(self.group_Buttons[1].btn_team) return false end end function UISlgGvESelectOfficer:IsMeetHeroFilter(heroId, heroKingdom) if not self.selectCountryToggle or self.selectCountryToggle == 0 then if self.toggle_hideOtherTeamHero.isOn then local isLineUp, isCurTeam = self:IsHeroLineUpInAllTeams(heroId) return not (isLineUp and not isCurTeam) else return true end end if heroKingdom == self.selectCountryToggle then if self.toggle_hideOtherTeamHero.isOn then local isLineUp, isCurTeam = self:IsHeroLineUpInAllTeams(heroId) return not (isLineUp and not isCurTeam) else return true end end return false end function UISlgGvESelectOfficer:GetHeroHavePos(heroId) local lineUps = MDL.FreeLineUp.GetLineUpInfoByFunctionType(self.freeLineupFuncType) if lineUps then for k,teamInfo in ipairs(lineUps) do if teamInfo.lineNumber == self.teamId then for _, heroInfo in ipairs(teamInfo.heroInfos) do if heroInfo.heroId == heroId then return heroInfo.posNumber end end end end end return 0 end function UISlgGvESelectOfficer:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_AvailableHero then UTL.Item.SetHeroIconByHeroId(cellTable.img_SelectedHero, data.heroCfg.ID, MDL.HeroAwaken.GetIsHeroAwaken(data.heroCfg.ID)) local quality = CTL.HeroAwaken.GetHeroQuality(data.heroCfg.ID, MDL.HeroAwaken.GetIsHeroAwaken(data.heroCfg.ID)) UTL.Color.SetQualityImageByType(cellTable.img_QualityFrame, quality, UTL.Color.QualityType.HeroSelectFrame) UTL.Color.SetQualityImageByType(cellTable.img_QualityHead, quality, UTL.Color.QualityType.HeroSelectBg) if data.serverInfo.HeroBreakLv == 0 then UIUtils.SetActive(cellTable.img_Bg, false) else UIUtils.SetActive(cellTable.img_Bg, true) UIUtils.SetLabel(cellTable.txt_BR, "+"..data.serverInfo.HeroBreakLv) UIUtils.SetActive(cellTable.img_BR, false) end if self.teamId then local isLineUp = self:IsHeroLineUpInAllTeams(data.heroCfg.ID) UIUtils.SetActive(cellTable.img_BlackCover, isLineUp) else UIUtils.SetActive(cellTable.img_BlackCover, self:GetHeroHavePos(data.heroCfg.ID) > 0) end end end function UISlgGvESelectOfficer:OnClosed() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) if not self.isServerClose then MDL.FreeLineUp.FreeLineUpLockOrClearReq(MDL.FreeLineUp.FuncType.SlgGvE, false) end end return UISlgGvESelectOfficer