public void CancelHosting()
    {
        if (hosting)
        {
            MatchmakingRequest matchmakingRequest = new MatchmakingRequest();
            matchmakingRequest.SetMatchShortCode("HostedMatch");

            GameSparks.Core.GSRequestData participantData = new GameSparks.Core.GSRequestData();
            participantData.AddString("displayName", gameSparksUserID.myDisplayName);
            participantData.AddBoolean("hosting", true);
            matchmakingRequest.SetParticipantData(participantData);
            matchmakingRequest.SetMatchData(participantData);
            matchmakingRequest.SetSkill(0);
            // Cancel host
            hosting = false;
            matchmakingRequest.SetAction("cancel");
            matchmakingRequest.Send(OnMatchmakingSuccess, OnMatchmakingError);
            // Change button text to represent hosting a game
            var buttonText = hostGameButton.GetComponentsInChildren <TMPro.TextMeshProUGUI>();
            buttonText[0].text          = "Host Game";
            joinGameButton.interactable = true;
            onRefreshGamesButtonClick();
            UnblockMatchmakingButton();
        }
    }
Exemple #2
0
    internal void FindPlayers(Action callback)
    {
        MatchFoundCallback = callback;

        GameSparks.Api.Messages.MatchFoundMessage.Listener += (resp) =>
        {
            OnMatchFound(resp);
        };

        MatchmakingRequest request = new MatchmakingRequest();

        request.SetSkill(0);
        request.SetMatchShortCode("SLIME_1V1");

        request.Send(
            (resp) =>
        {
            Debug.Log(resp.JSONString);
        },
            (resp) =>
        {
            Debug.LogError(resp.JSONString);
        }
            );
    }
    private void onRefreshGamesButtonClick()
    {
        BlockRefreshInput();
        // Make sure the user isn't currently hosting that way the refresh doesn't remove their hosted lobby/game
        if (!hosting)
        {
            GameSparksUserID gameSparksUserIDScript = GameObject.Find("GameSparksUserID").GetComponent <GameSparksUserID>();
            // Do a matchmaking request
            MatchmakingRequest matchmakingRequest = new MatchmakingRequest();
            matchmakingRequest.SetMatchShortCode("HostedMatch");

            GameSparks.Core.GSRequestData participantData = new GameSparks.Core.GSRequestData();
            participantData.AddString("displayName", gameSparksUserIDScript.myDisplayName);
            participantData.AddBoolean("hosting", false);
            matchmakingRequest.SetParticipantData(participantData);
            matchmakingRequest.SetMatchData(participantData);
            matchmakingRequest.SetSkill(0);
            // Store this request incase we get a throttled message
            lastMatchmakingRequest = matchmakingRequest;

            matchmakingRequest.Send(OnMatchmakingSuccess, OnMatchmakingError);
            FindGameLobbies();
        }
        else
        {
            FindGameLobbies();
        }
    }
 public void onMatchMakingButtonClick()
 {
     BlockMatchInput();
     BlockJoinHostGameButtons();
     if (matching)
     {
         findingMatchText.color = ColorPalette.invisible;
         matchmakingButton.gameObject.GetComponentInChildren <TMPro.TextMeshProUGUI>().text = "Find Match";
         Debug.Log("Making/sending matchmaking request");
         MatchmakingRequest request = new MatchmakingRequest();
         request.SetAction("cancel");
         request.SetMatchShortCode("DefaultMatch");
         request.SetSkill(0);
         request.Send(OnMatchmakingSuccess, OnMatchmakingError);
         matching = false;
         UnblockMatchInput();
         UnblockJoinHostGameButtons();
     }
     else
     {
         findingMatchText.color = ColorPalette.white;
         matchmakingButton.gameObject.GetComponentInChildren <TMPro.TextMeshProUGUI>().text = "Stop";
         Debug.Log("Making/sending matchmaking request");
         MatchmakingRequest request = new MatchmakingRequest();
         request.SetMatchShortCode("DefaultMatch");
         request.SetSkill(0);
         request.Send(OnMatchmakingSuccess, OnMatchmakingError);
         matching = true;
         UnblockMatchInput();
     }
 }
Exemple #5
0
    private void MatchmakingButtonClickedResponder()
    {
        MatchmakingRequest request = new MatchmakingRequest();

        request.SetMatchShortCode("Test_Match");
        request.SetSkill(0);
        request.Send(OnMatchmakingResponseSuccess, OnMatchmakingResponseError);
    }
Exemple #6
0
    public void OnClickFindMatch()
    {
        MatchmakingRequest request = new MatchmakingRequest();

        request.SetMatchShortCode("defMatch");
        request.SetSkill(0);
        request.Send(OnMatchMakingSuccess, OnMatchMakingError);
        BlockInput();
    }
