예제 #1
0
        public void CancelFindingMatchFor(PlayerData player)
        {
            QueuedPlayer queuedPlayer = GetQueueEntryFor(player);

            if (queuedPlayer != null)
            {
                queuedPlayer.matchFoundTaskCompletionSource?.SetResult(MatchMakingResult.GetCancelledResult(player));
            }

            RemoveQueueEntry(queuedPlayer);
        }
예제 #2
0
        public async void HandleMatchMakingRequestDataEvent(NetReceivedData receivedData)
        {
            if (receivedData.data is MatchMakingRequest matchMakingRequest)
            {
                receivedData.requestHandled = true;

                PlayerData        playerData = BBServer.Instance.Systems.Database.GetPlayerDataById(matchMakingRequest.playerId);
                MatchMakingResult result     = await FindAMatch(playerData, matchMakingRequest.matchMakingSettings);

                Log.D(result);
                receivedData.SendResponse(result);
            }
        }
예제 #3
0
        private bool TryMatchingWithCurrentQueue(QueuedPlayer newQueueEntry, out MatchMakingResult result)
        {
            QueuedPlayer matchingPlayer = queue.Find(qp => qp.IsValidMatchFor(newQueueEntry));

            if (matchingPlayer != null)
            {
                SetMatchFoundFor(matchingPlayer);

                var battleId = BBServer.Instance.Systems.BattleManager.CreateBattleFor(matchingPlayer.player, newQueueEntry.player, new BattleCreationData());
                result = new MatchMakingResult(newQueueEntry.player, matchingPlayer.player, battleId, MatchMakingResult.Status.MatchFound);

                matchingPlayer.matchFoundTaskCompletionSource.SetResult(result);
                return(true);
            }

            result = null;
            return(false);
        }
예제 #4
0
 private void TimeoutQueuedPlayer(QueuedPlayer queuedPlayer)
 {
     RemoveQueueEntry(queuedPlayer);
     queuedPlayer.matchFoundTaskCompletionSource.SetResult(MatchMakingResult.GetTimeoutResult(queuedPlayer.player));
 }