Ejemplo n.º 1
0
 //查看排队,组队Log
 public void PushMatchingLog()
 {
     QueueManager.PushLog();
     QueueSceneManager.PushLog();
     QueueTeamManager.PushLog();
     TeamManager.PushLog();
 }
Ejemplo n.º 2
0
        public void SetState(FightQueueScene _this, SceneState value)
        {
            switch (value)
            {
            case SceneState.Init:     //初始状态
            {
            }
            break;

            case SceneState.Full:     //已全部进场景状态
            {
                Stoptrigger(_this);
                QueueSceneManager.EnterFull(_this);
            }
            break;

            case SceneState.NoFull:     //缺人状态
            {
                if (_this.mState != SceneState.NoFull)
                {
                    QueueSceneManager.FirstNotFull(_this);
                }
            }
            break;
            }
            _this.mState = value;
        }
Ejemplo n.º 3
0
 //清空排队
 public void CleanMatching(int id)
 {
     if (id == -1)
     {
         QueueSceneManager.ClearScene(id);
     }
     QueueManager.ClearQueue(id);
 }
Ejemplo n.º 4
0
        public void RemoveCharacterOne(FollowQueueResult _this, QueueCharacter character)
        {
            QueueResultBase.GetImpl().RemoveCharacterOne(_this, character);
            var scene = QueueSceneManager.GetCharacterScene(_this.Character.mDatas[0].Id);

            if (scene == null)
            {
                Logger.Error("In AllOK scene == null!!!");
                return;
            }
            scene.RemoveFollowCharacter(character);
        }
Ejemplo n.º 5
0
        public void TimeOver(FollowQueueResult _this)
        {
            var character = _this.Character;
            var scene     = QueueSceneManager.GetCharacterScene(character.mDatas[0].Id);

            if (scene == null)
            {
                return;
            }
            scene.FollowResult(character, 1);
            QueueManager.Pop(character.mDatas[0].Id, eLeaveMatchingType.TimeOut);
        }
Ejemplo n.º 6
0
        public void AllOK(FollowQueueResult _this)
        {
            _this.mQueue.OnAllOk(_this);
            var scene = QueueSceneManager.GetCharacterScene(_this.Character.mDatas[0].Id);

            if (scene == null)
            {
                Logger.Error("In AllOK scene == null!!!");
                return;
            }
            scene.FollowResult(_this.Character, 1);
            QueueManager.Remove(_this.Character.mDatas[0].Id, eLeaveMatchingType.Success);
            _this.Character.result = null;
        }
Ejemplo n.º 7
0
        public ErrorCodes MatchingBack(FollowQueueResult _this, ulong guid, bool agree = false)
        {
            var err = QueueResultBase.GetImpl().MatchingBack(_this, guid, agree);

            if (!agree)
            {
                var scene = QueueSceneManager.GetCharacterScene(guid);
                if (scene == null)
                {
                    return(err);
                }
                scene.FollowResult(_this.Character, 0);
                QueueManager.Pop(guid, eLeaveMatchingType.Refuse);
            }
            return(err);
        }
Ejemplo n.º 8
0
        //开始创建副本
        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);
                }
            }
        }
Ejemplo n.º 9
0
        public void Tick(FightQueue _this)
        {
            var needCount  = _this.tbQueue.CountLimit;
            var needCount1 = _this.tbQueue.CountLimit;
            var needCount2 = _this.tbQueue.CountLimit;

            var noFullSceneList = QueueSceneManager.GetQueueNotFullList(_this.mQueueId);

            foreach (var nofullscene in noFullSceneList)
            {
                needCount1 = needCount - nofullscene.team1.Count;
                needCount2 = needCount - nofullscene.team2.Count;
                if (needCount1 == needCount2)
                {
                    //两边要同时进人
                    if (needCount2 < 1)
                    {
                        continue;
                    }
                    //找人
                    {
                        QueueCharacter gotoTeam1 = null;
                        foreach (var mCharacter in _this.mCharacters)
                        {
                            if (mCharacter.mDatas.Count > needCount1)
                            {
                                continue;
                            }
                            if (gotoTeam1 == null)
                            {
                                gotoTeam1 = mCharacter;
                            }
                            else if (mCharacter.mDatas.Count == gotoTeam1.mDatas.Count)
                            {
                                nofullscene.FollowCharacter(gotoTeam1, 0);
                                nofullscene.FollowCharacter(mCharacter, 1);
                                return;
                            }
                        }
                    }
                }
                else
                {
                    //少的一边先进
                    var diff = Math.Abs(needCount1 - needCount2);
                    foreach (var mCharacter in _this.mCharacters)
                    {
                        if (diff >= mCharacter.mDatas.Count)
                        {
                            if (needCount1 > needCount2)
                            {
                                nofullscene.FollowCharacter(mCharacter, 0);
                                return;
                            }
                            nofullscene.FollowCharacter(mCharacter, 1);
                            return;
                        }
                    }
                }
            }


            needCount1 = needCount;
            needCount2 = needCount;
            _this.tempTeam1.Clear();
            _this.tempTeam2.Clear();
            var isCanOver1 = false;
            var isCanOver2 = false;

            foreach (var mCharacter in _this.mCharacters)
            {
                if (mCharacter.mDatas.Count <= needCount1)
                {
                    _this.tempTeam1.Add(mCharacter);
                    needCount1 -= mCharacter.mDatas.Count;
                    if (needCount1 == 0)
                    {
                        isCanOver1 = true;
                        if (isCanOver2)
                        {
                            break;
                        }
                    }
                }
                else if (mCharacter.mDatas.Count <= needCount2)
                {
                    _this.tempTeam2.Add(mCharacter);
                    needCount2 -= mCharacter.mDatas.Count;
                    if (needCount2 == 0)
                    {
                        isCanOver2 = true;
                        if (isCanOver1)
                        {
                            break;
                        }
                    }
                }
            }
            if (isCanOver1 && isCanOver2)
            {
                _this.MatchOver();
            }

            // 如果已经很长时间没有匹配到人了,把这些人降级
            {
                if (_this.NextQueue != null)
                {
                    List <QueueCharacter> removes = new List <QueueCharacter>();
                    foreach (var character in _this.mCharacters)
                    {
                        if ((DateTime.Now - character.StartTime).Seconds > _this.tbQueue.WaitTime)
                        {
                            removes.Add(character);
                            //_this.Pop内会执行mCharacters.Remove(character),导致移除
                            //character.mLogic = _this.NextQueue;
                            //character.StartTime = DateTime.Now;
                            //_this.Pop(character, eLeaveMatchingType.MoveDown);
                            //_this.NextQueue.PushBack(character);
                        }
                    }
                    foreach (var queueCharacter in removes)
                    {
                        queueCharacter.mLogic    = _this.NextQueue;
                        queueCharacter.StartTime = DateTime.Now;
                        _this.Pop(queueCharacter, eLeaveMatchingType.MoveDown);
                        _this.NextQueue.PushBack(queueCharacter);
                    }
                }
            }
        }
