예제 #1
0
    void FixedUpdate()
    {
        if (!m_UseMatchmaking)
        {
            return;
        }

        if (m_Matchmaker == null)
        {
            MatchmakingServer = MatchmakingServer.Trim();

            m_Matchmaker = new Matchmaker(MatchmakingServer, OnMatchmakingSuccess, OnMatchmakingError);

            var matchId     = Guid.NewGuid().ToString();
            var playerProps = new MatchmakingUtilities.PlayerProperties()
            {
                hats = 5
            };
            var groupProps = new MatchmakingUtilities.GroupProperties()
            {
                mode = 0
            };
            var request = MatchmakingUtilities.CreateMatchmakingRequest(matchId, playerProps, groupProps);

            m_Matchmaker.RequestMatch(request);
        }
        else
        {
            m_Matchmaker.Update();
        }
    }
        // Initialize a new matchmaking request and set UI state to Matchmaking In Progress
        // Precondition: MatchmakingServer is not null and contains a valid matchmaking URI
        void StartNewMatchmakingRequest()
        {
            // Abort existing matchmaker
            if (m_Matchmaker != null)
            {
                EndMatchmaking();
            }

            m_LastMatchmakingState = default(Matchmaker.MatchmakingState);

            MatchmakingServer = MatchmakingServer.Trim();

            m_Matchmaker = new Matchmaker(MatchmakingServer, OnMatchmakingSuccess, OnMatchmakingError);

            var matchId     = Guid.NewGuid().ToString();
            var playerProps = new MatchmakingUtilities.PlayerProperties {
                hats = 5
            };
            var groupProps = new MatchmakingUtilities.GroupProperties {
                mode = 0
            };
            var request = MatchmakingUtilities.CreateMatchmakingRequest(matchId, playerProps, groupProps);

            m_Matchmaker.RequestMatch(request);
            m_LastMatchmakingState = m_Matchmaker.State;
        }