Beispiel #1
0
 //查看排队,组队Log
 public void PushMatchingLog()
 {
     QueueManager.PushLog();
     QueueSceneManager.PushLog();
     QueueTeamManager.PushLog();
     TeamManager.PushLog();
 }
Beispiel #2
0
 //移除玩家从队伍
 public void RemoveCharacter(QueueTeam _this, ulong cId)
 {
     _this.TeamList.Remove(cId);
     QueueTeamManager.RemoveCharacter(cId);
     if (_this.TeamList.Count == 0)
     {
         QueueTeamManager.RemoveTeam(_this.TeamId);
     }
 }
        //某个场景要结束了
        private void CleanScene(FightQueueScene scene)
        {
            foreach (var i in scene.team1)
            {
                QueueSceneManager.characters.Remove(i.Key);
                QueueTeamManager.LeaveScene(i.Key);
#if DEBUG
                PlayerLog.WriteLog((int)LogType.BattleLog, "SSCharacterLeaveBattle  CleanScene c={0},s={1}", i.Key,
                                   scene.mSceneGuid);
#endif
            }
            foreach (var i in scene.team2)
            {
                QueueSceneManager.characters.Remove(i.Key);
                QueueTeamManager.LeaveScene(i.Key);
#if DEBUG
                PlayerLog.WriteLog((int)LogType.BattleLog, "SSCharacterLeaveBattle  CleanScene c={0},s={1}", i.Key,
                                   scene.mSceneGuid);
#endif
            }
            foreach (var character in scene.FollowCharacters)
            {
                foreach (var data in character.mDatas)
                {
                    TeamServer.Instance.ServerControl.TeamServerMessage(data.Id, (int)eLeaveMatchingType.SceneOver,
                                                                        string.Empty);
                }
                character.mLogic.PushFront(character);
            }
            scene.FollowCharacters.Clear();
#if DEBUG
            PlayerLog.WriteLog((int)LogType.QueueMessage, "CleanScene(). scene.FollowCharacters.Clear(). scene={0}",
                               scene.mSceneGuid);
#endif
            switch (scene.State)
            {
            case SceneState.Init:
            {
            }
            break;

            case SceneState.Full:
            {
            }
            break;

            case SceneState.NoFull:
            {
            }
            break;
            }
        }
        //有人退出场景了
        public void LeaveScene(FightQueueScene _this, ulong cId, ulong sceneGuid)
        {
            if (sceneGuid != _this.mSceneGuid)
            {
                Logger.Warn("FightMatchingScene LeaveScene scene not same! cId={0},sceneGuid={1},teamGuid ={2}", cId,
                            sceneGuid, _this.mSceneGuid);
                return;
            }
            QueueSceneManager.characters.Remove(cId);
            int state;

            if (_this.team1.TryGetValue(cId, out state))
            {
#if DEBUG
                PlayerLog.WriteLog((int)LogType.QueueMessage, "LeaveScene() team1.Remove id={0}", cId);
#endif
                _this.team1.Remove(cId);
                _this.mStateCount--;
                SetState(_this, SceneState.NoFull);
                var t = QueueTeamManager.GetCharacterTeam(cId);
                if (t != null)
                {
                    t.RemoveCharacter(cId);
                }
            }
            else if (_this.team2.TryGetValue(cId, out state))
            {
#if DEBUG
                PlayerLog.WriteLog((int)LogType.QueueMessage, "LeaveScene() team2.Remove id={0}", cId);
#endif
                _this.team2.Remove(cId);
                _this.mStateCount--;
                SetState(_this, SceneState.NoFull);
                var t = QueueTeamManager.GetCharacterTeam(cId);
                if (t != null)
                {
                    t.RemoveCharacter(cId);
                }
            }
            else
            {
                Logger.Warn("FightMatchingScene LeaveScene cId={0},sceneGuid={1}", cId, sceneGuid);
            }
        }
        //后续排队的人返回结果了
        public void FollowResult(FightQueueScene _this, QueueCharacter c, int result)
        {
            if (!_this.FollowCharacters.Contains(c))
            {
                Logger.Warn("FollowResult error! c={0},r={1}", c.Guid, result);
                return;
            }
            PlayerLog.WriteLog((int)LogType.QueueMessage, "FollowResult(). c={0}, ids={1}, result={2}", c.Guid,
                               c.mDatas.Select(d => d.Id).GetDataString(), result);
            _this.FollowCharacters.Remove(c);
            Stoptrigger(_this);
            if (result == 0)
            {
//拒绝了
                RemoveFollowCharacter(_this, c);
            }
            else
            {
//同意了
                _this.mStateCount += c.mDatas.Count;
                var tbQueue = Table.GetQueue(_this.QueueId);
                if (_this.mStateCount == tbQueue.CountLimit * 2)
                {
                    SetState(_this, SceneState.Full);
                }
                var charList = new List <ulong>();
                foreach (var data in c.mDatas)
                {
                    var id = data.Id;
                    charList.Add(id);
                    var camp = GetCharacterCamp(_this, id);
                    if (camp == -1)
                    {
                        Logger.Error("FollowResult camp error!c={0}", c);
                        return;
                    }
                    //把该玩家的排队队伍整理一下
                    QueueTeamManager.AutoEnterTeam(_this, id, camp);
                    CoroutineFactory.NewCoroutine(NotifyCharacterSceneCamp, _this, id, camp).MoveNext();
                }
                CoroutineFactory.NewCoroutine(NotifyCreateChangeSceneCoroutine, _this, charList, c.mDatas[0].ServerId)
                .MoveNext();
            }
        }
        //开始创建副本
        private static IEnumerator NotifyCreateChangeSceneCoroutine(Coroutine co,
                                                                    FightQueueScene _this,
                                                                    List <ulong> characters,
                                                                    int serverId)
        {
            //排队创建场景时,根据合服ID进行
            var serverLogicId = SceneExtension.GetServerLogicId(serverId);

            PlayerLog.WriteLog((int)LogType.QueueMessage, "NotifyCreateChangeSceneCoroutine  Team={0}",
                               characters.GetDataString());
            var sceneInfo = new ChangeSceneInfo
            {
                SceneId   = -1,
                ServerId  = serverLogicId,
                SceneGuid = _this.mSceneGuid,
                Type      = (int)eScnenChangeType.EnterDungeon
            };

            sceneInfo.Guids.AddRange(characters);
            var msgChgScene = TeamServer.Instance.SceneAgent.SBChangeSceneByTeam(characters[0], sceneInfo);

            yield return(msgChgScene.SendAndWaitUntilDone(co));

            if (msgChgScene.State != MessageState.Reply)
            {
                yield break;
            }
            if (msgChgScene.Response == 0)
            {
                foreach (var characterGuid in characters)
                {
                    PlayerLog.WriteLog((int)LogType.BattleLog, "SSCharacterEnterBattle   Faild   c={0},s={1}",
                                       characterGuid, _this.mSceneGuid);
                    QueueTeamManager.LeaveScene(characterGuid);
                    QueueSceneManager.LeaveScene(characterGuid, _this.mSceneGuid);
                }
            }
        }
Beispiel #7
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);
                        }
                    }
                }
            }
        }