using LitJson; using System; using System.Collections.Generic; using System.Linq; using vnxbqy.UI; public class CrossServerGodBattleFieldAssortModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk { public readonly uint FuncMapID = 32060; //古神战场组队功能地图ID public readonly uint FuncMapEx = 0; public readonly byte QueryCount = 20; //查询条数 //当前展示中的类型 public uint HaveSpace = 1; // 是否只查看有空位置的队伍 public uint IDLimitType = 0; // ID限制类型:1-同仙盟队长;2-同ServerGroupID队长;3-同ServerID队长 //<索引,<队伍ID,队伍信息>> 所有队伍信息字典 //索引 = FuncMapID * 1000 + FuncMapEx 分辨是哪个功能的 古神战场组队是32060000 Dictionary> assortTeamInfoDict = new Dictionary>(); //<索引,<类型,队伍ID列表>> 队伍信息的所属类型 //类型 = HaveSpace * 1000 + IDLimitType Dictionary>> assortFindTypeTeamIdDict = new Dictionary>>(); Dictionary playerOnlineStateInfoDict = new Dictionary(); public uint StartIndex; // 查看的起始索引, 默认0 public byte QueryCnt; // 查看条数,默认20,最大不超过100 public byte SearchLen; public string SearchMsg; // 指定搜索时有用,可搜索指定队伍ID或模糊搜索队伍名称,搜索时返回最多QueryCnt个数的队伍 public uint LoopIndex; // 服务器检索到的索引,列表下拉时下一个查询包的StartIndex从这个LoopIndex开始 public byte TeamCount; // 如果返回的队伍数小于QueryCnt,代表服务器已经没有满足条件的队伍了,列表再下拉时不再发查询包 public bool isOnlyServerGroupIDLeader = false; //是否经查看自己服务器的队长 public bool isAutoJoin = false; //是否允许自动加入 public bool isSendB924Pack = false; public long nowPowerNum; //玩家设定多少战力才能加入 public int lastWorldChannelTime; //上次点击世界频道按钮的时间 public int lastCrossServiceChannelTime; //上次点击跨服频道按钮的时间 public int worldChannelTimeCD; //上次点击世界频道按钮的时间,秒 public int crossServiceChannelTimeCD; //上次点击跨服频道按钮的时间,秒 public bool isDisplayRedPoint = true; public event Action UpdateQueryPlayerFuncTeamRetInfoEvent; //玩家没有队伍 public event Action UpdateTeamInfoEvent; //队伍信息更新 public event Action UpdateFindInfoEvent; //队伍查找信息更新 public event Action UpdateTeamDissolveEvent; //队伍销毁 public event Action UpdatePlayerOnlineStateInfoEvent; //玩家在线状态变化 public event Action AddScrollerEvent; //增加项 Redpoint entranceRedPoint = new Redpoint(21304, MainRedDot.CrossServerGodBattleFieldAssort); //队伍入口红点 Redpoint manageRedPoint = new Redpoint(MainRedDot.CrossServerGodBattleFieldAssort, MainRedDot.CrossServerGodBattleFieldAssort * 10 + 1); //申请审理按钮红点 DailyQuestModel dailyQuestModel { get { return ModelCenter.Instance.GetModel(); } } RankModel rankModel { get { return ModelCenter.Instance.GetModel(); } } public override void Init() { rankModel.onRankRefresh += UpdatePlayerBillboardEvent; ILCrossServerModel.Instance.onSelectUpdate += OnSelectUpdate; dailyQuestModel.dailyQuestProgressUpdateEvent += DailyQuestProgressUpdateEvent; worldChannelTimeCD = int.Parse(FuncConfigConfig.Get("GodBattleFieldAssort").Numerical1); crossServiceChannelTimeCD = int.Parse(FuncConfigConfig.Get("GodBattleFieldAssort").Numerical2); } public override void UnInit() { rankModel.onRankRefresh -= UpdatePlayerBillboardEvent; ILCrossServerModel.Instance.onSelectUpdate -= OnSelectUpdate; dailyQuestModel.dailyQuestProgressUpdateEvent -= DailyQuestProgressUpdateEvent; } public void OnBeforePlayerDataInitialize() { //清除所有封包 assortTeamInfoDict.Clear(); assortFindTypeTeamIdDict.Clear(); //选项赋初始值 isOnlyServerGroupIDLeader = false; isSendB924Pack = false; isDisplayRedPoint = true; } public void OnPlayerLoginOk() { LoadAllTime(); LoadPowerNum(); isAutoJoin = LocalSave.GetBool(StringUtility.Contact("gszczd_toggle1_", PlayerDatas.Instance.baseData.PlayerID)); TrySendQueryPlayerFuncTeam(); } //保证只发一次B924包 public void TrySendQueryPlayerFuncTeam() { if (isSendB924Pack) return; //没开古神战场 if (!FuncOpen.Instance.IsFuncOpen(208)) return; SendQueryPlayerFuncTeam(FuncMapID); isSendB924Pack = true; } //尝试获得指定索引的所有队伍字典 public bool TryGetTeamInfoDict(out Dictionary teamInfoDict) { teamInfoDict = null; // 初始化输出参数为 null uint index = FuncMapID * 1000 + FuncMapEx; if (assortTeamInfoDict.IsNullOrEmpty()) return false; if (!assortTeamInfoDict.TryGetValue(index, out teamInfoDict)) return false; return true; } //尝试获得古神战场的所有队伍类型信息 public bool TryGetTeamTypeDict(out Dictionary> teamTypeDict) { teamTypeDict = null; // 初始化输出参数为 null uint index = FuncMapID * 1000 + FuncMapEx; if (assortFindTypeTeamIdDict.IsNullOrEmpty()) return false; if (!assortFindTypeTeamIdDict.TryGetValue(index, out teamTypeDict)) return false; return true; } //尝试获取指定类型的队伍id列表 public bool TryGetTeamTypeList(uint haveSpace, uint iDLimitType, out List teamTypeList) { teamTypeList = null; if (!TryGetTeamTypeDict(out Dictionary> teamTypeDict)) return false; uint type = haveSpace * 1000 + iDLimitType; if (!teamTypeDict.TryGetValue(type, out teamTypeList)) return false; return true; } //清除寻找队伍指定类型的列表 public void ClearTeamTypeList() { if (!TryGetTeamTypeDict(out var teamTypeDict)) return; teamTypeDict.Clear(); } /// /// 获取玩家所在的队伍信息 /// /// 玩家是不是所在的队伍的队长 /// 玩家所在队伍的teamID /// 玩家所在队伍的详细信息 /// 返回false说明玩家没有队伍 public bool TryGetPlayerTeamInfo(out bool isCaptain, out uint teamID, out AssortTeamInfo teamInfo) { isCaptain = false; teamID = 0; teamInfo = null; if (!TryGetTeamInfoDict(out var teamInfoDict)) return false; var keyArray = teamInfoDict.Keys.ToArray(); for (int i = 0; i < keyArray.Length; i++) { uint nowTeamID = keyArray[i]; var team = teamInfoDict[nowTeamID]; uint captainID = team.CaptainID; var memberDict = team.MemberDict; if (memberDict.ContainsKey(PlayerDatas.Instance.baseData.PlayerID)) { isCaptain = captainID == PlayerDatas.Instance.baseData.PlayerID; teamID = nowTeamID; teamInfo = team; return true; } } return false; } //尝试获得指定teamID的队伍信息 public bool TryGetTeamInfo(uint teamID, out AssortTeamInfo teamInfo) { teamInfo = null; if (!TryGetTeamInfoDict(out var teamInfoDict)) return false; if (!teamInfoDict.TryGetValue(teamID, out teamInfo)) return false; return true; } //尝试获得队长信息 public bool TryGetTeamCaptainMemberInfo(AssortTeamInfo teamInfo, out AssortMemberInfo memberInfo) { memberInfo = null; uint captainID = teamInfo.CaptainID; if (teamInfo.MemberDict.IsNullOrEmpty()) return false; if (!teamInfo.MemberDict.TryGetValue(captainID, out memberInfo)) return false; return true; } //获得指定队伍成员的总战力 public ulong GetTeamTotalPower(AssortTeamInfo teamInfo) { if (teamInfo.MemberDict.IsNullOrEmpty()) return 0; ulong result = 0; var keyArray = teamInfo.MemberDict.Keys.ToArray(); for (int i = 0; i < keyArray.Length; i++) { uint playerId = keyArray[i]; var members = teamInfo.MemberDict[playerId]; result += members.FightPower; } return result; } public List GetApplicantSortList(List list) { int sortType = FunctionTeamSetConfig.Get((int)FuncMapID).SortType; int sortReverse = FunctionTeamSetConfig.Get((int)FuncMapID).SortReverse; //按队员总战力排序 倒序 if (sortType == 1 && sortReverse == 1) { list.Sort(CmpApplicantTeamByPower); } //按队员总战力排序 正序 else if (sortType == 1 && sortReverse == 0) { list.Sort(CmpApplicantTeamByPower); list.Reverse(); } //按队伍创建顺序排序 倒序 else if (sortType == 0 && sortReverse == 1) { list.Sort(CmpApplicantTeamByCreateTime); } //按队伍创建顺序排序 正序 else { list.Sort(CmpApplicantTeamByCreateTime); list.Reverse(); } return list; } int CmpApplicantTeamByPower(uint a, uint b) { ulong fightPower1; ulong fightPower2; TryGetPlayerTeamInfo(out bool isCaptain, out uint teamID, out AssortTeamInfo teamInfo); fightPower1 = teamInfo.ApplicantDict[a].FightPower; fightPower2 = teamInfo.ApplicantDict[b].FightPower; if (fightPower1 > fightPower2) { return -1; } else if (fightPower1 < fightPower2) { return 1; } else { return 0; } } int CmpApplicantTeamByCreateTime(uint a, uint b) { uint createTime1; uint createTime2; TryGetPlayerTeamInfo(out bool isCaptain, out uint teamID, out AssortTeamInfo teamInfo); createTime1 = teamInfo.CreateTime; createTime2 = teamInfo.CreateTime; if (createTime1 > createTime2) { return -1; } else if (createTime1 < createTime2) { return 1; } else { return 0; } } public List GetShowList() { //获得当前的类型的队伍id List teamTypeList; if (!TryGetTeamTypeList(HaveSpace, IDLimitType, out teamTypeList)) teamTypeList = new List(); teamTypeList = GetTeamSortList(teamTypeList); // 排序:战力高的在前 //获得玩家所有正在申请中的队伍 var requestTeamList = GetPlayerRequestTeam(); requestTeamList = GetTeamSortList(requestTeamList); // 排序:战力高的在前 // 从 teamTypeList 中移除所有正在申请中的队伍,并添加到 containsList 中 for (int i = 0; i < requestTeamList.Count; i++) { uint teamID = requestTeamList[i]; if (teamTypeList.Contains(teamID)) { teamTypeList.Remove(teamID); } } // 将正在申请的队伍插入到列表头部,保持排序顺序 for (int i = requestTeamList.Count - 1; i >= 0; i--) { uint teamID = requestTeamList[i]; teamTypeList.Insert(0, teamID); } return teamTypeList; } public List GetTeamSortList(List list) { int sortType = FunctionTeamSetConfig.Get((int)FuncMapID).SortType; int sortReverse = FunctionTeamSetConfig.Get((int)FuncMapID).SortReverse; //按队员总战力排序 倒序 if (sortType == 1 && sortReverse == 1) { list.Sort(CmpTeamByPower); } //按队员总战力排序 正序 else if (sortType == 1 && sortReverse == 0) { list.Sort(CmpTeamByPower); list.Reverse(); } //按队伍创建顺序排序 倒序 else if (sortType == 0 && sortReverse == 1) { list.Sort(CmpTeamByCreateTime); } //按队伍创建顺序排序 正序 else { list.Sort(CmpTeamByCreateTime); list.Reverse(); } return list; } int CmpTeamByPower(uint a, uint b) { ulong fightPower1; ulong fightPower2; TryGetTeamInfo(a, out AssortTeamInfo teamInfo1); TryGetTeamInfo(b, out AssortTeamInfo teamInfo2); fightPower1 = GetTeamTotalPower(teamInfo1); fightPower2 = GetTeamTotalPower(teamInfo2); if (fightPower1 > fightPower2) { return -1; } else if (fightPower1 < fightPower2) { return 1; } else { return 0; } } int CmpTeamByCreateTime(uint a, uint b) { uint createTime1; uint createTime2; TryGetTeamInfo(a, out AssortTeamInfo teamInfo1); TryGetTeamInfo(b, out AssortTeamInfo teamInfo2); createTime1 = teamInfo1.CreateTime; createTime2 = teamInfo2.CreateTime; if (createTime1 > createTime2) { return -1; } else if (createTime1 < createTime2) { return 1; } else { return 0; } } public bool TryGetPlayerRequestTeam(out List teamInfoList) { teamInfoList = new List(); if (!TryGetTeamInfoDict(out var teamInfoDict)) return false; var keyArray = teamInfoDict.Keys.ToArray(); for (int i = 0; i < keyArray.Length; i++) { uint teamID = keyArray[i]; var team = teamInfoDict[teamID]; uint captainID = team.CaptainID; var applyIDList = team.ApplyIDList; if (!applyIDList.IsNullOrEmpty() && applyIDList.Contains(PlayerDatas.Instance.baseData.PlayerID)) { teamInfoList.Add(teamID); } } return false; } //获取玩家所有正在申请中的队伍ID public List GetPlayerRequestTeam() { List result = new List(); if (TryGetTeamInfoDict(out var teamInfoDict)) { var keyArray = teamInfoDict.Keys.ToArray(); for (int i = 0; i < keyArray.Length; i++) { uint teamID = keyArray[i]; var team = teamInfoDict[teamID]; var applyIDList = team.ApplyIDList; if (!applyIDList.IsNullOrEmpty() && applyIDList.Contains(PlayerDatas.Instance.baseData.PlayerID)) { result.Add(teamID); } } } return result; } //这个队伍是否在申请中 public bool IsRequest(uint teamID) { if (TryGetTeamInfoDict(out var teamInfoDict)) { var keyArray = teamInfoDict.Keys.ToArray(); for (int i = 0; i < keyArray.Length; i++) { uint nowTeamID = keyArray[i]; if (teamID == nowTeamID) { var team = teamInfoDict[teamID]; var applyIDList = team.ApplyIDList; if (!applyIDList.IsNullOrEmpty() && applyIDList.Contains(PlayerDatas.Instance.baseData.PlayerID)) { return true; } } } } return false; } // 发送B920 创建功能队伍包 public void SendCreateFuncTeam(uint funcMapID, uint funcMapEx, string teamName, ushort minLV, uint minFightPower, uint minFightPowerEx, byte serverOnly, byte needCheck) { var pack = new CB920_tagCGCreateFuncTeam(); pack.FuncMapID = funcMapID; pack.FuncMapEx = funcMapEx; pack.TeamName = teamName; pack.NameLen = (byte)teamName.Length; pack.MinLV = minLV; pack.MinFightPower = minFightPower; pack.MinFightPowerEx = minFightPowerEx; pack.ServerOnly = serverOnly; pack.NeedCheck = needCheck; GameNetSystem.Instance.SendInfo(pack); } // 发送B921 修改功能队伍包 public void SendChangeFuncTeam(uint teamID, uint funcMapID, ushort minLV, uint minFightPower, uint minFightPowerEx, byte serverOnly, byte needCheck) { var pack = new CB921_tagCGChangeFuncTeam(); pack.TeamID = teamID; pack.FuncMapID = funcMapID; pack.MinLV = minLV; pack.MinFightPower = minFightPower; pack.MinFightPowerEx = minFightPowerEx; pack.ServerOnly = serverOnly; pack.NeedCheck = needCheck; GameNetSystem.Instance.SendInfo(pack); } // 发送B922 功能队伍成员操作 public void SendFuncTeamMemOP(uint teamID, uint funcMapID, byte oPType, uint oPData = 0) { var pack = new CB922_tagCGFuncTeamMemOP(); pack.TeamID = teamID; pack.FuncMapID = funcMapID; pack.OPType = oPType; pack.OPData = oPData; GameNetSystem.Instance.SendInfo(pack); } // 发送B923 查找功能队伍列表 public void SendQueryFuncTeam(uint funcMapID, uint funcMapEx, uint startIndex, byte queryCnt, byte haveSpace, byte iDLimitType, string searchMsg = "") { var pack = new CB923_tagCGQueryFuncTeam(); pack.FuncMapID = funcMapID; pack.FuncMapEx = funcMapEx; pack.StartIndex = startIndex; pack.QueryCnt = queryCnt; pack.HaveSpace = haveSpace; pack.IDLimitType = iDLimitType; pack.SearchMsg = searchMsg; pack.SearchLen = (byte)searchMsg.Length; GameNetSystem.Instance.SendInfo(pack); } // 发送B924 查找玩家功能队伍 public void SendQueryPlayerFuncTeam(uint funcMapID) { var pack = new CB924_tagCGQueryPlayerFuncTeam(); pack.FuncMapID = funcMapID; GameNetSystem.Instance.SendInfo(pack); } public void UpdateFuncTeamRefreshInfo(HB920_tagGCFuncTeamRefresh pack) { uint index = pack.FuncMapID * 1000 + pack.FuncMapEx; if (!assortTeamInfoDict.TryGetValue(index, out var assortTeamInfo)) { assortTeamInfo = new Dictionary(); assortTeamInfoDict[index] = assortTeamInfo; } if (!assortTeamInfo.TryGetValue(pack.TeamID, out var teamInfo)) { teamInfo = new AssortTeamInfo(); assortTeamInfo[pack.TeamID] = teamInfo; } // 更新队伍基本信息 teamInfo.TeamID = pack.TeamID; teamInfo.CreateTime = pack.CreateTime; teamInfo.FuncMapID = pack.FuncMapID; teamInfo.FuncMapEx = pack.FuncMapEx; teamInfo.TeamName = pack.TeamName; teamInfo.CaptainID = pack.CaptainID; teamInfo.MinLV = pack.MinLV; teamInfo.MinFightPower = ((ulong)pack.MinFightPowerEx * 100000000) + pack.MinFightPower; teamInfo.ServerOnly = pack.ServerOnly; teamInfo.NeedCheck = pack.NeedCheck; teamInfo.Value1 = pack.Value1; teamInfo.Value2 = pack.Value2; // 更新成员信息 if (teamInfo.MemberDict == null) { teamInfo.MemberDict = new Dictionary(); } else { teamInfo.MemberDict.Clear(); } for (int i = 0; i < pack.MemberList.Length; i++) { var member = pack.MemberList[i]; AssortMemberInfo memberInfo = new AssortMemberInfo { ServerID = member.ServerID, PlayerID = member.PlayerID, Name = member.Name, LV = member.LV, Job = member.Job, Face = member.Face, FacePic = member.FacePic, RealmLV = member.RealmLV, FightPower = ((ulong)member.FightPowerEx * 100000000) + member.FightPower, OfflineValue = member.OfflineValue, Value1 = member.Value1, Value2 = member.Value2, }; teamInfo.MemberDict[member.PlayerID] = memberInfo; UpdateUpdatePlayerOnlineStateInfoDict(member.PlayerID, member.OfflineValue); } // 更新申请者信息 if (teamInfo.ApplyIDList == null) { teamInfo.ApplyIDList = new List(); } else { teamInfo.ApplyIDList.Clear(); } for (int i = 0; i < pack.ApplyIDList.Length; i++) { teamInfo.ApplyIDList.Add(pack.ApplyIDList[i]); } if (teamInfo.ApplicantDict == null) { teamInfo.ApplicantDict = new Dictionary(); } else { teamInfo.ApplicantDict.Clear(); } for (int i = 0; i < pack.ApplyInfoList.Length; i++) { var apply = pack.ApplyInfoList[i]; AssortMemberInfo applyInfo = new AssortMemberInfo { ServerID = apply.ServerID, PlayerID = apply.PlayerID, Name = apply.Name, LV = apply.LV, Job = apply.Job, Face = apply.Face, FacePic = apply.FacePic, RealmLV = apply.RealmLV, FightPower = ((ulong)apply.FightPowerEx * 100000000) + apply.FightPower, }; teamInfo.ApplicantDict[apply.PlayerID] = applyInfo; } // 触发更新事件 UpdateTeamInfoEvent?.Invoke(); UpdateRedPoint(); } public void UpdateQueryPlayerFuncTeamRetInfo(HB921_tagGCQueryPlayerFuncTeamRet pack) { //public uint FuncMapID; // 功能地图ID或自定义的活动功能ID //public uint TeamID; // 玩家所属队伍ID,目前只同步0的情况,如果玩家有队伍统一B920封包同步处理 if (FuncMapID == pack.FuncMapID && pack.TeamID == 0) { UpdateQueryPlayerFuncTeamRetInfoEvent?.Invoke(); } UpdateRedPoint(); } public void UpdateFindFuncTeamListInfo(HB922_tagGCFuncTeamList pack) { this.StartIndex = pack.StartIndex; this.QueryCnt = pack.QueryCnt; this.SearchLen = pack.SearchLen; this.SearchMsg = pack.SearchMsg; this.LoopIndex = pack.LoopIndex; this.TeamCount = pack.TeamCount; uint index = pack.FuncMapID * 1000 + pack.FuncMapEx; uint type = (uint)pack.HaveSpace * 1000 + pack.IDLimitType; if (!assortTeamInfoDict.TryGetValue(index, out var assortTeamInfo)) { assortTeamInfo = new Dictionary(); assortTeamInfoDict[index] = assortTeamInfo; } if (!assortFindTypeTeamIdDict.TryGetValue(index, out var teamIdListDict)) { teamIdListDict = new Dictionary>(); assortFindTypeTeamIdDict[index] = teamIdListDict; } if (!teamIdListDict.TryGetValue(type, out var teamIdList)) { teamIdList = new List(); teamIdListDict[type] = teamIdList; } if (pack.StartIndex == 0) { teamIdList.Clear(); } for (int i = 0; i < pack.TeamList.Length; i++) { var key = pack.TeamList[i]; uint teamID = key.TeamID; if (!assortTeamInfo.TryGetValue(teamID, out var teamInfo)) { teamInfo = new AssortTeamInfo(); assortTeamInfo[teamID] = teamInfo; } if (!teamIdList.Contains(teamID)) { teamIdList.Add(teamID); } // 更新 teamInfo 的内容 teamInfo.CreateTime = key.CreateTime; teamInfo.FuncMapEx = key.FuncMapEx; teamInfo.TeamName = key.TeamName; teamInfo.CaptainID = key.CaptainID; teamInfo.MinLV = key.MinLV; teamInfo.MinFightPower = ((ulong)key.MinFightPowerEx * 100000000) + key.MinFightPower; teamInfo.ServerOnly = key.ServerOnly; teamInfo.NeedCheck = key.NeedCheck; teamInfo.Value1 = key.Value1; teamInfo.Value2 = key.Value2; // 更新 ApplyIDList if (teamInfo.ApplyIDList == null) { teamInfo.ApplyIDList = new List(); } else { teamInfo.ApplyIDList.Clear(); } for (int j = 0; j < key.ApplyIDList.Length; j++) { var applyID = key.ApplyIDList[j]; teamInfo.ApplyIDList.Add(applyID); } // 更新 MemberDict if (teamInfo.MemberDict == null) { teamInfo.MemberDict = new Dictionary(); } else { teamInfo.MemberDict.Clear(); } for (int j = 0; j < key.MemberList.Length; j++) { var member = key.MemberList[j]; AssortMemberInfo memberInfo = new AssortMemberInfo(); memberInfo.ServerID = member.ServerID; memberInfo.PlayerID = member.PlayerID; memberInfo.Name = member.Name; memberInfo.LV = member.LV; memberInfo.Job = member.Job; memberInfo.Face = member.Face; memberInfo.FacePic = member.FacePic; memberInfo.RealmLV = member.RealmLV; memberInfo.FightPower = ((ulong)member.FightPowerEx * Constants.ExpPointValue) + member.FightPower; memberInfo.Value1 = member.Value1; memberInfo.Value2 = member.Value2; teamInfo.MemberDict[member.PlayerID] = memberInfo; } } // 触发更新事件 if (StartIndex == 0) { UpdateFindInfoEvent?.Invoke(); } else { AddScrollerEvent?.Invoke(); } } public void UpdateFuncTeamDissolveInfo(HB923_tagGCFuncTeamDissolve pack) { bool isHaveTeam = TryGetPlayerTeamInfo(out bool isCaptain, out uint nowTeamID, out AssortTeamInfo teamInfo); if (isHaveTeam && isCaptain) { isAutoJoin = false; nowPowerNum = 0; SavePowerNum(); LocalSave.SetBool(StringUtility.Contact("gszczd_toggle1_", PlayerDatas.Instance.baseData.PlayerID), isAutoJoin); } uint teamID = pack.TeamID; if (TryGetTeamTypeDict(out Dictionary> teamTypeDict)) { var list = teamTypeDict.Keys.ToList(); for (int i = 0; i < list.Count; i++) { uint type = list[i]; var typeList = teamTypeDict[type]; if (typeList.Contains(teamID)) { typeList.Remove(teamID); } } } if (TryGetTeamInfoDict(out var teamInfoDict) && teamInfoDict.ContainsKey(teamID)) { teamInfoDict.Remove(teamID); } UpdateTeamDissolveEvent?.Invoke(); UpdateRedPoint(); } void DailyQuestProgressUpdateEvent(int obj) { UpdateRedPoint(); } void OnSelectUpdate() { UpdateRedPoint(); } void UpdatePlayerBillboardEvent(int obj) { UpdateRedPoint(); } public void UpdateRedPoint() { entranceRedPoint.state = RedPointState.None; manageRedPoint.state = RedPointState.None; if (TimeUtility.OpenDay < GeneralDefine.crossServerBattleFieldOpenDay) { return; } bool isHaveTeam = TryGetPlayerTeamInfo(out bool isCaptain, out uint teamID, out AssortTeamInfo teamInfo); //活动处于开启状况 if (IsOpenAction()) return; //玩家有队伍 if (isHaveTeam) { //玩家是队长 且 申请列表中有成员 if (isCaptain && teamInfo.ApplicantDict.Count > 0) { manageRedPoint.state = RedPointState.Simple; } } //玩家没队伍 else { if (isDisplayRedPoint) { entranceRedPoint.state = RedPointState.Simple; } } } public int GetWorldChannelCoolDownEndTime() { if (lastWorldChannelTime == 0) return 0; var overTime = TimeUtility.GetTime((uint)(lastWorldChannelTime + worldChannelTimeCD)); if (TimeUtility.ServerNow > overTime) return 0; return (int)(overTime - TimeUtility.ServerNow).TotalSeconds; } public int GetCrossServiceChannelCoolDownEndTime() { if (lastCrossServiceChannelTime == 0) return 0; var overTime = TimeUtility.GetTime((uint)(lastCrossServiceChannelTime + crossServiceChannelTimeCD)); if (TimeUtility.ServerNow > overTime) return 0; return (int)(overTime - TimeUtility.ServerNow).TotalSeconds; } public void SetWorldChannelTime() { lastWorldChannelTime = TimeUtility.AllSeconds; } public void SetCrossServiceChannelTime() { lastCrossServiceChannelTime = TimeUtility.AllSeconds; } public void SaveAllTime() { int[] arr = new int[2]; arr[0] = lastWorldChannelTime; arr[1] = lastCrossServiceChannelTime; LocalSave.SetIntArray(StringUtility.Contact("gszczd_", PlayerDatas.Instance.baseData.PlayerID), arr); } public void LoadAllTime() { int[] arr = LocalSave.GetIntArray(StringUtility.Contact("gszczd_", PlayerDatas.Instance.baseData.PlayerID)); if (arr != null && arr.Length == 2) { lastWorldChannelTime = arr[0]; lastCrossServiceChannelTime = arr[1]; } else { lastWorldChannelTime = 0; lastCrossServiceChannelTime = 0; } } public void SavePowerNum() { int[] arr = new int[2]; arr[0] = (int)(nowPowerNum / 100000000); arr[1] = (int)(nowPowerNum % 100000000); LocalSave.SetIntArray(StringUtility.Contact("gszczd_powernum", PlayerDatas.Instance.baseData.PlayerID), arr); } public void LoadPowerNum() { int[] arr = LocalSave.GetIntArray(StringUtility.Contact("gszczd_powernum", PlayerDatas.Instance.baseData.PlayerID)); if (arr != null && arr.Length == 2) { nowPowerNum = (long)arr[0] * 100000000 + (long)arr[1]; } else { nowPowerNum = 0; } } public bool IsNoTeamName() { return FunctionTeamSetConfig.Get((int)FuncMapID).NeedName == 0; } public bool IsOpenAction() { if (FunctionTeamSetConfig.Get((int)FuncMapID).OPLimitInAct == 0) { return false; } int index = Math.Max(ILCrossServerModel.Instance.selectIndex, 0); var int3Config = ILCrossServerModel.Instance.crossBattleFieldOpenTimes[index]; var state = ILCrossServerModel.Instance.GetActionState(index); if (state == 1) return true; return false; } public void UpdatePlayerOnlineStateInfo(HB315_tagGCRelatedPlayerOnlineState vNetData) { UpdateUpdatePlayerOnlineStateInfoDict(vNetData.PlayerID, vNetData.OfflineValue, vNetData.IsCross); } void UpdateUpdatePlayerOnlineStateInfoDict(uint playerId, uint offlineValue = 1, byte isCross = 0) { if (!playerOnlineStateInfoDict.TryGetValue(playerId, out var playerOnlineStateInfo)) { playerOnlineStateInfo = new PlayerOnlineStateInfo(); playerOnlineStateInfoDict[playerId] = playerOnlineStateInfo; } playerOnlineStateInfo.IsOnline = offlineValue == 0; playerOnlineStateInfo.IsCross = isCross == 1; playerOnlineStateInfo.OfflineValue = offlineValue >= 1 ? offlineValue : 0; UpdatePlayerOnlineStateInfoEvent?.Invoke(); } public bool IsPlayerOnline(uint playerId) { //没有这个玩家的信息默认视为离线 if (!playerOnlineStateInfoDict.TryGetValue(playerId, out var playerOnlineStateInfo)) return false; return playerOnlineStateInfo.IsOnline; } } public class AssortTeamInfo { public uint TeamID; public uint CreateTime; //创建队伍时间戳 public uint FuncMapID; // 功能地图ID或自定义的活动功能ID public uint FuncMapEx; // 功能地图扩展,如不同的层级 public string TeamName; // 队伍名称 public uint CaptainID; //队长ID,队伍ServerID直接取队长的ServerID public ushort MinLV; //最低等级限制 public ulong MinFightPower; //最低战力限制 public byte ServerOnly; //是否仅本服玩家可加入,0-否,1-是 public byte NeedCheck; //是否需要审核 public uint Value1; //值1 public uint Value2; //值2 public Dictionary MemberDict = new Dictionary(); //成员详细信息 public List ApplyIDList = new List(); //申请者PlayerID public Dictionary ApplicantDict = new Dictionary(); //申请者详细信息 } public class AssortMemberInfo { public uint ServerID; public uint PlayerID; public string Name; public ushort LV; public byte Job; public uint Face; //基本脸型 public uint FacePic; //头像框 public ushort RealmLV; public ulong FightPower; public uint OfflineValue; public uint Value1; public uint Value2; } public class PlayerOnlineStateInfo { public bool IsOnline; // 是否在线 public bool IsCross; // 是否跨服同步的,如果是跨服则离线时间计算时要取跨服服务器时间 public uint OfflineValue; // 上次离线时间戳 }