Ejemplo n.º 10
0
        public void EnterFuben(QueueResultBase _this)
        {
            var tbQueue = _this.mQueue.tbQueue;
            var fubenId = tbQueue.Param;
            var tbFuben = Table.GetFuben(fubenId);

            if (tbFuben == null)
            {
                Logger.Error("Not Find FubenID! QueueId = {0} ", tbQueue.Id);
                return;
            }
            if (_this.CharacterState.Count < 1)
            {
                return;
            }
            var tbScene = Table.GetScene(tbFuben.SceneId);

            switch ((eQueueType)tbQueue.AppType)
            {
            case eQueueType.Dungeon:
            {
                var characters = new List <ulong>();
                foreach (var character in _this.CharacterState)
                {
                    characters.Add(character.Key);
                }
                var serverId = tbScene.CanCrossServer == 1 ? -1 : _this.mTeamList[0][0].mDatas[0].ServerId;
                CoroutineFactory.NewCoroutine(Utility.AskEnterDungeonByTeamCoroutine, characters, serverId, tbFuben,
                                              (ulong)0).MoveNext();
                foreach (var matchingCharacter in _this.CharacterState)
                {
                    QueueManager.Pop(matchingCharacter.Key, eLeaveMatchingType.Success);
                }
            }
            break;

            case eQueueType.BattleField:
            {
                if (_this.mTeamList.Count % 2 != 0)
                {
                    Logger.Error("fightQueue mTeamList Count ={0}", _this.mTeamList.Count);
                }
                var index      = 0;
                var characters = new List <ulong>();
                var tempScene  = QueueSceneManager.CreateScene(tbQueue.Id);
                foreach (var list in _this.mTeamList)
                {
                    foreach (var character in list)
                    {
                        foreach (var data in character.mDatas)
                        {
                            characters.Add(data.Id);
                            CoroutineFactory.NewCoroutine(NotifyCharacterSceneCamp, _this, data.Id, index)
                            .MoveNext();
                            tempScene.InitCharacter(data.Id, index);
                        }
                    }
                    if (index == 0)
                    {
                        index = 1;
                    }
                    else
                    {
                        index = 0;
                    }
                }
                var serverId = tbScene.CanCrossServer == 1 ? -1 : _this.mTeamList[0][0].mDatas[0].ServerId;
                CoroutineFactory.NewCoroutine(Utility.AskEnterDungeonByTeamCoroutine, characters, serverId, tbFuben,
                                              (ulong)0).MoveNext();
                foreach (var matchingCharacter in _this.CharacterState)
                {
                    QueueManager.Pop(matchingCharacter.Key, eLeaveMatchingType.Success);
                }
            }
            break;

            case eQueueType.ActivityDungeon:
            {
                var characters = new List <ulong>();
                foreach (var character in _this.CharacterState)
                {
                    characters.Add(character.Key);
                    if (tbFuben.FubenCountNode == (int)eDungeonSettlementNode.Start)
                    {
                        Utility.NotifyEnterFuben(character.Key, fubenId);
                    }
                }
                var serverId = tbScene.CanCrossServer == 1 ? -1 : _this.ServerId;
                CoroutineFactory.NewCoroutine(Utility.AskEnterDungeonByTeamCoroutine, characters, serverId,
                                              tbFuben, (ulong)0).MoveNext();
                foreach (var matchingCharacter in _this.CharacterState)
                {
                    QueueManager.Pop(matchingCharacter.Key, eLeaveMatchingType.Success);
                }
            }
            break;
            }
        }