示例#1
0
        public void changeTeamTarget(ulong characterId, int type, int targetId, int levelMini, int levelMax, int readTableId)
        {
            var team = TeamManager.GetCharacterTeam(characterId);

            if (null != team)
            {
                TeamManager.mCharacters[characterId].team.type         = (TeamTargetType)type;
                TeamManager.mCharacters[characterId].team.teamTargetID = targetId;
                TeamManager.mCharacters[characterId].team.levelMini    = levelMini;
                TeamManager.mCharacters[characterId].team.levelMax     = levelMax;

                TeamCharacterProxy proxy;
                for (int i = 0; i < TeamManager.mCharacters[characterId].team.TeamList.Count; i++)
                {
                    var temCharacId = TeamManager.mCharacters[characterId].team.TeamList[i];
                    if (TeamServer.Instance.ServerControl.Proxys.TryGetValue(temCharacId, out proxy))
                    {
                        if (null != proxy)
                        {
                            proxy.NotifyChangetTeamTarget(type, targetId, levelMini, levelMax, readTableId);
                        }
                    }
                }
            }
        }
示例#2
0
        //下线通知
        public void OnLost(ulong characterId)
        {
            var character = GetMatchingCharacter(characterId);

            if (character == null)
            {
                return;
            }
            if (character.result == null)
            {
                var characterteam = TeamManager.GetCharacterTeam(characterId);
                if (characterteam == null)
                {
//没有队伍的情况下
                    Pop(characterId, eLeaveMatchingType.Onlost);
                }
            }
            //if (character.team == null)
            //{//还在排队过程中
            //    Character characterteam = TeamManager.GetCharacterTeam(characterId);
            //    if (characterteam == null)
            //    {
            //        //没有队伍的情况下
            //        Pop(characterId, eLeaveMatchingType.Onlost);
            //        return;
            //    }
            //    else
            //    {
            //        //有队伍时,先继续这么排着
            //    }
            //}
            //else
            //{//已经排上队伍了
            //    Character characterteam = TeamManager.GetCharacterTeam(characterId);
            //    if (characterteam == null)
            //    {
            //        //没有队伍的情况下
            //        Pop(characterId, eLeaveMatchingType.Onlost);
            //        return;
            //    }
            //    else
            //    {
            //        //有队伍时,先继续这么排着
            //    }
            //}
        }
示例#3
0
        //上线通知
        public void OnLine(ulong characterId)
        {
            TeamCharacterProxy proxy;

            if (TeamServer.Instance.ServerControl.Proxys.TryGetValue(characterId, out proxy))
            {
                proxy.AutoMatchStateChange(0);
                var team = TeamManager.GetCharacterTeam(characterId);
                if (null != team)
                {
                    proxy.NotifyChangetTeamTarget((int)team.team.type, team.team.teamTargetID, team.team.levelMini, team.team.levelMax, 0);
                }
                else
                {
                    proxy.NotifyChangetTeamTarget(0, 0, 0, 0, 0);
                }
            }
        }
