-- 自选将布阵Base -- 子界面继承: -- UIStormSelectOfficer -- UIDemonGodSelectOfficer -- UINationClimbTowerSelectOfficer local UIFreeLineupSelectOfficer = UIViewClass() local bgImagePath = ConstAssetPathConfig.bgImagePath local NO_KINGDOM = MDL.Country.CountryType.Han --无国别时KingdomId local RefinedHintTime = "UIFreeLineupSelectOfficer_RefinedHintTime" -- 基类已修改方便后续继承 -- 1. self.freeLineupFuncType 自选将类型 -- 2. self.curActivityType 对应的活动type -- 3. self.teamId 部分玩法以队伍来缓存多组,使用teamId作为lineNumber (SlgGvE) -- BASE方法被继承使用,修改需要同时修改子类: -- CheckHeroLineups() 点击按钮前的判断逻辑 -- ExecuteFightFunc() 出战按钮点击逻辑 -- IsTeamPosLockedUp() 槽位是否已步 -- RefreshSelectOfficerView() 刷新界面 -- RefreshRightPanelInfo() 刷新右侧信息 -- Init() 更新子玩法的UI显示 function UIFreeLineupSelectOfficer:OnOpened(context) self:RegistSystemEvent(EventID.UI_FreeLineUp_RefreshUI, self.RefreshSelectOfficerView) self.selectTeamId = 1 self.allHeroList = {-1, -1, -1, -1, -1, -1} self.selectHeroIndex = -1 -- view成员变量(继承按需修改) self.teamNums = MDL.FreeLineUp.TeamNums.Single --缓存的队伍数量(默认单队) self.freeLineupFuncType = context.freeLineupFuncType self.curActivityType = context.activityType self.teamId = context.teamId --如果是以队伍来区分的布阵玩法,才需要有teamId self.kingdomLimitType = CTL.FreeLineUp.KingdomLimitShowType.SingleFlag --布阵国别限制的旗帜表现(默认为界面左下方单国别限制) self.gsIdsType = CTL.FreeLineUp.GsBasicType.Normal --布阵战力的包装 self.UIState_NationClimbTower:SetState(0) UIUtils.SetLabelText(self.lab_Limit, Const_IDS.IDS_SiegeCity_HeroLimit) self:Init() self:InitTeamSlotUnlock() -- 日服屏蔽 MDL.FreeLineUp.FreeLineUpGetInfoRequest(self.freeLineupFuncType) self:RefreshKingdomState() end function UIFreeLineupSelectOfficer:RefreshKingdomState() UIUtils.SetActive(self.group_Flag, false) UIUtils.SetActive(self.group_CountryLimit, false) if self.curKingdom == NO_KINGDOM then -- 无国别限制 if self.kingdomLimitType == CTL.FreeLineUp.KingdomLimitShowType.SingleFlag then UIUtils.SetActive(self.group_Flag, true) self.state_no_country:SetState(1) UIUtils.SetLabelText(self.lab_NationClimb, Const_IDS.IDS_Mine_Captured_NoLimit) else UIUtils.SetActive(self.group_CountryLimit, true) for _, v in ipairs(self.group_Flags) do UIUtils.SetActive(v, true) end end elseif self.curKingdom > 0 and self.curKingdom < 5 then -- 限制单国别 if self.kingdomLimitType == CTL.FreeLineUp.KingdomLimitShowType.SingleFlag then UIUtils.SetActive(self.group_Flag, true) self.state_no_country:SetState(0) self.state_countries:SetState(self.curKingdom - 1) UIUtils.SetLabelText(self.lab_NationClimb, Const_IDS.IDS_Mine_TodayLimit) else for _, v in ipairs(self.group_Flags) do UIUtils.SetActive(v, false) end UIUtils.SetActive(self.group_CountryLimit, true) UIUtils.SetActive(self.group_Flags[self.curKingdom], true) end else -- 限制组合国别 self:RefreshMutilKingdomLimit() end end -- 组合国别 -- 比如魏国1、蜀国2 ==> curKingdom为12; 魏国1、蜀国2、吴国3 ==> curKingdom为123 function UIFreeLineupSelectOfficer:RefreshMutilKingdomLimit() UIUtils.SetActive(self.group_CountryLimit, true) for _, v in ipairs(self.group_Flags) do UIUtils.SetActive(v, false) end local kindom1 = self.curKingdom%10 UIUtils.SetActive(self.group_Flags[kindom1], true) if self.curKingdom < 100 then local kindom2 = math.floor(self.curKingdom/10) UIUtils.SetActive(self.group_Flags[kindom2], true) elseif self.curKingdom < 1000 then local kindom2 = math.floor(self.curKingdom/100) local kindom3 = math.floor(self.curKingdom%100/10) UIUtils.SetActive(self.group_Flags[kindom2], true) UIUtils.SetActive(self.group_Flags[kindom3], true) end end --region ==================== 需继承功能 =========================== -- BASE function UIFreeLineupSelectOfficer:Init() -- 初始化界面标题、玩法说明等信息 end -- BASE function UIFreeLineupSelectOfficer:RefreshSelectOfficerView() -- 刷新玩法自定义信息 end -- BASE function UIFreeLineupSelectOfficer:RefreshRightPanelInfo() -- 操作时右侧需要刷新的内容 end --BASE function UIFreeLineupSelectOfficer:IsTeamPosLockedUp() -- 已步槽位是否锁定、无特殊需求不锁定 return false end -- BASE function UIFreeLineupSelectOfficer:ExecuteFightFunc() -- 按钮点击逻辑 end -- BASE function UIFreeLineupSelectOfficer:CheckHeroLineups() -- 检查布阵状况 end -- BASE function UIFreeLineupSelectOfficer:IsMeetHeroFilter(heroId, heroKingdom) -- 武将是否满足手动筛选条件(手动筛选国别,隐藏其他队伍等) end --endregion --region ==================== 基础功能 =========================== function UIFreeLineupSelectOfficer:InitTeamSlotUnlock() self.teamSlotUnlock = {} for k, v in ipairs(self.group_Buttons) do local isSlotUnlock = MDL.HeroSelect.GetTeamLevel() >= MDL.FreeLineUp.FreeLineUpSlotUnlockList[k] if isSlotUnlock then table.insert(self.teamSlotUnlock, true) else table.insert(self.teamSlotUnlock, false) end v.btn_team:SetGray(not isSlotUnlock, true) UIUtils.SetActive(v.img_Lock, not isSlotUnlock) if self.selectTeamId == k then v.state_Button:SetState(1) else v.state_Button:SetState(0) end end end -- 左侧槽位解锁刷新 function UIFreeLineupSelectOfficer:OnTeamSlotBtnClick(btnComp) for k,v in ipairs(self.group_Buttons) do if btnComp == v.btn_team then if self.selectTeamId ~= k then if MDL.HeroSelect.GetTeamLevel() >= MDL.FreeLineUp.FreeLineUpSlotUnlockList[k] then v.state_Button:SetState(1) self.group_Buttons[self.selectTeamId].state_Button:SetState(0) self.selectTeamId = k self:RefreshTeamInfo() else if MDL.FreeLineUp.FreeLineUpSlotUnlockList[k] == 999 then -- 解锁等级为999时,默认槽位功能运营暂不开放 CTL.Tips.AddTipsMsg(Const_IDS.IDS_DemonGod_UI_36) else local tlData = DataSheetManager.TeamLevelData:GetDataByTeamLevel(MDL.FreeLineUp.FreeLineUpSlotUnlockList[k]) if tlData ~= nil then local _levelStr = UTL.Item.GetNobilityByTeamLevel(tlData.TeamLevel) -- 爵位转换 local teamLevelName = string.FormatByIdsId(Const_IDS[tlData.TeamLevelName], _levelStr) CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_51, teamLevelName)) end end end end end end end function UIFreeLineupSelectOfficer:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_AvailableHero then UTL.Item.SetHeroIconByHeroId(cellTable.img_SelectedHero, data.heroCfg.ID, data.serverInfo.heroAwaken) UTL.Color.SetQualityImageByType(cellTable.img_QualityFrame, CTL.HeroAwaken.GetHeroQuality(data.heroCfg.ID, data.serverInfo.heroAwaken), UTL.Color.QualityType.HeroSelectFrame) UTL.Color.SetQualityImageByType(cellTable.img_QualityHead, CTL.HeroAwaken.GetHeroQuality(data.heroCfg.ID, data.serverInfo.heroAwaken), UTL.Color.QualityType.HeroSelectBg) UIUtils.SetLabel(cellTable.txt_BR, data.serverInfo.heroBaseGs) 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 --return 是否所有队伍中该武将已上阵; 是否在本队 function UIFreeLineupSelectOfficer:IsHeroLineUpInAllTeams(heroId) local lineUps = MDL.FreeLineUp.GetLineUpInfoByFunctionType(self.freeLineupFuncType) if lineUps then for k, teamInfo in ipairs(lineUps) do for _, heroInfo in ipairs(teamInfo.heroInfos) do if heroInfo.heroId == heroId then return true, teamInfo.lineNumber == self.teamId end end end end return false, false end function UIFreeLineupSelectOfficer:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_AvailableHero then local heroPosNum = self:GetHeroHavePos(data.heroCfg.ID) local key1, key2 = 1, 2 if self.selectTeamId == 2 then key1, key2 = 3, 4 elseif self.selectTeamId == 3 then key1, key2 = 5, 6 end if heroPosNum > 0 and heroPosNum ~= key1 and heroPosNum ~= key2 and (self:GetTeamPos(1) <= 0 or self:GetTeamPos(2) <= 0) then -- 有空位可以强制替换主将 self:CanForceReplaceHeroPos(data, heroPosNum) return elseif heroPosNum > 0 and heroPosNum ~= key1 and heroPosNum ~= key2 and self:GetTeamPos(1) > 0 and self:GetTeamPos(2) > 0 then --编队满人不让换 CTL.Tips.AddTipsMsg(Const_IDS.IDS_BossChallenge_ChooseHero_FullHero) return end if self:IsTeamPosLockedUp(self.selectTeamId) then CTL.Tips.AddTipsMsg(Const_IDS.IDS_DemonGod_UI_43) return end if self.teamId then local isLineUp, isCurTeam = self:IsHeroLineUpInAllTeams(data.heroCfg.ID) if isLineUp and not isCurTeam then CTL.Tips.AddTipsMsg(Const_IDS.IDS_DemonGod_UI_42) return end end if self:GetHeroHavePos(data.heroCfg.ID) > 0 then self.allHeroList[self:GetHeroHavePos(data.heroCfg.ID)] = -1 else if self:GetTeamPos(1) <= 0 then self:SetTeamPos(data.heroCfg.ID, self:GetTeamPos(2)) elseif self:GetTeamPos(2) <= 0 then self:SetTeamPos(self:GetTeamPos(1), data.heroCfg.ID) elseif self:GetTeamPos(1) > 0 and self:GetTeamPos(2) > 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_BossChallenge_ChooseHero_FullHero) return end end self.selectHeroIndex = index self:SetLineUps() end end function UIFreeLineupSelectOfficer:RefreshHeroList() local isHaveHero = false local heroList = {} local demonGodFreeLineUpList = MDL.FreeLineUp.GetLineUpSpareHeroInfoList() if demonGodFreeLineUpList and #demonGodFreeLineUpList > 0 then for k,v in ipairs(demonGodFreeLineUpList) do local heroData = DataSheetManager.HeroNum:GetDataByID(v.heroId) if self:IsLimitKindom(heroData.Kingdom) then isHaveHero = true table.insert(heroList, {heroCfg = heroData, serverInfo = v}) end end end if self.selectHeroIndex == -1 then self.loop_AvailableHero:ReloadAll(heroList) elseif self.selectHeroIndex > -1 then self.loop_AvailableHero:UpdateIndex(self.selectHeroIndex, heroList[self.selectHeroIndex + 1]) self.selectHeroIndex = -1 end if isHaveHero then UIUtils.SetLabel(self.txt_NoActiveHeroTips, "") else UIUtils.SetLabelText(self.txt_NoActiveHeroTips, Const_IDS.IDS_Guild_BlankContent) end self:RefreshTeamInfo() end function UIFreeLineupSelectOfficer:IsLimitKindom(kingdom) if self.curKingdom == NO_KINGDOM then return true end if kingdom == self.curKingdom then return true end if self.curKingdom > 10 and self.curKingdom < 100 then if math.floor(self.curKingdom/10) == kingdom or self.curKingdom%10 == kingdom then return true end elseif self.curKingdom > 100 and self.curKingdom < 1000 then if math.floor(self.curKingdom/100) == kingdom or math.floor(self.curKingdom%100/10) == kingdom or self.curKingdom%10 == kingdom then return true end end return false end function UIFreeLineupSelectOfficer:RefreshTeamInfo() self:RefreshPosTitle() self:RefreshRightPanelInfo() self.allHeroList = {-1, -1, -1, -1, -1, -1} self.posNumber1, self.posNumber2 = CTL.FreeLineUp.GetLineUpPosNumByTeamID(self.selectTeamId) self.allGs = 0 --如果服务器没清理上次的队伍 需要给基类设置成 self.teamNums = MDL.FreeLineUp.TeamNums.Multi if self.teamNums == MDL.FreeLineUp.TeamNums.Single then self:RefreshSingleTeamInfo() elseif self.teamNums == MDL.FreeLineUp.TeamNums.Multi then self:RefreshMultiTeamInfo() end end function UIFreeLineupSelectOfficer:RefreshSingleTeamInfo() local lineUps = MDL.FreeLineUp.GetLineUpInfoByFunctionType(self.freeLineupFuncType) self:RefreshInfo() if lineUps then for k,v in ipairs(lineUps) do self:RefreshHeroInfos(v) end end end function UIFreeLineupSelectOfficer:RefreshMultiTeamInfo() local lineUps = self:GetLineUpsInfoArr() self:RefreshInfo() if lineUps then self:RefreshHeroInfos(lineUps) end end function UIFreeLineupSelectOfficer:RefreshPosTitle() local posTitle = Const_IDS.IDS_DemonGod_UI_30 if self.selectTeamId == 2 then posTitle = Const_IDS.IDS_DemonGod_UI_31 elseif self.selectTeamId == 3 then posTitle = Const_IDS.IDS_DemonGod_UI_32 end UIUtils.SetLabel(self.txt_TotalBR, string.FormatByIdsId(CTL.FreeLineUp.GsPosTitleIDS[self.gsIdsType], UIUtils.GetLocalizedTxt(posTitle))) end function UIFreeLineupSelectOfficer:RefreshInfo() self.group_Sopt1.state_Select:SetState(0) self.group_Sopt2.state_Select:SetState(0) UIUtils.SetImageByAssetBundle(self.group_Sopt1.img_QualityHead, bgImagePath) UIUtils.SetImageByAssetBundle(self.group_Sopt2.img_QualityHead, bgImagePath) UIUtils.SetLabel(self.group_Sopt1.txt_Basic, string.FormatByIdsId(CTL.FreeLineUp.GsBasicIDS[self.gsIdsType], 0)) UIUtils.SetLabel(self.group_Sopt2.txt_Basic, string.FormatByIdsId(CTL.FreeLineUp.GsBasicIDS[self.gsIdsType], 0)) UIUtils.SetLabel(self.group_Sopt1.txt_Heritaged, string.FormatByIdsId(CTL.FreeLineUp.GsHeritagedIDS[self.gsIdsType], 0)) UIUtils.SetLabel(self.group_Sopt2.txt_Heritaged, string.FormatByIdsId(CTL.FreeLineUp.GsHeritagedIDS[self.gsIdsType],0)) UIUtils.SetLabel(self.txt_BR, 0) end function UIFreeLineupSelectOfficer:RefreshHeroInfos(lineUps) print(lineUps) for _,heroInfo in ipairs(lineUps.heroInfos) do self.allHeroList[heroInfo.posNumber] = heroInfo.heroId end for _,heroInfo in ipairs(lineUps.heroInfos) do if self.posNumber1 == heroInfo.posNumber then self.group_Sopt1.state_Select:SetState(1) UTL.Item.SetHeroIconByHeroId(self.group_Sopt1.img_SelectedHero, heroInfo.heroId, heroInfo.heroAwaken) UTL.Color.SetQualityImageByType(self.group_Sopt1.img_QualityFrame, CTL.HeroAwaken.GetHeroQuality(heroInfo.heroId, heroInfo.heroAwaken), UTL.Color.QualityType.HeroSelectFrame) UTL.Color.SetQualityImageByType(self.group_Sopt1.img_QualityHead, CTL.HeroAwaken.GetHeroQuality(heroInfo.heroId, heroInfo.heroAwaken), UTL.Color.QualityType.HeroSelectBg) UIUtils.SetLabel(self.group_Sopt1.txt_Basic, string.FormatByIdsId(CTL.FreeLineUp.GsBasicIDS[self.gsIdsType], heroInfo.heroBaseGs)) UIUtils.SetLabel(self.group_Sopt1.txt_Heritaged, string.FormatByIdsId(CTL.FreeLineUp.GsHeritagedIDS[self.gsIdsType], heroInfo.lineUpGs)) self.allGs = self.allGs + heroInfo.heroBaseGs + heroInfo.lineUpGs elseif self.posNumber2 == heroInfo.posNumber then self.group_Sopt2.state_Select:SetState(1) UTL.Item.SetHeroIconByHeroId(self.group_Sopt2.img_SelectedHero, heroInfo.heroId, heroInfo.heroAwaken) UTL.Color.SetQualityImageByType(self.group_Sopt2.img_QualityFrame, CTL.HeroAwaken.GetHeroQuality(heroInfo.heroId, heroInfo.heroAwaken), UTL.Color.QualityType.HeroSelectFrame) UTL.Color.SetQualityImageByType(self.group_Sopt2.img_QualityHead, CTL.HeroAwaken.GetHeroQuality(heroInfo.heroId, heroInfo.heroAwaken), UTL.Color.QualityType.HeroSelectBg) UIUtils.SetLabel(self.group_Sopt2.txt_Basic, string.FormatByIdsId(CTL.FreeLineUp.GsBasicIDS[self.gsIdsType], heroInfo.heroBaseGs)) UIUtils.SetLabel(self.group_Sopt2.txt_Heritaged, string.FormatByIdsId(CTL.FreeLineUp.GsHeritagedIDS[self.gsIdsType], heroInfo.lineUpGs)) self.allGs = self.allGs + heroInfo.heroBaseGs + heroInfo.lineUpGs end end UIUtils.SetLabel(self.txt_BR, self.allGs) end function UIFreeLineupSelectOfficer:GetLineUpsInfoArr() for _, lineInfo in ipairs(MDL.FreeLineUp.GetLineUpInfoByFunctionType(self.freeLineupFuncType)) do if lineInfo.lineNumber == self.curKingdom then return lineInfo end end end function UIFreeLineupSelectOfficer:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIFreeLineupSelectOfficer:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView() elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.DemonGod_SelectArray}) elseif comp == self.btn_Fight or comp == self.btn_Next then -- 出战 self:ExecuteFightFunc() elseif comp == self.group_Sopt1.btn_Demount then -- 阵位1 if self:IsTeamPosLockedUp(self.selectTeamId) then return end self:SetTeamPos(-1, self:GetTeamPos(2)) self:SetLineUps() elseif comp == self.group_Sopt2.btn_Demount then -- 阵位2 if self:IsTeamPosLockedUp(self.selectTeamId) then return end self:SetTeamPos(self:GetTeamPos(1), -1) self:SetLineUps() elseif comp == self.btn_Formation then UIManager.OpenView(Const_UI_Lua.UIEnum.UIFreeLineupDetailPanel, {id = self.freeLineupFuncType, heroList = self.allHeroList}) else self:OnTeamSlotBtnClick(comp) end end function UIFreeLineupSelectOfficer:SetTeamPos(hero1, hero2) if self.selectTeamId == 1 then self.allHeroList[1] = hero1 self.allHeroList[2] = hero2 elseif self.selectTeamId == 2 then self.allHeroList[3] = hero1 self.allHeroList[4] = hero2 elseif self.selectTeamId == 3 then self.allHeroList[5] = hero1 self.allHeroList[6] = hero2 end end function UIFreeLineupSelectOfficer:GetTeamPos(posNumber, teamId) local heroList = self.allHeroList if teamId == nil then teamId = self.selectTeamId end if teamId == 1 then return heroList[posNumber] elseif teamId == 2 then if posNumber == 1 then return heroList[3] elseif posNumber == 2 then return heroList[4] end elseif teamId == 3 then if posNumber == 1 then return heroList[5] elseif posNumber == 2 then return heroList[6] end end end --BASE function UIFreeLineupSelectOfficer:GetHeroHavePos(heroId) local lineUps = MDL.FreeLineUp.GetLineUpInfoByFunctionType(self.freeLineupFuncType) if lineUps then for k,teamInfo in ipairs(lineUps) do for _, heroInfo in ipairs(teamInfo.heroInfos) do if heroInfo.heroId == heroId then return heroInfo.posNumber end end end end return 0 end function UIFreeLineupSelectOfficer:SetLineUps() local activityData = DataSheetManager.ActivityData:GetDataByID(self.curActivityType) if UTL.Time.IsServerInOpeningTime(activityData.Time_Table[1].StartTime, activityData.Time_Table[1].EndTime) then MDL.FreeLineUp.FreeLineUpSetRequest( self.freeLineupFuncType, MDL.FreeLineUp.GetFreeLineUpLineNumber(self.freeLineupFuncType), MDL.FreeLineUp.SetType.Official, self.allHeroList ) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroActivity_TimeHint3) end end --手动设置英雄列表的筛选国别 function UIFreeLineupSelectOfficer:InitCountrySelectToggle() if not self.countrySelectToggleView then self.countrySelectToggleView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UICommonCountrySelectToggle), {parentUI = self}) end end function UIFreeLineupSelectOfficer:OnCountrySelectToggleValueChanged(index) self.selectCountryToggle = index self:RefreshFilterCountryHeroList() end function UIFreeLineupSelectOfficer:OnValueChanged(comp, index) if comp == self.toggle_hideOtherTeamHero then --隐藏其他队列已上阵武将toggle self:RefreshFilterCountryHeroList() end end --具有手动筛选英雄功能的布阵,使用该方法刷新英雄列表 function UIFreeLineupSelectOfficer:RefreshFilterCountryHeroList() local heroList = {} local lineUpList = MDL.FreeLineUp.GetLineUpSpareHeroInfoList() if lineUpList and #lineUpList > 0 then for k,v in ipairs(lineUpList) do local heroData = DataSheetManager.HeroNum:GetDataByID(v.heroId) if self:IsMeetHeroFilter(v.heroId, heroData.Kingdom) then table.insert(heroList, {heroCfg = heroData, serverInfo = v}) end end end if self.selectHeroIndex == -1 then self.loop_AvailableHero:ReloadAll(heroList) elseif self.selectHeroIndex > -1 then self.loop_AvailableHero:UpdateIndex(self.selectHeroIndex, heroList[self.selectHeroIndex + 1]) self.selectHeroIndex = -1 end if #heroList > 0 then UIUtils.SetLabel(self.txt_NoActiveHeroTips, "") else UIUtils.SetLabelText(self.txt_NoActiveHeroTips, Const_IDS.IDS_Guild_BlankContent) end end function UIFreeLineupSelectOfficer:CanForceReplaceHeroPos(data, heroPosNum) -- 有空位的时候可以强制替换上阵主将 local refinedHintTime = PersistentData.PlayerData:Get(RefinedHintTime, 0) if UTL.Time.IsTimestampSameDay(refinedHintTime) then self:ForceReplaceHeroPos(data.heroCfg.ID) else --根据玩家操作决定后续动作 local selectHeroName = UIUtils.GetLocalizedTxt(Const_IDS[data.heroCfg.NameIDS]) local beforeTeamName = UIUtils.GetLocalizedTxt(self:GetTeamIDSByHeroPosNum(heroPosNum)) local curTeamName = UIUtils.GetLocalizedTxt(self:GetCurTeamIDS(self.selectTeamId)) local des = string.FormatByIdsId(Const_IDS.IDS_OptimizeHeroSelect_Tips, selectHeroName, beforeTeamName, curTeamName) UTL.MessageBox.ShowOKCancelToggleBox(nil, des, UIUtils.GetLocalizedTxt(Const_IDS.IDS_WarZoneAuction_27), function() self:ForceReplaceHeroPos(data.heroCfg.ID) end, function(isOn) if isOn then PersistentData.PlayerData:Set(RefinedHintTime, UTL.Time.GetServerTimestamp(), true) else PersistentData.PlayerData:Remove(RefinedHintTime) end end) end end function UIFreeLineupSelectOfficer:ForceReplaceHeroPos(heroId) local selectHeroId = heroId --更新当前布阵主将位置信息 if self:GetTeamPos(2) <= 0 and self:GetTeamPos(1) > 0 then self:SetTeamPos(self:GetTeamPos(1), selectHeroId) else self:SetTeamPos(selectHeroId, self:GetTeamPos(2)) end --清除变更后的布阵主将位置信息 if self:GetHeroHavePos(selectHeroId) > 0 then self.allHeroList[self:GetHeroHavePos(selectHeroId)] = -1 end --刷新cell标志位 self.selectHeroIndex = -1 --设置到服务器 self:SetLineUps() end --根据主将上阵位置反向查到所在队列IDS function UIFreeLineupSelectOfficer:GetTeamIDSByHeroPosNum(heroPosNum) if heroPosNum == 1 or heroPosNum == 2 then return Const_IDS.IDS_DemonGod_UI_30 elseif heroPosNum == 3 or heroPosNum == 4 then return Const_IDS.IDS_DemonGod_UI_31 else return Const_IDS.IDS_DemonGod_UI_32 end end function UIFreeLineupSelectOfficer:GetCurTeamIDS(selectTeamId) if selectTeamId == 1 then return Const_IDS.IDS_DemonGod_UI_30 elseif selectTeamId == 2 then return Const_IDS.IDS_DemonGod_UI_31 else return Const_IDS.IDS_DemonGod_UI_32 end end --endregion =============================================== return UIFreeLineupSelectOfficer