local SpecialTeam_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') local TeamShoutCDTime = DataSheetManager.ConstData:GetDataByID("TeamNoticeCD").IntValue local SpecialTeamApplyAutoPopUPKey = "SpecialTeam_Apply_AutoPopUP" local SpecialTeamInvitedAutoPopUPKey = "SpecialTeam_Invited_AutoPopUP" local GroupChatHasReadMsgKey = "GroupChatHasReadMsgKey" local GroupChatHasCreateKey = "GroupChatHasCreateKey" local SpecialTeamFullRedKey = "SpecialTeamFullRedKey" local SpecialTeamFullRedTeamId = "SpecialTeamFullRedTeamId" local MAX_MSG_COUNT = 50 local HISTORY_MSG_COUNT = 5 --单次请求历史消息的条数 local CONST_LENGTH_NAME = 14 function SpecialTeam_Controller.OnStartup() EventSystem.Regist(EventID.New_Day_Refresh, private.RefreshAutoPopUPValue) EventSystem.Regist(EventID.UIBattle_OnFriendBaseClose, private.OnFriendPanelClose) EventSystem.Regist(EventID.UI_SpecialTeam_LeaveTeam, SpecialTeam_Controller.RefreshTeamNotice) EventSystem.Regist(EventID.UI_SpecialTeam_CreateTeam, SpecialTeam_Controller.RefreshTeamNotice) EventSystem.Regist(EventID.UI_SpecialTeam_MemberInfoChange, private.OnTeamMemberCountChange) private.isGroupChatNoticeRed = false private.lastShoutTimeStamp = 0 private.groupChatMsgDic = {} end --region 群聊相关 function SpecialTeam_Controller.IsInGroupChatChannel(channelId) return private.groupChatMsgDic[channelId] end --加入群组,提供一个群组id function SpecialTeam_Controller.TryJoinGroupChat(groupId) local channelId = SpecialTeam_Controller.GetGroupChatKey(groupId) if private.groupChatMsgDic[channelId] == nil then MDL.ChannelChat.JoinChannel(MDL.ChannelChat.ChannelCfgId.GroupChat, channelId) end end function SpecialTeam_Controller.ExitGroupChat(groupId) local channelId = SpecialTeam_Controller.GetGroupChatKey(groupId) if private.groupChatMsgDic[channelId] then MDL.ChannelChat.ExitChannel(MDL.ChannelChat.ChannelCfgId.GroupChat, channelId) private.groupChatMsgDic[channelId] = nil EventSystem.Dispatch(EventID.UI_UpdateChatRed) end end function SpecialTeam_Controller.OnJoinGroupChat(channelId) if private.groupChatMsgDic[channelId] == nil then private.groupChatMsgDic[channelId] = {} else --断线重连尝试请求历史消息 SpecialTeam_Controller.TryGetHistory(channelId) end EventSystem.Dispatch(EventID.UI_GroupChat_JoinChannel, channelId) end function SpecialTeam_Controller.OnExitGroupChat(channelId) if private.groupChatMsgDic[channelId] then private.groupChatMsgDic[channelId] = nil end EventSystem.Dispatch(EventID.UI_GroupChat_ExitChannel, channelId) end --断线重连重进所有群组频道 function SpecialTeam_Controller.JoinAllGroupChat() for channelId, v in pairs(private.groupChatMsgDic) do MDL.ChannelChat.JoinChannel(MDL.ChannelChat.ChannelCfgId.GroupChat, channelId) end end --是否开启群聊 function SpecialTeam_Controller.GetIsGroupChatOpen() return MDL.SpecialTeam.HasTeam() and MDL.SpecialTeam.GetMemberNumbers() > 1 end function SpecialTeam_Controller.GetGroupChatKey(value) local chatCfgData = DataSheetManager.Chat:GetDataByID(MDL.ChannelChat.ChannelCfgId.GroupChat) return chatCfgData.ChannelPrefix .. value end function SpecialTeam_Controller.TryGetHistory(channelId) local chatList = SpecialTeam_Controller.GetGroupChatMsgList(channelId) if chatList == nil then return end local curCount = #chatList if curCount >= MAX_MSG_COUNT then --已达缓存上限,不再请求 return end local nextCount = math.min(curCount + HISTORY_MSG_COUNT, MAX_MSG_COUNT) MDL.ChannelChat.GetHistoryInfosByChannelId(channelId, curCount, nextCount) end --历史消息顺序是反的 function SpecialTeam_Controller.AddGroupChatMsg(channelId, msgData, isHistory) local msgList = private.groupChatMsgDic[channelId] if msgList then --直接按时间排序即可,不考虑历史消息还是及时消息的先后顺序了 table.insert(msgList, msgData) table.sort(msgList, private.SortByMsgTime) if #msgList > MAX_MSG_COUNT then table.remove(msgList, 1) end else private.groupChatMsgDic[channelId] = { msgData } end EventSystem.Dispatch(EventID.UI_GroupChat_NewMsg, channelId, msgData, isHistory) end function private.SortByMsgTime(msgData1, msgData2) return msgData1.msgTime < msgData2.msgTime end function SpecialTeam_Controller.GetGroupChatMsgList(channelId) local chatTab = private.groupChatMsgDic[channelId] return chatTab end function SpecialTeam_Controller.GetGroupChatList() local groupList = {} for channelId, _ in pairs(private.groupChatMsgDic) do local groupInfo = SpecialTeam_Controller.GetGroupInfoByChannelId(channelId) if groupInfo then table.insert(groupList, groupInfo) end end return groupList end function SpecialTeam_Controller.GetGroupInfoByChannelId(channelId) local teamIdKey = SpecialTeam_Controller.GetGroupChatKey(MDL.SpecialTeam.GetMyTeamId()) if teamIdKey == channelId then if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then return private.CreatGroupChatData(MDL.SpecialTeam.GetMyTeamName(), UIUtils.GetLocalizedTxt(Const_IDS.IDS_TeamFairTournamen_ChatTeam), MDL.SpecialTeam.GetMemberNumbers(), 3, channelId) else return private.CreatGroupChatData(MDL.SpecialTeam.GetMyTeamName(), UIUtils.GetLocalizedTxt(Const_IDS.IDS_HeroMatch3v3_ChatTeam), MDL.SpecialTeam.GetMemberNumbers(), 3, channelId) end end end function private.CreatGroupChatData(name, desc, curNum, maxNum, groupChatChannelId) return { isGroupChat = true, groupChatName = name, groupChatDesc = desc, groupChatCurNum = curNum, groupChatMaxNum = maxNum, groupChatChannelId = groupChatChannelId, } end function SpecialTeam_Controller.GetSumGroupChatRedCount() local unreadCount = 0 if CTL.SpecialTeam.GetIsGroupChatOpen() == false then return unreadCount end for _, chatTab in pairs(private.groupChatMsgDic) do for i, msgData in ipairs(chatTab) do if msgData.unRead then unreadCount = unreadCount + 1 end end end if unreadCount > 99 then return 99 end return unreadCount end function SpecialTeam_Controller.GetGroupChatRedCount(channelId) local unreadCount = 0 local chatTab = private.groupChatMsgDic[channelId] if chatTab then for i, v in ipairs(chatTab) do if v.unRead then unreadCount = unreadCount + 1 end end end if unreadCount > 99 then return 99 end return unreadCount end function SpecialTeam_Controller.NoticeGroupChatRed(value, isRemove) if value and MDL.SpecialTeam.GetMemberNumbers() <= 1 then return end if isRemove then private.noticeGroupTab = nil PersistentData.PlayerData:Set(GroupChatHasCreateKey, nil, true) else if value then private.noticeGroupTab = PersistentData.PlayerData:Get(GroupChatHasCreateKey) if private.noticeGroupTab == nil then private.noticeGroupTab = {} end local isAll = true for i, v in ipairs(MDL.SpecialTeam.GetAllMembersInfo()) do if private.noticeGroupTab[v.memberId] == nil then isAll = false break end end --这些队友我都提示过了 if isAll then value = false end else if private.noticeGroupTab == nil then private.noticeGroupTab = {} else table.clear(private.noticeGroupTab) end for i, v in ipairs(MDL.SpecialTeam.GetAllMembersInfo()) do private.noticeGroupTab[v.memberId] = 1 end PersistentData.PlayerData:Set(GroupChatHasCreateKey, private.noticeGroupTab, true) end end private.isGroupChatNoticeRed = value EventSystem.Dispatch(EventID.UI_UpdateChatRed) end function SpecialTeam_Controller.GetNoticeGroupChatRed() return private.isGroupChatNoticeRed and 1 or 0 end function private.InitHasReadMsgDict() if private.hasReadMsgDict == nil then private.hasReadMsgDict = PersistentData.PlayerData:Get(GroupChatHasReadMsgKey) if private.hasReadMsgDict == nil then private.hasReadMsgDict = {} end end end function SpecialTeam_Controller.IsMsgUnRead(msgData) private.InitHasReadMsgDict() if private.hasReadMsgDict[msgData.uuid] then return false end return true end function SpecialTeam_Controller.HasReadMsg(msgData) private.InitHasReadMsgDict() private.hasReadMsgDict[msgData.uuid] = 1 end function private.OnFriendPanelClose() if private.hasReadMsgDict then PersistentData.PlayerData:Set(GroupChatHasReadMsgKey, private.hasReadMsgDict, true) end end --endregion function private.OnTeamMemberCountChange() private.SetSpecialTeamFullRedKey() if MDL.SpecialTeam.GetMemberNumbers() <= 1 then SpecialTeam_Controller.NoticeGroupChatRed(false, true) else SpecialTeam_Controller.NoticeGroupChatRed(true) end end function private.SetSpecialTeamFullRedKey() if MDL.SpecialTeam.IsTeamFull() then if not SpecialTeam_Controller.IsHasSpecialTeamFullRedKey() then local teamId = PersistentData.PlayerData:Get(SpecialTeamFullRedTeamId, -1) if teamId ~= MDL.SpecialTeam.GetMyTeamId() then PersistentData.PlayerData:Set(SpecialTeamFullRedKey, true) PersistentData.PlayerData:Set(SpecialTeamFullRedTeamId, MDL.SpecialTeam.GetMyTeamId()) EventSystem.Dispatch(EventID.UI_SpecialTeam_TeamMemberFull) end end else SpecialTeam_Controller.RemoveSpecialTeamFullRedKey() end end function SpecialTeam_Controller.RemoveSpecialTeamFullRedKey() if SpecialTeam_Controller.IsHasSpecialTeamFullRedKey() then PersistentData.PlayerData:Set(SpecialTeamFullRedKey, false, true) EventSystem.Dispatch(EventID.UI_SpecialTeam_TeamMemberFull) end end function SpecialTeam_Controller.IsHasSpecialTeamFullRedKey() return PersistentData.PlayerData:Get(SpecialTeamFullRedKey, false) end function SpecialTeam_Controller.RefreshTeamNotice() private.RefreshInviteNotice() private.RefreshApplyNotice() private.SetSpecialTeamFullRedKey() end function SpecialTeam_Controller.OnInviteInfoHandle() EventSystem.Dispatch(EventID.UI_SpecialTeam_InviteInfoHandle) private.RefreshInviteNotice() end function private.RefreshInviteNotice() local inviteLength = #MDL.SpecialTeam.GetInviteList() if inviteLength > 0 then if BattleDataGetter.IsTownLevel() and not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UISpecialTeamInvited) and SpecialTeam_Controller.IsAutoPopUpInvited() then if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIActivitiesRemind) or UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIFightThroneRemind) then CTL.HomeMain.AddTownHomeDelayView(Const_UI_Lua.UIEnum.UISpecialTeamInvited) else if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIFriendBase) then CTL.SpecialTeam.OpenTeamInvited() end end end CTL.HomeMain.AddMainNotice(CTL.HomeMain.NoticeType.SpecialTeamInvite) else CTL.HomeMain.RemoveMainNotice(CTL.HomeMain.NoticeType.SpecialTeamInvite) end end function SpecialTeam_Controller.OnApplyInfoHandle() EventSystem.Dispatch(EventID.UI_SpecialTeam_ApplyInfoHandle) private.RefreshApplyNotice() end function private.RefreshApplyNotice() if MDL.SpecialTeam.IsHasMemberApply() then if BattleDataGetter.IsTownLevel() and not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UISpecialTeamApplyPopUp) and SpecialTeam_Controller.IsAutoPopUpApply() then if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIActivitiesRemind) or UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIFightThroneRemind) then CTL.HomeMain.AddTownHomeDelayView(Const_UI_Lua.UIEnum.UISpecialTeamApplyPopUp) else if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIFriendBase) then CTL.SpecialTeam.OpenTeamApplyPopUp() end end end CTL.HomeMain.AddMainNotice(CTL.HomeMain.NoticeType.SpecialTeamApply) else CTL.HomeMain.RemoveMainNotice(CTL.HomeMain.NoticeType.SpecialTeamApply) end end function SpecialTeam_Controller.OpenTeamInteractive(memberInfo, posX, posY) local memberId = memberInfo.memberId if memberId ~= BattleDataGetter.GetAcID() then SpecialTeam_Controller.OpenTeamInteractive(memberInfo, posX, posY) end end --退出战团 function SpecialTeam_Controller.TryQuitTeam() if MDL.SpecialTeam.HasTeam() == false then CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroMatch3v3_LeaveTeamFail"]) return end local hasRecord = MDL.SpecialTeam.CheckHasRecord() if hasRecord then CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroMatch3v3_Battled2"]) return end UTL.MessageBox.ShowOKCancelBox(nil, string.FormatByIdsId(Const_IDS.IDS_HeroMatch3v3_QuitTeam1, MDL.SpecialTeam.GetMyTeamName()), MDL.SpecialTeam.TeamWarLeaveReq) end --申请战团 function SpecialTeam_Controller.TryApplyTeam(teamId) if MDL.SpecialTeam.HasTeam() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroMatch3v3_HaveBattleTeam3"]) return end MDL.SpecialTeam.TeamWarApplyReq(teamId) end --升为团长 function SpecialTeam_Controller.TryChangeLeader(playerId) if playerId == BattleDataGetter.GetAcID() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroMatch3v3_LeaderAlready"]) return end if MDL.SpecialTeam.IsSelfLeader() == false then CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroMatch3v3_OnlyLeaderCan1"]) return end MDL.SpecialTeam.TeamWarLeaderChangeReq(playerId) end --请离战团 function SpecialTeam_Controller.TryKickOutMember(playerId) if MDL.SpecialTeam.IsSelfLeader() == false then CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroMatch3v3_OnlyLeaderCan2"]) return end if MDL.SpecialTeam.CheckHasRecord() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroMatch3v3_Battled2"]) return end local playerName = MDL.SpecialTeam.GetMemberNameById(playerId) if playerName then UTL.MessageBox.ShowOKCancelBox(nil, string.FormatByIdsId(Const_IDS.IDS_HeroMatch3v3_ReallyKickOut, playerName), function() MDL.SpecialTeam.TeamWarKickOutMemberReq(playerId) end) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroMatch3v3_OnlyMemberCan2) end end --邀请玩家入团 function SpecialTeam_Controller.TryInviteMember(headInfo) if MDL.SpecialTeam.HasTeam() == false then CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroMatch3v3_NoTeam"]) return end if MDL.SpecialTeam.CheckHasRecord() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroMatch3v3_Battled2"]) return end if headInfo.isOnline == false then CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroMatch3v3_OutlineCannot2"]) return end MDL.SpecialTeam.TeamWarInviteReq(headInfo.acid) end --接受玩家申请 function SpecialTeam_Controller.AcceptInvitation(inviterInfo) --如果邀请者是队长,直接发进队;如果不是,则发申请入队 local isFromLeader = inviterInfo.teamInfo.members[1].memberId == inviterInfo.inviteAcid if isFromLeader then MDL.SpecialTeam.TeamWarInviteHandleReq(inviterInfo.teamInfo.teamId, true) else MDL.SpecialTeam.TeamWarApplyReq(inviterInfo.teamInfo.teamId) end end --打开群聊 function SpecialTeam_Controller.OpenMyTeamChat() if SpecialTeam_Controller.GetIsGroupChatOpen() then CTL.Friend.OpenFriendPanel(CTL.Friend.MainIndex.Main, 99) end end --打开布阵界面 function SpecialTeam_Controller.OpenFormatSetting() if MDL.SpecialTeam.HasTeam() then if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UISpecialTeamSelectOfficer, nil, "SpecialTeamFairChampionship/UISpecialTeamSelectOfficer") else UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UISpecialTeamSelectOfficer) end else CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroMatch3v3_TeamCreateFirst"]) end end --创建战队 function SpecialTeam_Controller.TryCreateTeam(teamName) if MDL.SpecialTeam.HasTeam() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroMatch3v3_HaveTeamAlready"]) return end if string.isNilOrEmpty(teamName) then CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroMatch3v3_NoNameNoTeam"]) return end local strLen = UTL.String.GetStrCharCount(teamName, 2) if strLen > CONST_LENGTH_NAME then -- 名字长度不能超过14个字符 CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERROR_NETWORK_AUTH_1) return end MDL.SpecialTeam.TeamWarCreateReq(teamName) end --打开战队主界面 function SpecialTeam_Controller.OpenMain(selectIndex) if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UISpecialTeamWithRankPanel, {selectIndex=selectIndex}, "SpecialTeamFairChampionship/UISpecialTeamBasePanel") else UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UISpecialTeamBasePanel, {selectIndex=selectIndex}) end end function SpecialTeam_Controller.OpenTeamCreatePopUp() if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then UIManager.OpenView(Const_UI_Lua.UIEnum.UISpecialTeamCreatePopUp, nil, "SpecialTeamFairChampionship/UISpecialTeamCreatePopUp") else UIManager.OpenView(Const_UI_Lua.UIEnum.UISpecialTeamCreatePopUp) end end function SpecialTeam_Controller.OpenTeamApplyPopUp() if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then UIManager.OpenView(Const_UI_Lua.UIEnum.UISpecialTeamApplyPopUp, nil, "SpecialTeamFairChampionship/UISpecialTeamApplyPopUp") else UIManager.OpenView(Const_UI_Lua.UIEnum.UISpecialTeamApplyPopUp) end end function SpecialTeam_Controller.OpenTeamInteractive(memberInfo, posX, posY) if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then UIManager.OpenView(Const_UI_Lua.UIEnum.UISpecialTeamInteractive, {memberInfo=memberInfo,x=posX,y=posY}, "SpecialTeamFairChampionship/UISpecialTeamInteractive") else UIManager.OpenView(Const_UI_Lua.UIEnum.UISpecialTeamInteractive, {memberInfo=memberInfo,x=posX,y=posY}) end end function SpecialTeam_Controller.OpenTeamInvited() if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then UIManager.OpenView(Const_UI_Lua.UIEnum.UISpecialTeamInvited, nil, "SpecialTeamFairChampionship/UISpecialTeamInvited") else UIManager.OpenView(Const_UI_Lua.UIEnum.UISpecialTeamInvited) end end function SpecialTeam_Controller.OpenTeamInviteInPopUp() if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then UIManager.OpenView(Const_UI_Lua.UIEnum.UISpecialTeamInviteInPopUp, nil, "SpecialTeamFairChampionship/UISpecialTeamInviteInPopUp") else UIManager.OpenView(Const_UI_Lua.UIEnum.UISpecialTeamInviteInPopUp) end end function SpecialTeam_Controller.GetMyTeamViewPath() if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then return "SpecialTeamFairChampionship/UISpecialTeamMyTeam" else return Const_UI_Lua.UIEnum.UISpecialTeamMyTeam end end function SpecialTeam_Controller.GetTeamPlatformViewPath() if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then return "SpecialTeamFairChampionship/UISpecialTeamPlatform" else return Const_UI_Lua.UIEnum.UISpecialTeamPlatform end end function SpecialTeam_Controller.GetTeamRankViewPath() if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then return "SpecialTeamFairChampionship/UISpecialTeamRank" else return Const_UI_Lua.UIEnum.UISpecialTeamRank end end --是否可以编辑阵容 function SpecialTeam_Controller.IsCanEditorFreeline() if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then return false end return true end --是否显示创建战队提示 function SpecialTeam_Controller.GetShowCreateTeamTipIds() if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then return Const_IDS.IDS_HeroMatch3v3_TeamCanJoin end return Const_IDS.IDS_HeroMatch3v3_TeamCanJoin end --是否显示创建战队提示 function SpecialTeam_Controller.IsShowCreateTeamTip() if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then return false end return true end function SpecialTeam_Controller.IsShowPlayerGs() if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then return false end return true end function SpecialTeam_Controller.IsShowWarZoneButton() if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then return true end return false end function SpecialTeam_Controller.IsShowPlayerServer() if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then return false end return true end function SpecialTeam_Controller.GetTeamPlayerModelPos() if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then return {{posX=1.58,posY=0,scale=0.9},{posX=-0.16,posY=0.01,scale=0.9},{posX=-1.8,posY=-0.03,scale=0.9}} end return {{posX=1.5,posY=0.1,scale=0.9},{posX=0.15,posY=0.1,scale=0.9},{posX=-1.2,posY=0.1,scale=0.9}} end --获取战队组建时间 function SpecialTeam_Controller.GetTeamCreateTime() if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then return CTL.TeamFairChampionship.GetMatchStateTimeInfo(MDL.TeamFairChampionship.Enum_BigStage.Advance) end return nil end --获取能进入比赛的队伍数量 function SpecialTeam_Controller.GetEnterMatchTeamCount() if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then return MDL.TeamFairChampionship.GetEnterMatchTeamCount() end return nil end --获取战队组建标题 function SpecialTeam_Controller.GetTeamCreatePanelTitle() if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then return Const_IDS.IDS_TeamFairTournamen_CreateTeamName end return Const_IDS.IDS_HeroMatch3v3_CreateTeamName end --获取自己的战队界面的提示ids function SpecialTeam_Controller.GetMyTeamCreateTip() if MDL.SpecialTeam.GetCurTeamType() == MDL.Unlock.FunctionType.TeamFairChampionship then return Const_IDS.IDS_TeamFairTournamen_MatchTips end return Const_IDS.IDS_HeroMatch3v3_MatchTips end function SpecialTeam_Controller.ShutRecruitMsg(isInit, channelType) if isInit then private.lastShoutTimeStamp = 0 else local currentTime = UTL.Time.GetServerTimestamp() if private.lastShoutTimeStamp ~= 0 then if currentTime - private.lastShoutTimeStamp < TeamShoutCDTime then return end end private.lastShoutTimeStamp = currentTime end local teamInfo = MDL.SpecialTeam.GetTeamInfo() local leaderName = MDL.SpecialTeam.GetMemberNameById(MDL.SpecialTeam.GetTeamLeaderId()) MDL.ChannelChat.SendChatSpecialTeamRecruitMsg(teamInfo.teamId, MDL.SpecialTeam.GetMemberNumbers(), leaderName, teamInfo.teamName, MDL.SpecialTeam.GetCurTeamType(), channelType) end function SpecialTeam_Controller.GetShutTimeCD() local shoutCdTime = 0 if private.lastShoutTimeStamp ~= 0 then shoutCdTime = TeamShoutCDTime - (UTL.Time.GetServerTimestamp() - private.lastShoutTimeStamp) end return shoutCdTime < 0 and 0 or shoutCdTime end function private.RefreshAutoPopUPValue() PersistentData.DeviceData:Set(SpecialTeamApplyAutoPopUPKey, 0, true) PersistentData.DeviceData:Set(SpecialTeamInvitedAutoPopUPKey, 0, true) end -- 是否自动弹出队伍申请弹窗 function SpecialTeam_Controller.IsAutoPopUpApply() local lastTime = PersistentData.DeviceData:Get(SpecialTeamApplyAutoPopUPKey) or 0 if lastTime == 0 then return true elseif lastTime > 0 and UTL.Time.IsTimestampCrossDay(lastTime) then PersistentData.DeviceData:Set(SpecialTeamApplyAutoPopUPKey, 0, true) return true end return false end function SpecialTeam_Controller.SetAutoApplePopUpValue(value) if value then if not SpecialTeam_Controller.IsAutoPopUpApply() then PersistentData.DeviceData:Set(SpecialTeamApplyAutoPopUPKey, 0, true) end else if SpecialTeam_Controller.IsAutoPopUpApply() then PersistentData.DeviceData:Set(SpecialTeamApplyAutoPopUPKey, UTL.Time.GetServerTimestamp(), true) end end end -- 是否自动弹出队伍邀请弹窗 function SpecialTeam_Controller.IsAutoPopUpInvited() local lastTime = PersistentData.DeviceData:Get(SpecialTeamInvitedAutoPopUPKey) or 0 if lastTime == 0 then return true elseif lastTime > 0 and UTL.Time.IsTimestampCrossDay(lastTime) then PersistentData.DeviceData:Set(SpecialTeamInvitedAutoPopUPKey, 0, true) return true end return false end function SpecialTeam_Controller.SetAutoInvitedPopUpValue(value) if value then if not SpecialTeam_Controller.IsAutoPopUpInvited() then PersistentData.DeviceData:Set(SpecialTeamInvitedAutoPopUPKey, 0, true) end else if SpecialTeam_Controller.IsAutoPopUpInvited() then PersistentData.DeviceData:Set(SpecialTeamInvitedAutoPopUPKey, UTL.Time.GetServerTimestamp(), true) end end end --尝试添加战团操作按钮 function SpecialTeam_Controller.TryAddOptBtn(btnList, interactiveInfo) if MDL.SpecialTeam.IsFunctionOpen() then if MDL.SpecialTeam.IsTeamFull() then --我的战团满员不显示 return end if interactiveInfo.HeadInfo.IsCross then --跨服不显示 return end if string.isNilOrEmpty(interactiveInfo.TeamWarID) then --目标没战团,显示邀入战团 table.insert(btnList, MDL.PlayerInteract.InteractType.SpecialTeamInvite) else --目标有战团,显示申请战团 table.insert(btnList, MDL.PlayerInteract.InteractType.SpecialTeamApply) end end end function SpecialTeam_Controller.OnFuncIdClose() MDL.SpecialTeam.ClearAll() --暂时只有单功能,直接派发 EventSystem.Dispatch(EventID.UI_SpecialTeam_CloseAll) end return SpecialTeam_Controller