Exemplo n.º 1
0
        /// <summary>
        /// Start Matchmaking
        /// </summary>
        /// <param name="playerId">The id of the player</param>
        /// <param name="playerProps">Custom player properties relevant to the matchmaking function</param>
        /// <param name="groupProps">Custom group properties relevant to the matchmaking function</param>
        public void RequestMatch(string playerId, MatchmakingPlayerProperties playerProps, MatchmakingGroupProperties groupProps)
        {
            request = CreateMatchmakingRequest(playerId, playerProps, groupProps);

            matchmakingController = new MatchmakingController(Endpoint);

            matchmakingController.StartRequestMatch(request, GetAssignment, OnError);
            State = MatchmakingState.Requesting;
            Debug.Log(State);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Generates a matchmaking request from the custom player and group properties provided.
        /// </summary>
        /// <param name="playerId">The id of the player</param>
        /// <param name="playerProps">Custom player properties relevant to the matchmaking function</param>
        /// <param name="groupProps">Custom group properties relevant to the matchmaking function</param>
        /// <returns></returns>
        public static MatchmakingRequest CreateMatchmakingRequest(string playerId, MatchmakingPlayerProperties playerProps, MatchmakingGroupProperties groupProps)
        {
            MatchmakingRequest request    = new MatchmakingRequest();
            MatchmakingPlayer  thisPlayer = new MatchmakingPlayer(playerId);

            thisPlayer.Properties = JsonUtility.ToJson(playerProps);

            request.Players.Add(thisPlayer);
            request.Properties = JsonUtility.ToJson(groupProps);

            return(request);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Generates a matchmaking request from the custom player and group properties provided.
        /// </summary>
        /// <param name="playerId">The id of the player</param>
        /// <param name="playerProps">Custom player properties relevant to the matchmaking function</param>
        /// <param name="groupProps">Custom group properties relevant to the matchmaking function</param>
        /// <returns></returns>
        private static MatchmakingRequest CreateMatchmakingRequest(string playerId, MatchmakingPlayerProperties playerProps, MatchmakingGroupProperties groupProps)
        {
            // TODO: WORKAROUND: Currently matchmaker handles IDs as UUIDs, not player names, and will only ever generate 1 match assignment for each UUID
            //   Therefore, we'll append the current time in Ticks as an attempt at creating a UUID
            playerId = playerId + DateTime.UtcNow.Ticks.ToString();

            MatchmakingPlayer thisPlayer = new MatchmakingPlayer(playerId)
            {
                Properties = JsonUtility.ToJson(playerProps)
            };

            MatchmakingRequest request = new MatchmakingRequest()
            {
                Properties = JsonUtility.ToJson(groupProps)
            };


            request.Players.Add(thisPlayer);

            return(request);
        }