Esempio n. 1
0
        /// <summary>
        /// 队伍销毁 回调
        /// </summary>
        /// <param name="data"></param>
        private void OnTeamDestroy(CopyTeamDestroyData data)
        {
            if (data == null)
            {
                return;
            }

            lock (Mutex)
            {
                CopyTeamData td = null;
                if (!TeamDict.TryGetValue(data.TeamId, out td))
                {
                    return;
                }

                TeamDict.Remove(data.TeamId);
                FuBenSeq2TeamId.Remove(td.FuBenSeqID);
                HashSet <long> teamList = null;
                if (FuBenId2Teams.TryGetValue(td.FuBenId, out teamList))
                {
                    teamList.Remove(td.TeamID);
                }

                foreach (var member in td.TeamRoles)
                {
                    RoleId2JoinedTeam.Remove(member.RoleID);

                    if (member.ServerId != ThisServerId)
                    {
                        continue;
                    }

                    GameClient client = GameManager.ClientMgr.FindClient(member.RoleID);
                    if (client != null)
                    {
                        NotifyTeamStateChanged(client, (int)CopyTeamErrorCodes.LeaveTeam, member.RoleID, 0);
                    }
                }

                // 队长id设为-1, 通知整个队伍
                td.LeaderRoleID = -1;
                NotifyTeamData(td);

                // 清空队伍,然后通知给所有关注列表的人
                td.TeamRoles.Clear();
                td.MemberCount = td.TeamRoles.Count;
                NotifyTeamListChange(td);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 队伍创建回调
        /// </summary>
        /// <param name="data"></param>
        private void OnTeamCreate(CopyTeamCreateData data)
        {
            if (data == null)
            {
                return;
            }

            bool isKuaFuCopy = IsKuaFuCopy(data.CopyId);

            CopyTeamData td = new CopyTeamData();

            td.TeamID       = data.TeamId;
            td.LeaderRoleID = data.Member.RoleID;
            td.FuBenId      = data.CopyId;
            td.MinZhanLi    = data.MinCombat;
            td.AutoStart    = data.AutoStart > 0;
            td.TeamRoles.Add(data.Member);
            td.TeamRoles[0].IsReady = true;
            td.TeamName             = td.TeamRoles[0].RoleName; //KF
            td.MemberCount          = td.TeamRoles.Count;

            lock (Mutex)
            {
                TeamDict[td.TeamID] = td;

                HashSet <long> teams = null;
                if (FuBenId2Teams.TryGetValue(td.FuBenId, out teams) && !teams.Contains(td.TeamID))
                {
                    teams.Add(td.TeamID);
                }

                if (data.Member.ServerId == ThisServerId)
                {
                    RoleId2JoinedTeam[data.Member.RoleID] = td.TeamID;

                    GameClient client = GameManager.ClientMgr.FindClient(data.Member.RoleID);
                    if (client != null)
                    {
                        NotifyTeamCmd(client, CopyTeamErrorCodes.Success, (int)TeamCmds.Create, td.TeamID, td.TeamName);
                    }
                }

                NotifyTeamData(td);
                NotifyTeamListChange(td);
            }

            /*
             * int roleID = client.ClientData.RoleID;
             * long teamID = FindRoleID2TeamID(roleID);
             * if (teamID > 0)
             * {
             *  QuitFromTeam(client);
             * }
             *
             * teamID = GetNextAutoID();
             * AddRoleID2TeamID(roleID, teamID);
             *
             * CopyTeamData td = new CopyTeamData()
             * {
             *  TeamID = teamID,
             *  LeaderRoleID = roleID,
             *  SceneIndex = copyId,
             *  MinZhanLi = minCombat,
             *  AutoStart = autoStart > 0,
             * };
             *
             * if (null == td.TeamRoles)
             * {
             *  td.TeamRoles = new List<CopyTeamMemberData>();
             * }
             *
             * td.TeamRoles.Add(ClientDataToTeamMemberData(client.ClientData));
             * td.TeamRoles[0].IsReady = true;
             * td.TeamName = td.TeamRoles[0].RoleName;
             * td.MemberCount = td.TeamRoles.Count;
             *
             * //存入组队管理队列
             * AddData(teamID, td);
             *
             * //通知组队数据的指令信息
             * NotifyTeamCmd(client, CopyTeamErrorCodes.Success, (int)TeamCmds.Create, teamID, td.TeamName);
             * NotifyTeamData(td);
             *
             * //添加队伍需要向注册通知的用户发送变化列表
             * NotifyTeamListChange(td);*/
        }