public bool JoinPrivateGame(string gameName, string gamePassword) { // Configure request MpRequest.JoinPrivateGame request = new MpRequest.JoinPrivateGame(); request.GameName = gameName; request.GamePassword = gamePassword; // Send request string rawResponse = SendRequest(request); // Check if request failed if (RequestFailed(rawResponse)) { MpResponse.Status statusResponse = JsonUtility.FromJson <MpResponse.Status>(rawResponse); InvalidToken(statusResponse); if (statusResponse.ErrorLevel == "InvalidGameName") { Other.Tools.CreatePopup(Other.Tools.Messages.CouldntFindGame); } if (statusResponse.ErrorLevel == "InvalidPassword") { Other.Tools.CreatePopup(Other.Tools.Messages.InvalidGamePassword); } return(false); } // Handle response Scenes.SetString("GameMode", "Online"); Scenes.SetString("OpponentName", gameName); Scenes.Load("Game"); return(true); }
private void QuickMatchCallback() { string rawResponse = _callbackResponse; // Check if request failed if (RequestFailed(rawResponse)) { MpResponse.Status statusResponse = JsonUtility.FromJson <MpResponse.Status>(rawResponse); InvalidToken(statusResponse); if (statusResponse.ErrorLevel == "AlreadyInQueue") { Other.Tools.CreatePopup(Other.Tools.Messages.AlreadyInQueue); } } else { // Handle request MpResponse.Player playerResponse = JsonUtility.FromJson <MpResponse.Player>(rawResponse); Scenes.SetString("GameMode", "Online"); Scenes.SetString("OpponentName", playerResponse.PlayerName); Scenes.Load("Game"); Other.Tools.CreatePopup(Other.Tools.Messages.SearchingGames); } }