Ejemplo 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));
                    }
                }
            }
        }
Ejemplo n.º 2
0
        // 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;
        }
Ejemplo n.º 3
0
        public IEnumerator DeleteMatchLobby(string matchLobbyId)
        {
            var matchLobbyHandler = new MatchLobbyHandler(ApplicationModel.CurrentPlayer);

            yield return(matchLobbyHandler.DeleteMatchLobby(matchLobbyId));

            Debug.Log($"MatchLobby deleted: {matchLobbyId}");
            ApplicationModel.CurrentMatchLobby = null;
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        public IEnumerator DeleteMatchLobbyAndLeaveNetwork(string matchLobbyId)
        {
            var matchLobbyHandler = new MatchLobbyHandler(ApplicationModel.CurrentPlayer);

            yield return(matchLobbyHandler.DeleteMatchLobby(matchLobbyId));

            yield return(partyNetworkHandler.LeaveNetwork());

            ApplicationModel.CurrentMatchLobby = null;
        }
Ejemplo n.º 6
0
        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");
            }
        }
Ejemplo n.º 7
0
        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;
            }
        }
Ejemplo n.º 8
0
        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;
        }
Ejemplo n.º 9
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;
            }
        }
Ejemplo n.º 10
0
        private IEnumerator LeaveMatchLobby()
        {
            var matchLobbyHandler = new MatchLobbyHandler(CurrentPlayer);

            yield return(matchLobbyHandler.LeaveMatchLobby(MatchLobby.matchLobbyId));
        }