-- 天地群雄3v3 布阵界面 local UISpecialTeamSelectOfficer = UIViewClass() local Effect_Drag_Event = ConstAssetPathConfig.Effect_Drag_Event local Effect_Replace_Event = ConstAssetPathConfig.Effect_Replace_Event local bgImagePath = ConstAssetPathConfig.bgImagePath function UISpecialTeamSelectOfficer:OnOpened(context) ---TODO -- 刷新事件 self:RegistSystemEvent(EventID.UI_FreeLineUp_RefreshUI, self.RefreshTeamInfos) self:RegistSystemEvent(EventID.UI_SpecialTeam_FormationStateChange, self.RefreshEditorStateChange) -- 布阵编辑状态变更 self:RegistSystemEvent(EventID.UI_SpecialTeam_LeaveTeam, self.OnBackButtonPressed) -- 被踢或解散关闭界面 self:RegistSystemEvent(EventID.UI_SpecialTeam_CloseAll, self.OnBackButtonPressed) self:RegistSystemEvent(EventID.UI_SpecialTeam_MemberInfoChange, self.UpdateTeamMemberInfo) -- 设置标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_HeroMatch3v3_Embattle) UIUtils.SetActive(self.btn_Fight, true) -- 保存按钮 self.lineNumbers = {1, 2, 3} self:InitDragAndDropEvents() self.freeLineupFuncType = MDL.FreeLineUp.FuncType.TeamWar self.ActivityType = LuaConst.ActivityType.HeroMatch3v3 self.allHeroList = { {-1, -1, -1, -1, -1, -1}, -- 第一战队 {-1, -1, -1, -1, -1, -1}, -- 第二战队 {-1, -1, -1, -1, -1, -1} -- 第三战队 } self.SkillList = { {0,0,0}, {0,0,0}, {0,0,0} } self.TeamTotalScore = {0,0,0} -- 队伍战力 self.selectTeamIndex = 1 -- 战队索引 self.selectMemberIndex = 0 -- 队员索引 self.selectHeroIndex = -1 self:SetEditorAcid() self:RefreshEditorState() self.curKingdoms = MDL.SpecialTeam.GetTeamLimitCountry() self.loop_Flag:ReloadAll({[1] = self.curKingdoms}) self:UpdateTeamMemberInfo() self:RefreshButtonPower() self:RefreshButtonGroupState() end function UISpecialTeamSelectOfficer:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UISpecialTeamSelectOfficer:UpdateTeamMemberInfo() MDL.FreeLineUp.C2GFreeLineUpGetInfoRepeatRequest(self.freeLineupFuncType) end function UISpecialTeamSelectOfficer:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then local canClose = true if self.isEditor and self.editorAcid == BattleDataGetter.GetAcID() then canClose = self:SaveLineUps() end if canClose then self:CloseView(true) end elseif comp == self.UITemplateTitlePanel.btn_Home then local canClose = true if self.isEditor and self.editorAcid == BattleDataGetter.GetAcID() then canClose = self:SaveLineUps() end if canClose then CTL.HomeMain.CloseViewBackHomeMain() end elseif comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.HeroMatch3v3_TeamFormation}) elseif comp == self.btn_Edit then -- 编辑 if not self.isEditor then MDL.SpecialTeam.TeamWarLineUpReq(true) end elseif comp == self.btn_Save then -- 保存 if self.isEditor then self:SaveLineUps() end else for k,v in ipairs(self.group_TeammateInfo) do if comp == v.img_BG or comp == v.group_Spot1.btn_Demount or comp == v.group_Spot2.btn_Demount or comp == v.btn_Skill or comp == v.btn_Formation then if self.teammateInfo[k] and self.selectAcid ~= self.teammateInfo[k].memberId then if MDL.SpecialTeam.IsSelfLeader() then self.selectMemberIndex = k self.selectAcid = self.teammateInfo[k].memberId self:RefreshMemberGroupState(self.freeLineupFuncType) self:RefreshHeroList() return else if MDL.HeroMatch3v3.IsCurActivityInOpenTime() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroMatch3v3_OnlyLeaderSet) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroMatch3v3_OnlyLeader) end return end end end if comp == v.group_Spot1.btn_Demount then -- 阵位1 if self.isEditor then if self.editorAcid ~= BattleDataGetter.GetAcID() then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_HeroMatch3v3_Editing, MDL.SpecialTeam.GetMemberNameById(self.editorAcid))) return end self:SetTeamPos(-1, self:GetTeamPos(2)) self:SetLineUps() return else if MDL.HeroMatch3v3.IsCurActivityInOpenTime() and self.selectAcid ~= BattleDataGetter.GetAcID() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroMatch3v3_OnlyLeaderEdit) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroMatch3v3_TapEditFirst) end return end elseif comp == v.group_Spot2.btn_Demount then -- 阵位2 if self.isEditor then if self.editorAcid ~= BattleDataGetter.GetAcID() then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_HeroMatch3v3_Editing, MDL.SpecialTeam.GetMemberNameById(self.editorAcid))) return end self:SetTeamPos(self:GetTeamPos(1), -1) self:SetLineUps() return else if MDL.HeroMatch3v3.IsCurActivityInOpenTime() and self.selectAcid ~= BattleDataGetter.GetAcID() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroMatch3v3_OnlyLeaderEdit) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroMatch3v3_TapEditFirst) end return end elseif comp == v.btn_Skill then -- 锦囊 if self.isEditor then if self.editorAcid ~= BattleDataGetter.GetAcID() then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_HeroMatch3v3_Editing, MDL.SpecialTeam.GetMemberNameById(self.editorAcid))) return end UIManager.OpenView(Const_UI_Lua.UIEnum.UISpecialTeamSilkBag, {parent = self, selectSkillID = self.SkillList[self.selectMemberIndex][self.selectTeamIndex]}) else if MDL.HeroMatch3v3.IsCurActivityInOpenTime() and self.selectAcid ~= BattleDataGetter.GetAcID() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroMatch3v3_OnlyLeaderEdit) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroMatch3v3_TapEditFirst) end return end elseif comp == v.btn_Formation then -- 布阵详情 if not self:CheckLineUpHaveNil() then UIManager.OpenView(Const_UI_Lua.UIEnum.UIFreeLineupCustomDetailPanel_3v3, { id = MDL.FreeLineUp.FuncType.TeamWar, heroList = self.allHeroList, parentView = self }, -- 复用布阵详情界面 Const_UI_Lua.UIEnum.UIFreeLineupDetailPanel ) end end end end end function UISpecialTeamSelectOfficer:CheckLineUpHaveNil() for k,_ in ipairs(self.teammateInfo) do for i,v in ipairs(self.allHeroList[k]) do if i%2 == 1 and v == -1 then if self.allHeroList[k][i+1] == -1 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_DemonGod_UI_12) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_SiegeCity_LineupTips_2) end self:OnPointerDown(self.group_TeamButtons[math.ceil(i/2)].rect_Event) return true end end end return false end function UISpecialTeamSelectOfficer:SaveLineUps() if self:CheckLineUpHaveNil() then return false else MDL.SpecialTeam.TeamWarLineUpReq(false) return true end end function UISpecialTeamSelectOfficer:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_AvailableHero then UTL.Item.SetHeroIconByHeroId(cellTable.img_SelectedHero, data.heroCfg.ID, data.serverInfo.heroAwaken) local quality = CTL.HeroAwaken.GetHeroQuality(data.heroCfg.ID, data.serverInfo.heroAwaken) UTL.Color.SetQualityImageByType(cellTable.img_QualityFrame, quality, UTL.Color.QualityType.HeroSelectFrame) UTL.Color.SetQualityImageByType(cellTable.img_QualityHead, quality, UTL.Color.QualityType.HeroSelectBg) UIUtils.SetLabel(cellTable.txt_BR, data.serverInfo.heroBaseGs) UIUtils.SetActive(cellTable.img_BlackCover, self:GetHeroHavePos(data.heroCfg.ID) > 0) UIUtils.SetActive(cellTable.img_Lock, not self.isEditor or self.editorAcid ~= BattleDataGetter.GetAcID()) elseif scrollRect == self.loop_Flag then cellTable.state_countries:SetState(data - 1) -- 国别 end end function UISpecialTeamSelectOfficer:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_AvailableHero then if self.isEditor then if self.editorAcid ~= BattleDataGetter.GetAcID() then return end else if MDL.HeroMatch3v3.IsCurActivityInOpenTime() and self.selectAcid ~= BattleDataGetter.GetAcID() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroMatch3v3_OnlyLeaderEdit) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroMatch3v3_TapEditFirst) end return end local heroPosNum = self:GetHeroHavePos(data.heroCfg.ID) local key1, key2 = self.selectTeamIndex * 2 - 1, self.selectTeamIndex * 2 if heroPosNum > 0 and heroPosNum ~= key1 and heroPosNum ~= key2 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_DemonGod_UI_42) -- 该武将已被其它出战阵容锁定 return end if self:GetHeroHavePos(data.heroCfg.ID) > 0 then self.allHeroList[self.selectMemberIndex][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 UISpecialTeamSelectOfficer:RefreshButtonGroupState() for k,v in ipairs(self.group_TeamButtons) do if self.selectTeamIndex == k then v.state_Button:SetState(1) else v.state_Button:SetState(0) end end end -- 更新队友的选中状态 function UISpecialTeamSelectOfficer:RefreshMemberGroupState() for k,v in ipairs(self.group_TeammateInfo) do if self.selectMemberIndex == k then v.state_Light:SetState(0) UIUtils.SetActive(v.img_Mask, false) else v.state_Light:SetState(1) UIUtils.SetActive(v.img_Mask, not MDL.SpecialTeam.IsSelfLeader()) end end end -- 战队三人总战力 function UISpecialTeamSelectOfficer:RefreshButtonPower() ---TODO 每队总战力 for UI_Index, UI_Cell in ipairs(self.group_TeamButtons) do self.TeamTotalScore[UI_Index] = 0 local pos1, pos2 = UI_Index * 2 - 1, UI_Index * 2 if self.teammateInfo then self.TeamTotalScore[UI_Index] = 0 for memberIndex, memberInfo in ipairs(self.teammateInfo) do if memberInfo then local memberFuncInfo = MDL.FreeLineUp.GetLineUpInfoByFunctionType(self.freeLineupFuncType, memberInfo.memberId) if memberFuncInfo then self.SkillList[memberIndex][UI_Index] = memberFuncInfo.silkBag[UI_Index] local lineUps = memberFuncInfo.lineUps[1] if lineUps then for posIndex,heroInfo in ipairs(lineUps.heroInfos) do if pos1 == posIndex or pos2 == posIndex then self.TeamTotalScore[UI_Index] = self.TeamTotalScore[UI_Index] + heroInfo.heroBaseGs + heroInfo.lineUpGs end end end end end end end UIUtils.SetLabel(UI_Cell.lab_CE, self.TeamTotalScore[UI_Index]) UIUtils.SetLabelText(UI_Cell.labLocal_Team, Const_IDS["IDS_LineupDrag_Name"..(self.lineNumbers[UI_Index] or UI_Index)]) end end -- 刷新武将列表 function UISpecialTeamSelectOfficer:RefreshHeroList() local isHaveHero = false local heroList = {} local demonGodFreeLineUpList = MDL.FreeLineUp.GetLineUpSpareHeroInfoList(self.freeLineupFuncType, self.selectAcid) if demonGodFreeLineUpList and #demonGodFreeLineUpList > 0 then for k,v in ipairs(demonGodFreeLineUpList) do local heroData = DataSheetManager.HeroNum:GetDataByID(v.heroId) if self.curKingdoms <= 0 or heroData.Kingdom == self.curKingdoms 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 end -- 刷新三人阵容信息 function UISpecialTeamSelectOfficer:RefreshFormationList() local allTotalScore = 0 for i, v in ipairs(self.group_TeammateInfo) do self:RefreshTeamInfo(v, self.teammateInfo[i], i) allTotalScore = allTotalScore + self.TeamTotalScore[i] end UIUtils.SetLabel(self.txt_TotalScore, string.FormatByIdsId(Const_IDS.IDS_HeroMatch3v3_AllNum, allTotalScore)) -- 三军总伤害 end -- 服务器数据刷新 function UISpecialTeamSelectOfficer:RefreshTeamInfos(funcType, lineUpTypes) if funcType == self.freeLineupFuncType then self.teammateInfo = MDL.SpecialTeam.GetAllMembersInfo() if self.selectMemberIndex == 0 then for k,v in ipairs(self.teammateInfo) do if v.memberId == BattleDataGetter.GetAcID() then self.selectMemberIndex = k self.selectAcid = self.teammateInfo[self.selectMemberIndex].memberId end end end if lineUpTypes then self.lineNumbers = lineUpTypes end self:RefreshButtonPower() self:RefreshButtonGroupState() self:RefreshMemberGroupState() self:RefreshHeroList() self:RefreshFormationList() end end -- 刷新锦囊 function UISpecialTeamSelectOfficer:RefreshSkillInfo(cell_Member, memberIndex) local silkBagID = self.SkillList[memberIndex][self.selectTeamIndex] UIUtils.SetActive(cell_Member.img_Skill, silkBagID > 0) if silkBagID > 0 then local buffData = DataSheetManager.BuffData:GetDataByBuffID(silkBagID) UIUtils.SetImageByAssetBundle(cell_Member.img_Skill, buffData.BuffIcon) UIUtils.SetLabelText(cell_Member.txt_SkillName, Const_IDS[buffData.BuffName]) else UIUtils.SetLabelText(cell_Member.txt_SkillName, Const_IDS.IDS_HeroMatch3v3_AddSkillBag) end end -- 刷新阵容 function UISpecialTeamSelectOfficer:RefreshTeamInfo(cell_Member, memberInfo, memberIndex) cell_Member.state_Empty:SetState(memberInfo and 0 or 1) if memberInfo then local baseInfo = memberInfo.playerShowInfo -- 头像 CTL.Character.SetPortraitAndFrame(cell_Member.UIHeroHead150, baseInfo.PortraitId, baseInfo.FrameId) -- 队员名字 cell_Member.txt_PlayerName.text = MDL.SpecialTeam.GetMemberNameById(memberInfo.memberId) -- 战力 cell_Member.txt_NumCE.text = 0 -- 队长标识 local isCaptain = MDL.SpecialTeam.IsTeamLeader(memberInfo.memberId) if isCaptain then UIUtils.SetCanvasSortingOrderByMainCanvas(cell_Member.UIHeroHead150.effectUpCanvas, cell_Member.ico_Leader, CTL.Character.UpOrder.Common) end local memberFuncInfo = MDL.FreeLineUp.GetLineUpInfoByFunctionType(self.freeLineupFuncType, memberInfo.memberId) if memberFuncInfo then self.SkillList[memberIndex][self.selectTeamIndex] = memberFuncInfo.silkBag[self.selectTeamIndex] or 0 self:RefreshSkillInfo(cell_Member, memberIndex) local posNumber1, posNumber2 = self.selectTeamIndex * 2 - 1, self.selectTeamIndex * 2 self.allHeroList[memberIndex] = {-1, -1, -1, -1, -1, -1} local lineUps = memberFuncInfo.lineUps if lineUps then cell_Member.group_Spot1.state_Select:SetState(0) cell_Member.group_Spot2.state_Select:SetState(0) UIUtils.SetImageByAssetBundle(cell_Member.group_Spot1.img_QualityHead, bgImagePath) UIUtils.SetImageByAssetBundle(cell_Member.group_Spot2.img_QualityHead, bgImagePath) UIUtils.SetLabel(cell_Member.group_Spot1.txt_Basic, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_47, 0)) UIUtils.SetLabel(cell_Member.group_Spot2.txt_Basic, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_47, 0)) UIUtils.SetLabel(cell_Member.group_Spot1.txt_Inherit, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_48, 0)) UIUtils.SetLabel(cell_Member.group_Spot2.txt_Inherit, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_48,0)) for k,v in ipairs(lineUps) do for _,heroInfo in ipairs(v.heroInfos) do self.allHeroList[memberIndex][heroInfo.posNumber] = heroInfo.heroId end local allGs = 0 for _,heroInfo in ipairs(v.heroInfos) do if posNumber1 == heroInfo.posNumber then cell_Member.group_Spot1.state_Select:SetState(1) UTL.Item.SetHeroIconByHeroId(cell_Member.group_Spot1.img_SelectedHero, heroInfo.heroId, heroInfo.heroAwaken) local quality = CTL.HeroAwaken.GetHeroQuality(heroInfo.heroId, heroInfo.heroAwaken) UTL.Color.SetQualityImageByType(cell_Member.group_Spot1.img_QualityFrame, quality, UTL.Color.QualityType.HeroSelectFrame) UTL.Color.SetQualityImageByType(cell_Member.group_Spot1.img_QualityHead, quality, UTL.Color.QualityType.HeroSelectBg) UIUtils.SetLabel(cell_Member.group_Spot1.txt_Basic, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_47, heroInfo.heroBaseGs)) UIUtils.SetLabel(cell_Member.group_Spot1.txt_Inherit, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_48, heroInfo.lineUpGs)) allGs = allGs + heroInfo.heroBaseGs + heroInfo.lineUpGs elseif posNumber2 == heroInfo.posNumber then cell_Member.group_Spot2.state_Select:SetState(1) UTL.Item.SetHeroIconByHeroId(cell_Member.group_Spot2.img_SelectedHero, heroInfo.heroId, heroInfo.heroAwaken) local quality = CTL.HeroAwaken.GetHeroQuality(heroInfo.heroId, heroInfo.heroAwaken) UTL.Color.SetQualityImageByType(cell_Member.group_Spot2.img_QualityFrame, quality, UTL.Color.QualityType.HeroSelectFrame) UTL.Color.SetQualityImageByType(cell_Member.group_Spot2.img_QualityHead, quality, UTL.Color.QualityType.HeroSelectBg) UIUtils.SetLabel(cell_Member.group_Spot2.txt_Basic, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_47, heroInfo.heroBaseGs)) UIUtils.SetLabel(cell_Member.group_Spot2.txt_Inherit, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_48, heroInfo.lineUpGs)) allGs = allGs + heroInfo.heroBaseGs + heroInfo.lineUpGs end end -- 战力 cell_Member.txt_NumCE.text = allGs end else cell_Member.group_Spot1.state_Select:SetState(0) cell_Member.group_Spot2.state_Select:SetState(0) UIUtils.SetImageByAssetBundle(cell_Member.group_Spot1.img_QualityHead, bgImagePath) UIUtils.SetImageByAssetBundle(cell_Member.group_Spot2.img_QualityHead, bgImagePath) end end end end function UISpecialTeamSelectOfficer:SetTeamPos(hero1, hero2) self.allHeroList[self.selectMemberIndex][self.selectTeamIndex * 2 - 1] = hero1 self.allHeroList[self.selectMemberIndex][self.selectTeamIndex * 2] = hero2 end -- 设置布阵信息 function UISpecialTeamSelectOfficer:SetLineUps() if MDL.SpecialTeam.IsFunctionOpen() then MDL.FreeLineUp.C2GFreeLineUpSetRequest(self.freeLineupFuncType, 1, MDL.FreeLineUp.SetType.Official, self.allHeroList[self.selectMemberIndex], nil, self.selectAcid, self.SkillList[self.selectMemberIndex]) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroActivity_TimeHint3) end end -- 获取武将的阵位索引 function UISpecialTeamSelectOfficer:GetHeroHavePos(heroId) local lineUps = MDL.FreeLineUp.GetLineUpInfoByFunctionType(self.freeLineupFuncType, self.selectAcid).lineUps 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 UISpecialTeamSelectOfficer:SetPosSkillID(skillID) self.SkillList[self.selectMemberIndex][self.selectTeamIndex] = skillID self:RefreshSkillInfo(self.group_TeammateInfo[self.selectMemberIndex], self.selectMemberIndex) self:SetLineUps() end -- 刷新正在编辑阵容的玩家ID function UISpecialTeamSelectOfficer:SetEditorAcid() self.editorAcid = MDL.SpecialTeam.GetTeamInfo().lineUpOpAcid self.isEditor = not string.isNilOrEmpty(self.editorAcid) end -- 刷新编辑状态 function UISpecialTeamSelectOfficer:RefreshEditorState() if self.isEditor then if self.editorAcid == BattleDataGetter.GetAcID() then UIUtils.SetLabel(self.txt_Edit, string.FormatByIdsId(Const_IDS.IDS_HeroMatch3v3_Editing, MDL.SpecialTeam.GetMemberNameById(self.editorAcid))) self.group_Btn:SetState(1) -- 保存 else UIUtils.SetLabel(self.txt_Other, string.FormatByIdsId(Const_IDS.IDS_HeroMatch3v3_Editing, MDL.SpecialTeam.GetMemberNameById(self.editorAcid))) self.group_Btn:SetState(2) -- xx正在编辑 end else if MDL.HeroMatch3v3.IsCurActivityInOpenTime() and not MDL.SpecialTeam.IsSelfLeader() then UIUtils.SetLabelText(self.txt_Other, Const_IDS.IDS_HeroMatch3v3_OnlyLeaderSet) -- 比赛期间,只有战队队长可进行布阵 self.group_Btn:SetState(2) -- xx正在编辑 else self.group_Btn:SetState(0) -- 编辑 end end end -- 服务器编辑状态变更 function UISpecialTeamSelectOfficer:RefreshEditorStateChange() self:SetEditorAcid() self:RefreshEditorState() self:RefreshHeroList() end -- 获取上阵的武将ID function UISpecialTeamSelectOfficer:GetTeamPos(posNumber) local heroList = self.allHeroList[self.selectMemberIndex] if self.selectTeamIndex == 1 then return heroList[posNumber] elseif self.selectTeamIndex == 2 then if posNumber == 1 then return heroList[3] elseif posNumber == 2 then return heroList[4] end elseif self.selectTeamIndex == 3 then if posNumber == 1 then return heroList[5] elseif posNumber == 2 then return heroList[6] end end end function UISpecialTeamSelectOfficer:OnPointerDown(comp, eventdata) local index = self:GetRectIndex(comp) if index then if self.selectTeamIndex == index then return end self.group_TeamButtons[self.selectTeamIndex].state_Button:SetState(0) self.selectTeamIndex = index self.group_TeamButtons[self.selectTeamIndex].state_Button:SetState(1) self:RefreshTeamInfos(self.freeLineupFuncType, self.lineNumbers) end end function UISpecialTeamSelectOfficer:InitDragAndDropEvents() self.dragParentObj = self.drag_Parent.gameObject self.dragParentTrans = self.drag_Parent.transform self.dropGroup = { self.group_TeamButtons[1].rect_Event.gameObject, self.group_TeamButtons[2].rect_Event.gameObject, self.group_TeamButtons[3].rect_Event.gameObject, } --注册事件 for i, v in ipairs(self.group_TeamButtons) do self:RegistAllEvent(v.rect_Event) end end function UISpecialTeamSelectOfficer:RegistAllEvent(comp) self:RegistTriggerEvent(comp, UIEventTriggerType.PointerDown) self:RegistTriggerEvent(comp, UIEventTriggerType.BeginDrag) self:RegistTriggerEvent(comp, UIEventTriggerType.Drag) self:RegistTriggerEvent(comp, UIEventTriggerType.EndDrag) self:RegistDropEvent(comp, self.dropGroup) end function UISpecialTeamSelectOfficer:OnBeginDrag(comp, eventData) if not MDL.SpecialTeam.IsSelfLeader() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_LineupDrag_LeaderCan2) return end if self.editorAcid ~= BattleDataGetter.GetAcID() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_LineupDrag_EditFirst) return end UIUtils.ScreenPointToWorldPointInRectangle(self.dragParentObj, eventData) self.draggingTrans = comp.transform.parent self.originParent = self.draggingTrans.parent self.originX, self.originY = self.draggingTrans:GetLocalPosition() self.draggingTrans:SetParent(self.dragParentTrans, true) self:PlayDragEffect(comp) end function UISpecialTeamSelectOfficer:OnDrag(comp, eventData) if not MDL.SpecialTeam.IsSelfLeader() then return end if self.editorAcid ~= BattleDataGetter.GetAcID() then return end UIUtils.ScreenPointToWorldPointInRectangle(self.dragParentObj, eventData) if eventData.pointerEnter then self:PlayReplaceEffect(comp, eventData.pointerEnter.transform) end end function UISpecialTeamSelectOfficer:OnDrop(comp, eventData) if not MDL.SpecialTeam.IsSelfLeader() then return end if self.editorAcid ~= BattleDataGetter.GetAcID() then return end self:StopAllEffect() self:TryExchangeLineUp(comp, eventData.pointerDrag.transform) --实际不更换拖拽与释放的位置,只更换数据,因此最终都放回原来的位置即可 self.draggingTrans:SetParent(self.originParent, true) self.draggingTrans:SetLocalPosition(self.originX, self.originY, 0) end function UISpecialTeamSelectOfficer:OnEndDrag() --可以不写逻辑 但是必须有 ondrop 在 OnEndDrag 之后 end function UISpecialTeamSelectOfficer:PlayDragEffect(rect) local tagEffect = self:GetEffectNode(rect) if tagEffect then tagEffect:StopUIEffect() tagEffect:PlayUIEffect(Effect_Drag_Event, -1) end end function UISpecialTeamSelectOfficer:PlayReplaceEffect(dragTrans, targetTrans) self:StopAllEffect(dragTrans) local tagEffect = self:GetEffectNode(targetTrans) if tagEffect then tagEffect:StopUIEffect() tagEffect:PlayUIEffect(Effect_Replace_Event, -1) end end function UISpecialTeamSelectOfficer:StopAllEffect(exceptRect) for i, v in ipairs(self.group_TeamButtons) do if exceptRect and exceptRect == v.rect_Event then else v.tag_Effect:StopUIEffect() end end end function UISpecialTeamSelectOfficer:GetEffectNode(rect) for i, v in ipairs(self.group_TeamButtons) do if rect == v.rect_Event then return v.tag_Effect end end return nil end function UISpecialTeamSelectOfficer:GetRectIndex(rect) for i, v in ipairs(self.group_TeamButtons) do if rect == v.rect_Event then return i end end return nil end function UISpecialTeamSelectOfficer:TryExchangeLineUp(targetObj, dragObj) if targetObj == nil then return end local curIndex = self:GetRectIndex(dragObj) local targetIndex = self:GetRectIndex(targetObj) if curIndex and targetIndex then self.selectTeamIndex = targetIndex MDL.FreeLineUp.C2GLineUpTypeExchange(self.freeLineupFuncType, curIndex-1, targetIndex-1) end end return UISpecialTeamSelectOfficer