public void Update(QueueBase _this) { var tick = QueueManager.Tick; if (tick % 2 == 0) { _this.UpdataNoWait(); } if (tick >= 30) { UpdataIndex(_this); } }
private void UpdataIndex(QueueBase _this) { var index = 0; foreach (var connet in _this.WaitPlayerList) { if (index >= 50) { break; } index++; connet.SendClientQueueIndex(index); } }
public PlayerConnect GetFirstWaitPlayer(QueueBase _this) { if (_this.WaitPlayerCount > 0) { var temp = _this.WaitPlayerList.First.Value; _this.WaitPlayerList.RemoveFirst(); if (temp.State == ConnectState.WaitOffLine) { QueueManager.CacheLost.Remove(temp.GetKey()); } else { temp.State = ConnectState.Landing; } return(temp); } return(null); }
public PlayerQueueType PushConnect(QueueBase _this, string type, ulong clientId, string name, PlayerController playerController) { //是否曾经在排队过程中 PlayerConnect findConnect; var key = PlayerConnect.GetLandingKey(type, name); if (QueueManager.CacheLost.TryGetValue(key, out findConnect)) { findConnect.IsOnline = true; QueueManager.CacheLost.Remove(key); findConnect.ClientId = clientId; playerController.Connect = findConnect; switch (findConnect.State) { case ConnectState.Wait: //QueueManager.TotalList.TryAdd(clientId, findConnect); //break; case ConnectState.Landing: case ConnectState.EnterGame: case ConnectState.InGame: Logger.Warn("PushConnect StateERROR clientId={0},name={1},State={2}", clientId, name, findConnect.State); break; case ConnectState.OffLine: { var checkState = _this.CheckQueueState(); QueueManager.TotalList.TryAdd(clientId, findConnect); findConnect.Player = playerController; if (checkState == PlayerQueueType.NoWait) { findConnect.State = ConnectState.Landing; QueueManager.LandingPlayerList.TryAdd(playerController.DbData.Id, findConnect); return(PlayerQueueType.NoWait); } findConnect.State = ConnectState.Wait; _this.WaitPlayerList.AddFirst(findConnect); } break; case ConnectState.WaitOffLine: { var checkState = _this.CheckQueueState(); QueueManager.TotalList.TryAdd(clientId, findConnect); findConnect.Player = playerController; if (checkState == PlayerQueueType.NoWait) { findConnect.State = ConnectState.Landing; QueueManager.LandingPlayerList.TryAdd(playerController.DbData.Id, findConnect); return(PlayerQueueType.NoWait); } findConnect.State = ConnectState.Wait; } break; } return(PlayerQueueType.Wait); } //增加到新的排队 QueueManager.TotalList.TryGetValue(clientId, out findConnect); var check = _this.CheckQueueState(); switch (check) { case PlayerQueueType.NoWait: { if (findConnect == null) { findConnect = new PlayerConnect(type, clientId, name, ConnectState.Landing); QueueManager.TotalList.TryAdd(clientId, findConnect); } playerController.Connect = findConnect; findConnect.Player = playerController; QueueManager.LandingPlayerList.TryAdd(findConnect.Player.DbData.Id, findConnect); } break; case PlayerQueueType.Wait: { if (findConnect == null) { findConnect = new PlayerConnect(type, clientId, name); QueueManager.TotalList.TryAdd(clientId, findConnect); } playerController.Connect = findConnect; findConnect.Player = playerController; _this.WaitPlayerList.AddLast(findConnect); } break; case PlayerQueueType.More: break; default: throw new ArgumentOutOfRangeException(); } return(check); }