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)); } } } }
// Start is called before the first frame update void Start() { SetGameObjectListeners(); if (ApplicationModel.CurrentMatchLobby != null) { MatchLobby = ApplicationModel.CurrentMatchLobby; MatchLobbyTitleTxt.text = $"Match Lobby: { ApplicationModel.CurrentMatchLobby.matchLobbyId }"; } if (ApplicationModel.CurrentPlayer != null) { CurrentPlayer = ApplicationModel.CurrentPlayer; } if (PartyNetworkHandler == null) { PartyNetworkHandler = new PartyNetworkHandler(); SetPartyNetworkHandlerListeners(); } MatchLobbyHandler = new MatchLobbyHandler(ApplicationModel.CurrentPlayer); InitializeScene(); InvitationCodeField.text = string.Empty; }
public IEnumerator DeleteMatchLobby(string matchLobbyId) { var matchLobbyHandler = new MatchLobbyHandler(ApplicationModel.CurrentPlayer); yield return(matchLobbyHandler.DeleteMatchLobby(matchLobbyId)); Debug.Log($"MatchLobby deleted: {matchLobbyId}"); ApplicationModel.CurrentMatchLobby = null; }
private IEnumerator SearchMatchLobby(string filter) { var matchLobbyHandler = new MatchLobbyHandler(ApplicationModel.CurrentPlayer); yield return(matchLobbyHandler.GetMatchLobbyList(filter)); ApplicationModel.MatchLobbyList = matchLobbyHandler.MatchLobbyList; ApplicationModel.MatchLobbyListHasChanged = true; UpdateGameStatus((ApplicationModel.MatchLobbyList?.Count ?? default) + Constants.MATCH_LOBBY_FOUND); }
public IEnumerator DeleteMatchLobbyAndLeaveNetwork(string matchLobbyId) { var matchLobbyHandler = new MatchLobbyHandler(ApplicationModel.CurrentPlayer); yield return(matchLobbyHandler.DeleteMatchLobby(matchLobbyId)); yield return(partyNetworkHandler.LeaveNetwork()); ApplicationModel.CurrentMatchLobby = null; }
private void StartMatch() { if (StartMatchConditionsMet()) { if (ApplicationModel.CurrentMatchLobby != null && ApplicationModel.IsHost) { var matchLobbyHandler = new MatchLobbyHandler(ApplicationModel.CurrentPlayer); StartCoroutine(matchLobbyHandler.DeleteMatchLobby(ApplicationModel.CurrentMatchLobby.matchLobbyId)); } CreateCurrentMatch(); SceneManager.LoadScene("Game"); } }
private IEnumerator CreateGroup(string groupName) { ApplicationModel.ConnectedToLobby = false; var sharedGroupHandler = new SharedGroupHandler(ApplicationModel.CurrentPlayer); yield return(StartCoroutine(sharedGroupHandler.Create(groupName))); if (!string.IsNullOrWhiteSpace(sharedGroupHandler.SharedGroupId)) { var matchLobbyHandler = new MatchLobbyHandler(ApplicationModel.CurrentPlayer); yield return(StartCoroutine(matchLobbyHandler.CreateMatchLobby(sharedGroupHandler.SharedGroupId))); ApplicationModel.CurrentSharedGroupData = matchLobbyHandler.TicTacToeSharedGroupData; ApplicationModel.ConnectedToLobby = ApplicationModel.CurrentMatch.playerOneId == ApplicationModel.CurrentPlayer.PlayFabId; } }
private IEnumerator CreateMatchLobby(string groupName, bool locked) { yield return(StartCoroutine(partyNetworkHandler.CreateAndJoinToNetwork())); ApplicationModel.NetworkCreatorId = ApplicationModel.CurrentPlayer.Entity.Id; if (string.IsNullOrWhiteSpace(partyNetworkHandler.NetworkId)) { yield return(null); } var matchLobbyHandler = new MatchLobbyHandler(ApplicationModel.CurrentPlayer); yield return(StartCoroutine(matchLobbyHandler.CreateMatchLobby(groupName, partyNetworkHandler.NetworkId, locked))); ApplicationModel.CurrentMatchLobby = matchLobbyHandler.MatchLobby; }
private IEnumerator ConnectMatchLobby(string matchLobbyId) { ApplicationModel.ConnectedToLobby = false; var matchLobbyHandler = new MatchLobbyHandler(ApplicationModel.CurrentPlayer); yield return(matchLobbyHandler.JoinMatchLobby(matchLobbyId)); ApplicationModel.CurrentSharedGroupData = matchLobbyHandler.TicTacToeSharedGroupData ?? new TicTacToeSharedGroupData(); if (ApplicationModel.CurrentMatchLobby == null) { UpdateGameStatus(Constants.MATCH_LOBBY_JOIN_ERROR); } else { ApplicationModel.ConnectedToLobby = ApplicationModel.CurrentMatch.playerTwoId == ApplicationModel.CurrentPlayer.PlayFabId; } }
private IEnumerator LeaveMatchLobby() { var matchLobbyHandler = new MatchLobbyHandler(CurrentPlayer); yield return(matchLobbyHandler.LeaveMatchLobby(MatchLobby.matchLobbyId)); }