local UITeamPlatform = UIViewClass() local SELECTED_COLOR = "93969C" local UNSELECT_COLOR = "93969c" local EventSystem = require('Event/EventSystem') function UITeamPlatform:OnOpened(context) self:RegistSystemEvent(EventID.UI_Team_RecommendTeamListChange, self.RefreshRightTeamList) self:RegistSystemEvent(EventID.UI_Team_TeamInfoChange, self.RefreshButtonState) self:RegistSystemEvent(EventID.UI_Team_MemberInfoChange, self.RefreshButtonState) self:RegistSystemEvent(EventID.UI_Team_LeaveTeam, self.RefreshButtonState) self:RegistSystemEvent(EventID.UI_Team_CreateTeam, self.SelectParentToggleIndex) self:RegistSystemEvent(EventID.UI_Team_InviteInfoHandle, self.RefreshInviteButtonRedPoint) self:RegistSystemEvent(EventID.UI_Team_ApplyInfoHandle, self.RefreshApplyButtonRedPoint) self:RegistSystemEvent(EventID.UI_Team_SavePageIndex, self.SavePageIndex) self:RegistSystemEvent(EventID.UI_Team_UpdateFoldView,self.UpdateFoldView) self:RefreshInviteButtonRedPoint(true) self:RefreshApplyButtonRedPoint(true) self.parentView = context.parentView self.mainTarget = context and context.mainTarget or MDL.Team.GetDefaultTarget() self.subTarget = context and context.subTarget or 0 self:RefreshButtonState() self:OpenCommonFoldView() --判断需要选中哪个 local targetIndex = MDL.Team.GetTeamPlayIndexByActivityId(self.mainTarget) local selectIndex = CTL.Team.GetTeamBaseUIPageChildIndex() if selectIndex then targetIndex = selectIndex end if targetIndex > 8 then self.foldView.scroll_Main:MoveIndex(targetIndex) end self.foldView.scroll_Main:SelectIndex(targetIndex, true) self.toggle_AutoAccept.isOn = MDL.Team.IsAutoAccept UIUtils.SetActive(self.toggle_AutoAccept, true) self.toggle_AutoFollow.isOn = MDL.Team.IsAutoFollow UIUtils.SetActive(self.toggle_AutoFollow, true) self.toggle_AutoInvited.isOn = MDL.Team.IsAutoInvited UIUtils.SetActive(self.toggle_AutoInvited, true) UIUtils.SetCanvasSortingOrderByMainCanvas(self.gameObject:GetComponent(typeof(UnityEngine.Canvas)), self.group_Button, CTL.Character.UpOrder.ChannelChat) end function UITeamPlatform:OnClosed() MDL.Team.ClearRecommendTeamList() end function UITeamPlatform:SavePageIndex() CTL.Team.SaveTeamBaseUIPageChildIndex(self.childIndex) end function UITeamPlatform:RefreshInviteButtonRedPoint(isAdd) local length = #MDL.Team.GetInviteList() length = isAdd and length or length - 1 self.btn_InvitedList:SetRedPoint(length > 0) end function UITeamPlatform:RefreshApplyButtonRedPoint(isAdd) local length = #MDL.Team.GetApplyTeamList() length = isAdd and length or length - 1 self.btn_ApplyList:SetRedPoint(length > 0) end function UITeamPlatform:SelectParentToggleIndex() if CTL.Team.IsInTeam() then self.parentView:SelectToggleIndex(1) end end function UITeamPlatform:RefreshButtonState() local isInTeam = CTL.Team.IsInTeam() if isInTeam then local isSelfLeader = CTL.Team.IsSelfLeader() self.state_Button:SetState(0) if not isSelfLeader then if MDL.Team.GetSelfMemberInfo().state == MDL.Team.MemberState.Following then UIUtils.SetActive(self.btn_FollowLead, false) UIUtils.SetActive(self.btn_CancelFollow, true) else UIUtils.SetActive(self.btn_FollowLead, true) UIUtils.SetActive(self.btn_CancelFollow, false) end else UIUtils.SetActive(self.btn_FollowLead, false) UIUtils.SetActive(self.btn_CancelFollow, false) end self.state_Toggle:SetState(isSelfLeader and 0 or 1) else self.state_Button:SetState(1) self.state_Toggle:SetState(2) if self.mainTarget == 0 then UIUtils.SetActive(self.btn_MatchTeam, false) end end end function UITeamPlatform:RefreshRightTeamList(mainTarget, subTarget, beginIndex) if self.mainTarget ~= mainTarget or self.subTarget ~= subTarget then if self.loop_TeamList.Count > 0 then self.loop_TeamList:ClearCells() end self.mainTarget = mainTarget self.subTarget = subTarget end local recommendTeamList = MDL.Team.GetRecommendTeamList() for i, v in ipairs(recommendTeamList) do if i >= beginIndex + 1 then self.loop_TeamList:AddData(v, 0) end end UIUtils.SetActive(self.group_Empty, self.loop_TeamList.Count == 0) end function UITeamPlatform:RefreshSingleTeamCell(data, cellTable) local target = data.target UIUtils.SetActive(cellTable.ico_TaskLevelTitle, false) if CTL.Team.IsSpecifiedTarget(target.mainTarget) == false then local targetInfo = MDL.Team.GetTeamTargetInfo(target.mainTarget, target.subTarget) if targetInfo.Activity then UIUtils.SetLabelText(cellTable.txt_TaskName, Const_IDS[targetInfo.Activity]) UIUtils.SetActive(cellTable.txt_TaskNameSec, false) else cellTable.txt_TaskName.text = targetInfo.ActivityName cellTable.txt_TaskNameSec.text = targetInfo.ActivitySub UIUtils.SetActive(cellTable.txt_TaskNameSec, true) end local unlockParam,unlockDes = MDL.Team.GetTeamTargetUnlockInfo(target.mainTarget, target.subTarget) UIUtils.SetLabel(cellTable.lab_TaskLevelNum, unlockDes) else UIUtils.SetLabelText(cellTable.txt_TaskName, CTL.Team.GetSpecifiedTargetTitle(target.mainTarget)) end if target.subTarget and target.subTarget > 0 then UIUtils.SetActive(cellTable.txt_TaskNameSec.gameObject, true) else UIUtils.SetActive(cellTable.txt_TaskNameSec.gameObject, false) end UIUtils.SetActive(cellTable.group_TaskInactive.gameObject, data.state == MDL.Team.TeamState.InActive) UIUtils.SetActive(cellTable.bg_Legion.gameObject, false) for i, v in ipairs(cellTable.group_Head) do if data.members[i] then self:RefreshSingleMember(data.members[i], v, data.crossTeam) UIUtils.SetActive(v.group_Hero.gameObject, true) else UIUtils.SetActive(v.group_Hero.gameObject, false) end end local limit = data.limit if limit.level == 0 then UIUtils.SetActive(cellTable.group_LimitLevel.gameObject, false) else UIUtils.SetActive(cellTable.group_LimitLevel.gameObject, true) local levelText = MDL.HeroSelect.GetTeamLevelName(limit.level) if MDL.HeroSelect.GetTeamLevel() < limit.level then cellTable.lab_LimitLevelNum.text = UTL.Color.FormatRedColor(levelText) else cellTable.lab_LimitLevelNum.text = levelText end end if limit.power == 0 then UIUtils.SetActive(cellTable.group_LimitCE, false) else UIUtils.SetActive(cellTable.group_LimitCE, true) if MDL.Player.GetLineUpGs() < limit.power then cellTable.lab_LimitCE.text = UTL.Color.FormatRedColor(limit.power) else cellTable.lab_LimitCE.text = limit.power end end UIUtils.SetActive(cellTable.group_LimitInBattle.gameObject, data.state == MDL.Team.TeamState.TSInBattle) end function UITeamPlatform:RefreshSingleMember(memberInfo, cell, isCrossServerTeam) local baseInfo = memberInfo.playerShowInfo CTL.Character.SetPortraitAndFrame(cell.UIHeroHead150, baseInfo.PortraitId, baseInfo.FrameId, baseInfo.level) UIUtils.SetCanvasSortingOrderByMainCanvas(cell.UIHeroHead150.effectUpCanvas, cell.UpCanvas, CTL.Character.UpOrder.Common) UIUtils.SetActive(cell.ico_Leader.gameObject, memberInfo.type == MDL.Team.MemberType.Leader) UIUtils.SetActive(cell.ico_Legion.gameObject, false) if isCrossServerTeam then cell.lab_RoleName.text = baseInfo.name .. CTL.CrossServer.GetServerShowStr(baseInfo.ShowServerId, CTL.CrossServer.IsSameServer(baseInfo.MergeServerId)) else cell.lab_RoleName.text = baseInfo.name end CTL.Player.OperateGenderImage(cell.group_Gender, baseInfo.sex) cell.acid = memberInfo.memberId --同势力显示徽记 if MDL.Guild.IsSameGuild(baseInfo.guildId) then UIUtils.SetLabel(cell.txt_GuildInitiate,baseInfo.EmblemContent) if baseInfo.EmblemFrame > 0 then UTL.Item.SetAtlasSprite(cell.img_GuildMark, "UI_Guild", DataSheetManager.GuildEmblem:GetDataByID(baseInfo.EmblemFrame).Image) end UIUtils.SetActive(cell.txt_GuildInitiate, true) UIUtils.SetActive(cell.img_GuildMark, true) else UIUtils.SetActive(cell.txt_GuildInitiate, false) UIUtils.SetActive(cell.img_GuildMark, false) end end function UITeamPlatform:OnClickRefresh() self.loop_TeamList:ClearCells() MDL.Team.ClearRecommendTeamList() MDL.Team.TeamRecommendListAutoReq(self.mainTarget, self.subTarget) end function UITeamPlatform:OnButtonClicked(comp) if comp == self.btn_CreateTeam then UIManager.OpenView(Const_UI_Lua.UIEnum.UITeamCreatePanel, {mainTarget = self.mainTarget, subTarget = self.subTarget}) elseif comp == self.btn_MatchTeam then elseif comp == self.btn_FollowLead then MDL.Team.TeamFollowReq(true) elseif comp == self.btn_CancelFollow then MDL.Team.TeamFollowReq(false) elseif comp == self.btn_LeaveTeam then MDL.Team.TeamLeaveReq() elseif comp == self.event_Refresh then self:OnClickRefresh() elseif comp == self.btn_InvitedList then UIManager.OpenView(Const_UI_Lua.UIEnum.UITeamInvitedPanel) elseif comp == self.btn_ApplyList then UIManager.OpenView(Const_UI_Lua.UIEnum.UITeamApplyPanel) end end function UITeamPlatform:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_TeamList then self:RefreshSingleTeamCell(data, cellTable) end end function UITeamPlatform:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_TeamList then if target == cellTable.btn_Apply then CTL.Team.SendTeamApplyRequest(data.teamId, data.target, data.limit) else --弹出交互页面弹窗 for i, v in ipairs(cellTable.group_Head) do if target == v.btn then CTL.PlayerInteract.OpenFriendInteractView(v.acid) EventSystem.Dispatch(EventID.UI_Team_SavePageIndex) end end end end end function UITeamPlatform:OnScrollBottom(comp, isBottom) if isBottom then MDL.Team.TeamRecommendListAutoReq(self.mainTarget, self.subTarget) end end function UITeamPlatform:OnValueChanged(comp, state) if comp == self.toggle_AutoAccept then MDL.Team.IsAutoAccept = self.toggle_AutoAccept.isOn elseif comp == self.toggle_AutoFollow then MDL.Team.IsAutoFollow = self.toggle_AutoFollow.isOn elseif comp == self.toggle_AutoInvited then MDL.Team.IsAutoInvited = self.toggle_AutoInvited.isOn end end function UITeamPlatform:OpenCommonFoldView() self.foldView = self.LeftPanel:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UICommonFoldView), {mainData = MDL.Team.GetTeamPlayListData(), parentView = self}, nil, nil) end function UITeamPlatform:UpdateFoldView() self.LeftPanel:CloseView() self.foldView = self.LeftPanel:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UICommonFoldView), {mainData = MDL.Team.GetTeamPlayListData(), parentView = self}, nil, nil) end function UITeamPlatform:initMainCellCallBack(scrollRect, cellTable, data, index) cellTable.lab_Check.text = data.MainTitle cellTable.lab_UnCheck.text = data.MainTitle UIUtils.SetActive(cellTable.Check.gameObject, false) UIUtils.SetActive(cellTable.UnCheck.gameObject, true) if data.Menu == CTL.Rank.MenuLevel.Single then UIUtils.SetActive(cellTable.Check.gameObject, false) UIUtils.SetActive(cellTable.UnCheck.gameObject, true) UIUtils.SetActive(cellTable.UnCheckmarkArrow.gameObject, false) UIUtils.SetActive(cellTable.CheckmarkArrow.gameObject, false) end end function UITeamPlatform:initSubCellCallBack(scrollRect, cellTable, data, index) UIUtils.SetActive(cellTable.Check.gameObject, false) UIUtils.SetActive(cellTable.UnCheck.gameObject, true) UIUtils.SetLabel(cellTable.lab_Sub, UTL.Color.FormatTextByColor(UNSELECT_COLOR, data.SubTitle)) end function UITeamPlatform:clickMainCellCallBack(scrollRect, cellTable, target, data, index, isFold) if data.Menu == CTL.Rank.MenuLevel.Single then if self.childIndex ~= index then MDL.Team.TeamRecommendListAutoReq(data.ID, 0) end UIUtils.SetActive(cellTable.Check.gameObject, true) UIUtils.SetActive(cellTable.UnCheck.gameObject, false) self.childIndex = index elseif data.Menu == CTL.Rank.MenuLevel.Double then local subIndex = index + 1 local hasAddSubCell = false if table.containValue(MDL.MultiplayerDungeon.SubActivityId, data.ID) then subIndex = index + #data.subData hasAddSubCell = true end scrollRect:SelectIndex(subIndex) if hasAddSubCell then --中间插入了子cell,需要加个延迟才能移动过去 self.delayOptScrollRect = scrollRect self.delayOptMoveIndex = subIndex self:StartRepeatFunc(self.DelayOptScrollFunc, 0.1, 1) else scrollRect:MoveIndex(subIndex) end end end function UITeamPlatform:DelayOptScrollFunc(deltaTime, timeSinceUpdate) if self.delayOptScrollRect and self.delayOptMoveIndex then self.delayOptScrollRect:MoveIndex(self.delayOptMoveIndex) self.delayOptScrollRect = nil self.delayOptMoveIndex = nil end end function UITeamPlatform:clickSubCellCallBack(scrollRect, cellTable, target, data, index) if data.Menu == CTL.Rank.MenuLevel.Double then UIUtils.SetLabel(cellTable.lab_Sub, UTL.Color.FormatTextByColor(SELECTED_COLOR, data.SubTitle)) MDL.Team.TeamRecommendListAutoReq(data.ID, data.subId) end end return UITeamPlatform