Пример #1
0
        void CreateTicket()
        {
            var matchingplayer = new MatchmakingPlayer {
                Entity = new PlayFab.MultiplayerModels.EntityKey {
                    Id   = PlayFabSettings.staticPlayer.EntityId,
                    Type = PlayFabSettings.staticPlayer.EntityType,
                },
                Attributes = new MatchmakingPlayerAttributes {
                    DataObject = new { },
                }
            };

            PlayFabMultiplayerAPI.CreateMatchmakingTicket(
                new CreateMatchmakingTicketRequest {
                Creator            = matchingplayer,
                GiveUpAfterSeconds = 12,     // 最大600秒
                QueueName          = QUEUE_NAME,
            },
                result => {
                StartCoroutine(Polling(result.TicketId));
            },
                error => {
                Debug.LogError(error.GenerateErrorReport());
            }
                );
        }
Пример #2
0
    /// <summary>
    /// Generate a Match Request object using pre-serialized player and group properties.  Does not check for valid JSON.
    /// </summary>
    /// <param name="playerId">Unique ID of the player</param>
    /// <param name="serializedPlayerProps">Pre-serialized player properties</param>
    /// <param name="serializedGroupProps">Pre-serialized group properties</param>
    /// <returns>A properly-formed matchmaking request object that can be used in calls to the matchmaking API</returns>
    public static MatchmakingRequest CreateMatchmakingRequest(string playerId, string serializedPlayerProps, string serializedGroupProps)
    {
        if (string.IsNullOrEmpty(playerId))
        {
            throw new ArgumentException($"{nameof(playerId)} must be a non-null, non-0-length string", nameof(playerId));
        }

        if (string.IsNullOrEmpty(serializedPlayerProps))
        {
            throw new ArgumentException($"{nameof(serializedPlayerProps)} must be a non-null, non-0-length string", nameof(serializedPlayerProps));
        }

        if (string.IsNullOrEmpty(serializedGroupProps))
        {
            throw new ArgumentException($"{nameof(serializedGroupProps)} must be a non-null, non-0-length string", nameof(serializedGroupProps));
        }

        var thisPlayer = new MatchmakingPlayer(playerId, serializedPlayerProps);
        var players    = new List <MatchmakingPlayer>()
        {
            thisPlayer
        };
        var request = new MatchmakingRequest(players, serializedGroupProps);

        return(request);
    }
 public static void FillMatchmakingProfiles()
 {
     for (int index = 0; index < 8; ++index)
     {
         if (Level.current is TeamSelect2)
         {
             (Level.current as TeamSelect2).ClearTeam(index);
         }
     }
     UIMatchmakingBox.matchmakingProfiles.Clear();
     foreach (Profile profile in Profiles.active)
     {
         profile.team = Teams.all[Persona.Number(profile.persona)];
         MatchmakingPlayer matchmakingPlayer = new MatchmakingPlayer()
         {
             duckIndex = (byte)Persona.Number(profile.persona), inputProfile = profile.inputProfile, team = profile.team
         };
         matchmakingPlayer.customData = (byte[])null;
         UIMatchmakingBox.matchmakingProfiles.Add(matchmakingPlayer);
     }
 }