-- 天地群雄3v3的额外设置子界面 local UIFreeLineupDetailChild3v3Panel = UIViewClass() function UIFreeLineupDetailChild3v3Panel:OnOpened(context) self:RegistSystemEvent(EventID.UI_FreeLineUp_RefreshUI, self.RefreshLineupGS) self:RegistSystemEvent(EventID.UI_SpecialTeam_FormationStateChange, self.SetEditorAcid) -- 布阵编辑状态变更 self.root = context.parentView self.teammateInfo = MDL.SpecialTeam.GetAllMembersInfo() UIUtils.SetActive(self.btn_Before, #self.teammateInfo > 1) UIUtils.SetActive(self.btn_Next, #self.teammateInfo > 1) self:SetEditorAcid() self:SetPlayerInfo() self:RefreshLineupGS() end function UIFreeLineupDetailChild3v3Panel:OnButtonClicked(comp) if comp == self.btn_Before then if MDL.SpecialTeam.IsSelfLeader() then self.root.parentView.selectMemberIndex = self.root.parentView.selectMemberIndex - 1 if self.root.parentView.selectMemberIndex <= 0 then self.root.parentView.selectMemberIndex = #self.teammateInfo end self.root.parentView.selectAcid = self.teammateInfo[self.root.parentView.selectMemberIndex].memberId self:SetPlayerInfo() self:RefreshLineupGS() self.root:InitHeroPictures() self.root:SendFreeLineUpGetSlotInfoRequest() else CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroMatch3v3_OnlyLeader) end elseif comp == self.btn_Next then if MDL.SpecialTeam.IsSelfLeader() then self.root.parentView.selectMemberIndex = self.root.parentView.selectMemberIndex + 1 if self.root.parentView.selectMemberIndex > #self.teammateInfo then self.root.parentView.selectMemberIndex = 1 end self.root.parentView.selectAcid = self.teammateInfo[self.root.parentView.selectMemberIndex].memberId self:SetPlayerInfo() self:RefreshLineupGS() self.root:InitHeroPictures() self.root:SendFreeLineUpGetSlotInfoRequest() else CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroMatch3v3_OnlyLeader) end elseif comp == self.btn_Save then if self.isEditor then MDL.SpecialTeam.TeamWarLineUpReq(false) end elseif comp == self.btn_Start 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 else if MDL.HeroMatch3v3.IsCurActivityInOpenTime() then if MDL.SpecialTeam.IsSelfLeader() then MDL.SpecialTeam.TeamWarLineUpReq(true) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroMatch3v3_OnlyLeaderSet) end else MDL.SpecialTeam.TeamWarLineUpReq(true) end end end end function UIFreeLineupDetailChild3v3Panel:RefreshLineupGS() for UI_Index, UI_Cell in ipairs(self.headGSGroupCollections) do local gs = 0 local pos1, pos2 = UI_Index * 2 - 1, UI_Index * 2 if self.curPlayerInfo then local memberFuncInfo = MDL.FreeLineUp.GetLineUpInfoByFunctionType(self.root.parentView.freeLineupFuncType, self.curPlayerInfo.memberId) local lineUps = memberFuncInfo.lineUps if lineUps then for _,v in ipairs(lineUps) do for posIndex,heroInfo in ipairs(v.heroInfos) do if pos1 == posIndex or pos2 == posIndex then gs = gs + heroInfo.heroBaseGs + heroInfo.lineUpGs end end end end end UIUtils.SetLabel(UI_Cell, gs) end end function UIFreeLineupDetailChild3v3Panel:SetEditorAcid() self.editorAcid = MDL.SpecialTeam.GetTeamInfo().lineUpOpAcid self.isEditor = not string.isNilOrEmpty(self.editorAcid) UIUtils.SetActive(self.btn_Save.gameObject, self.isEditor and self.editorAcid == BattleDataGetter.GetAcID()) UIUtils.SetActive(self.group_Start, not (self.isEditor and self.editorAcid == BattleDataGetter.GetAcID())) if self.isEditor then if self.editorAcid ~= BattleDataGetter.GetAcID() then UIUtils.SetLabel(self.lab_Start, string.FormatByIdsId(Const_IDS.IDS_HeroMatch3v3_Editing, MDL.SpecialTeam.GetMemberNameById(self.editorAcid))) end else if MDL.HeroMatch3v3.IsCurActivityInOpenTime() and not MDL.SpecialTeam.IsSelfLeader() then UIUtils.SetLabelText(self.lab_Start, Const_IDS.IDS_HeroMatch3v3_OnlyLeaderSet) -- 比赛期间,只有战队队长可进行布阵 else UIUtils.SetLabelText(self.lab_Start, Const_IDS.IDS_HeroMatch3v3_TapEdit) end end end function UIFreeLineupDetailChild3v3Panel:SetPlayerInfo() self.curPlayerInfo = self.teammateInfo[self.root.parentView.selectMemberIndex] CTL.Character.SetPortraitAndFrame(self.UIHeroHead, self.curPlayerInfo.playerShowInfo.PortraitId, self.curPlayerInfo.playerShowInfo.FrameId) self.txt_Name.text = self.curPlayerInfo.playerShowInfo.name local isCaptain = MDL.SpecialTeam.IsTeamLeader(self.curPlayerInfo.memberId) self.state_ShowCaptain:SetState(isCaptain and 0 or 1) if isCaptain then UIUtils.SetCanvasSortingOrderByMainCanvas(self.UIHeroHead.effectUpCanvas, self.img_Captain, CTL.Character.UpOrder.Common) end end return UIFreeLineupDetailChild3v3Panel