示例#4
0
        public void beginAotuMatch(bool isHaveTeam, ulong characterId, TeamMatchItem item)
        {
            Logger.Info("TeamWorkRefrerrence  beginAotuMatch= " + characterId);

            if (isHaveTeam) // 有队伍开启自动匹配
            {
                List <ulong> oldList = new List <ulong>();
                foreach (var sNull in AutoMatchManager.nullTeamMatchDic)
                {
                    if (sNull.Key != characterId && sNull.Value.teamTarget.type == item.teamTarget.type && sNull.Value.teamTarget.teamTargetID == item.teamTarget.teamTargetID)
                    {
                        //增加到队伍
                        var theTeam = TeamManager.GetCharacterTeam(characterId);

                        oldList.Add(sNull.Key);

                        if (theTeam.team.TeamList.Count == 4)
                        {
                            TeamManager.addOneToTeam(theTeam.team, characterId, TeamState.Member);
                            //TeamChange(TeamChangedType.Request, theTeam, charaID);

                            TeamCharacterProxy proxy;
                            if (TeamServer.Instance.ServerControl.Proxys.TryGetValue(characterId, out proxy))
                            {
                                proxy.AutoMatchStateChange(0);
                            }
                            AutoMatchManager.teamMatchDic.Remove(characterId);
                            break;
                        }

                        TeamManager.addOneToTeam(theTeam.team, sNull.Key, TeamState.Member);
                    }
                }

                for (int r = 0; r < oldList.Count; r++)
                {
                    var sItem = oldList[r];
                    if (AutoMatchManager.nullTeamMatchDic.ContainsKey(sItem))
                    {
                        AutoMatchManager.nullTeamMatchDic.Remove(sItem);
                    }

                    TeamCharacterProxy proxy;
                    if (TeamServer.Instance.ServerControl.Proxys.TryGetValue(sItem, out proxy))
                    {
                        proxy.AutoMatchStateChange(0);
                    }
                }
                oldList.Clear();
            }
            else
            {     // 无队伍开启自动匹配
                bool isGetTeam = false;
                { // 过滤 处于 自动匹配状态的队伍
                    foreach (var sTeam in AutoMatchManager.teamMatchDic)
                    {
                        if (sTeam.Key != characterId)
                        {
                            var theTeam = sTeam.Value.chracter.team;

                            if (null == theTeam || theTeam.TeamList == null || theTeam.TeamList.Count > 4)
                            {
                                continue;
                            }
                            if (theTeam.TeamList.Contains(characterId))
                            {
                                continue;
                            }
                            if (sTeam.Value.teamTarget.teamTargetID != item.teamTarget.teamTargetID || sTeam.Value.teamTarget.type != item.teamTarget.type)
                            {
                                continue;
                            }

                            //AutoMatchManager.teamMatchDic.Remove(sTeam.Key);
                            TeamCharacterProxy proxy;
                            if (TeamServer.Instance.ServerControl.Proxys.TryGetValue(characterId, out proxy))
                            {
                                proxy.AutoMatchStateChange(0);
                            }

                            if (AutoMatchManager.teamMatchDic.ContainsKey(sTeam.Key) && theTeam.TeamList.Count == 4)
                            {
                                TeamCharacterProxy proxy1;
                                if (TeamServer.Instance.ServerControl.Proxys.TryGetValue(sTeam.Key, out proxy1))
                                {
                                    proxy1.AutoMatchStateChange(0);
                                }
                                AutoMatchManager.teamMatchDic.Remove(sTeam.Key);
                            }

                            //增加到队伍
                            TeamManager.addOneToTeam(theTeam, characterId, TeamState.Member);
                            //TeamChange(TeamChangedType.AcceptRequest, theTeam, charaID);
                            isGetTeam = true;
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }

                    // 过滤 没使用自动匹配但是勾选了“自动接收入队申请”的队伍
                    if (!isGetTeam)
                    {
                        if (TeamManager.mTeams.Count > 0)
                        {
                            foreach (var sFlag in AutoMatchManager.teamFlagDic)
                            {
                                if (sFlag.Key != characterId && sFlag.Value == true)
                                {
                                    if (TeamManager.mTeams.ContainsKey(sFlag.Key))
                                    {
                                        var theTeam = TeamManager.mTeams[sFlag.Key];
                                        if (theTeam.teamTargetID != item.teamTarget.teamTargetID || theTeam.type != item.teamTarget.type)
                                        {
                                            continue;
                                        }
                                        //增加到队伍
                                        TeamManager.addOneToTeam(theTeam, characterId, TeamState.Member);

                                        isGetTeam = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    // 当无队伍可加入,且服务器收到的消息均为无队伍自动匹配申请时
                    if (!isGetTeam)
                    {
                        foreach (var sNullItem in AutoMatchManager.nullTeamMatchDic)
                        {
                            if (sNullItem.Key != characterId)
                            {
                                var theTeam = TeamManager.CreateTeam(sNullItem.Key);// 默认队长(即匹配对象时间靠前的为队长)

                                //增加到队伍
                                TeamManager.addOneToTeam(theTeam, characterId, TeamState.Member);
                                //TeamChange(TeamChangedType.AcceptRequest, sTeam, charaID);

                                if (AutoMatchManager.nullTeamMatchDic.ContainsKey(characterId))
                                {
                                    AutoMatchManager.nullTeamMatchDic.Remove(characterId);
                                }
                                AutoMatchManager.nullTeamMatchDic.Remove(sNullItem.Key);

                                TeamCharacterProxy proxy;
                                if (TeamServer.Instance.ServerControl.Proxys.TryGetValue(characterId, out proxy))
                                {
                                    proxy.AutoMatchStateChange(0);
                                }

                                TeamCharacterProxy proxy1;
                                if (TeamServer.Instance.ServerControl.Proxys.TryGetValue(sNullItem.Key, out proxy1))
                                {
                                    proxy1.AutoMatchStateChange(0);
                                }
                                isGetTeam = true;
                                break;
                            }
                        }
                    }
                }
            }
        }
示例#5
0
        //重新组织新队长
        private void ResetNewLeader(QueueResultBase _this)
        {
            foreach (var list in _this.mTeamList)
            {
                //筛选队长
                CharacterSimpleData LeaderCharacter = null;
                var maxCount   = 0;
                var FightPoint = 0;
                foreach (var qCharacters in list)
                {
                    foreach (var matchingCharacter in qCharacters.mDatas)
                    {
                        var character = TeamManager.GetCharacterTeam(matchingCharacter.Id);
                        if (character != null)
                        {
                            if (character.TeamState == TeamState.Leader)
                            {
                                if (character.team.GetTeamCount() > maxCount)
                                {
                                    maxCount        = character.team.GetTeamCount();
                                    LeaderCharacter = matchingCharacter;
                                    FightPoint      = matchingCharacter.FightPoint;
                                }
                                else if (character.team.GetTeamCount() == maxCount)
                                {
                                    if (matchingCharacter.FightPoint > FightPoint)
                                    {
                                        FightPoint      = matchingCharacter.FightPoint;
                                        LeaderCharacter = matchingCharacter;
                                    }
                                }
                                //character.team.Disband();
                            }
                        }
                        else
                        {
                            if (matchingCharacter.FightPoint > FightPoint && LeaderCharacter == null)
                            {
                                FightPoint      = matchingCharacter.FightPoint;
                                LeaderCharacter = matchingCharacter;
                            }
                        }
                    }
                }
                if (LeaderCharacter == null)
                {
                    return;
                }
                //组队
                var tempTeam = QueueTeamManager.CreateTeam(_this.mQueue.mQueueId);
                _this.newTeams.Add(tempTeam);
                tempTeam.PushCharacter(LeaderCharacter.Id);

                foreach (var qCharacters in list)
                {
                    qCharacters.team = tempTeam;
                    foreach (var matchingCharacter in qCharacters.mDatas)
                    {
                        if (LeaderCharacter != matchingCharacter)
                        {
                            tempTeam.PushCharacter(matchingCharacter.Id);
                        }
                    }
                }
            }
        }