Exemple #7
0
    private void Play()
    {
        BlockInput();
        MatchmakingRequest request = new MatchmakingRequest();

        request.SetMatchShortCode("QUIZ_BATTLE");
        request.SetSkill(1);
        request.Send(OnMatchmakingSuccess, OnMatchmakingError);
        Debug.Log("Match Making Request: " + request.JSONString);
    }
    public void OnHostGameButtonClick()
    {
        BlockMatchmakingButton();
        joinGameButton.interactable = false;
        EventSystem.current.SetSelectedGameObject(null);

        gameSparksUserID = GameObject.Find("GameSparksUserID").GetComponent <GameSparksUserID>();

        MatchmakingRequest matchmakingRequest = new MatchmakingRequest();

        matchmakingRequest.SetMatchShortCode("HostedMatch");

        GameSparks.Core.GSRequestData participantData = new GameSparks.Core.GSRequestData();
        participantData.AddString("displayName", gameSparksUserID.myDisplayName);
        participantData.AddBoolean("hosting", true);
        matchmakingRequest.SetParticipantData(participantData);
        matchmakingRequest.SetMatchData(participantData);
        matchmakingRequest.SetSkill(0);


        if (!hosting)
        {
            hosting = true;
            // Change button text to represent canceling host
            var buttonText = hostGameButton.GetComponentsInChildren <TMPro.TextMeshProUGUI>();
            buttonText[0].text = "Cancel Host";
        }
        else
        {
            // Cancel host
            hosting = false;
            matchmakingRequest.SetAction("cancel");
            matchmakingRequest.Send(OnMatchmakingSuccess, OnMatchmakingError);
            // Change button text to represent hosting a game
            var buttonText = hostGameButton.GetComponentsInChildren <TMPro.TextMeshProUGUI>();
            buttonText[0].text          = "Host Game";
            joinGameButton.interactable = true;
            onRefreshGamesButtonClick();
            UnblockMatchmakingButton();
        }

        matchmakingRequest.Send(OnMatchmakingSuccess, OnMatchmakingError);
    }
Exemple #9
0
    private void FindPlayers()
    {
        var request = new MatchmakingRequest();

        request.SetMatchShortCode("test_match");
        request.SetSkill(0);

        request.Send(r =>
        {
            if (r.HasErrors)
            {
                Debug.LogError("GSM | MatchMaking Error" + r.Errors.JSON);
            }
        });
    }
Exemple #10
0
        /**
         * Submit a Matchmaking Request
         */
        private static void MatchmakingRequest(int skill, string matchShortcode)
        {
            var req = new MatchmakingRequest();

            req.SetSkill(skill);
            req.SetMatchShortCode(matchShortcode);
            req.Send(r =>
            {
                if (r.HasErrors)
                {
                    Console.WriteLine("MatchmakingError: {0}", r.JSONString);
                }
                else
                {
                    Console.WriteLine("MatchmakingRequest Successful");
                }
            });
        }
Exemple #11
0
    public IEnumerator onMatchMakingButtonClick()
    {
        BlockInput();
        Debug.Log("Making/sending matchmaking request");

        string matchGroupNumber = "";

        yield return(GetMatchmakingGroupNumber(matchGroupNumber));

        MatchmakingRequest request = new MatchmakingRequest();

        request.SetMatchShortCode("DefaultMatch");
        request.SetSkill(0);
        request.SetMatchGroup(matchGroupNumber);
        // Store last request incase we get a throttled response
        lastMatchmakingRequest = request;

        request.Send(OnMatchmakingSuccess, OnMatchmakingError);
    }
Exemple #12
0
    private void MatchMaking(bool cancel = false)
    {
        var matchRequest = new MatchmakingRequest().SetMatchShortCode("matchRanked");

        if (cancel)
        {
            matchRequest
            .SetSkill(Skill)
            .SetMatchGroup("group1");
        }
        else
        {
            matchRequest.SetAction("cancel");
        }

        matchRequest.Send((response) => {
            GSData scriptData = response.ScriptData;
        });
    }
    public void CheckHosting()
    {
        if (hosting)
        {
            MatchmakingRequest matchmakingRequest = new MatchmakingRequest();
            matchmakingRequest.SetMatchShortCode("HostedMatch");

            GameSparks.Core.GSRequestData participantData = new GameSparks.Core.GSRequestData();
            participantData.AddString("displayName", gameSparksUserID.myDisplayName);
            participantData.AddBoolean("hosting", true);
            matchmakingRequest.SetParticipantData(participantData);
            matchmakingRequest.SetMatchData(participantData);
            matchmakingRequest.SetSkill(0);
            // Store this request incase we get a throttled message
            lastMatchmakingRequest = matchmakingRequest;

            matchmakingRequest.Send(OnMatchmakingSuccess, OnMatchmakingError);
            FindGameLobbies();
        }
        hostingCheckTimer.ResetTimer();
        hostingCheckTimer.StartCountdown();
    }