Exemplo n.º 1
0
        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));
                    }
                }
            }
        }
Exemplo n.º 2
0
        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;
            }
        }