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(); } }
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(); } }
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 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); }