private IEnumerator ConnectMatchLobby(string matchLobbyId, string invitationCode = null) { var matchLobbyHandler = new MatchLobbyHandler(ApplicationModel.CurrentPlayer); yield return(matchLobbyHandler.JoinMatchLobby(matchLobbyId, invitationCode)); var joinResponse = matchLobbyHandler.JoinMatchLobbyResponse; GUIHelper.UpdateGUIMessageWithStatusCode(GameStatusTxt, joinResponse.statusCode); if (joinResponse.statusCode == StatusCode.OK) { ApplicationModel.CurrentMatchLobby = ApplicationModel.CurrentMatchLobbyToJoin; ApplicationModel.NetworkCreatorId = ApplicationModel.CurrentMatchLobby.creatorId; yield return(partyNetworkHandler.JoinNetwork(joinResponse.response.networkId)); } else { if (joinResponse.statusCode == StatusCode.NotInvitationCodeIncluded) { InvitationCodeModal.InvitationCodeModalResult modalResult = null; yield return(AskForInvitationCode((result) => { modalResult = result; })); if (modalResult.OptionSelected == InvitationCodeModal.OptionSelected.OK && !string.IsNullOrWhiteSpace(modalResult.InvitationCode)) { yield return(ConnectMatchLobby(matchLobbyId, modalResult.InvitationCode)); } } } }
private IEnumerator JoinMatchLobby() { ApplicationModel.JoinToMatchLobby = false; var cancel = false; if (ApplicationModel.CurrentMatchLobbyToJoin.locked) { InvitationCodeModal.InvitationCodeModalResult modalResult = null; yield return(AskForInvitationCode((result) => { modalResult = result; })); cancel = modalResult.OptionSelected != InvitationCodeModal.OptionSelected.OK; if (!cancel) { yield return(StartCoroutine(ConnectMatchLobby(ApplicationModel.CurrentMatchLobbyToJoin.matchLobbyId, invitationCodeModal.Result.InvitationCode))); } } else { yield return(StartCoroutine(ConnectMatchLobby(ApplicationModel.CurrentMatchLobbyToJoin.matchLobbyId))); } if (!cancel && ApplicationModel.CurrentMatchLobby != null) { // HACK: set that the lobby players list has changed in order to trigger the players renderization ApplicationModel.CreateRemotePlayersHandler(PlayFabMultiplayerManager.Get()); ApplicationModel.MatchLobbyJoinedPlayerListHasChanged = true; SceneManager.LoadScene("MatchLobby"); } }