Esempio n. 1
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;
        }
Esempio n. 2
0
        public static async Task <MatchLobby> LeaveMatchLobby(MatchLobby matchLobby, DocumentClient documentClient)
        {
            matchLobby.CurrentAvailability++;

            // This method will update the Cosmos DB document with the newest availability.
            // If there was an outside-modification by other player (race condition),
            // this will throw an error and the player won't be able to join this Lobby.
            await DocumentClientManager.ReplaceDocument(documentClient, matchLobby, Constants.DatabaseName, Constants.MatchLobbyTableName);

            return(matchLobby);
        }
Esempio n. 3
0
        public static async Task <MatchLobby> CreateMatchLobby(string matchLobbyId, bool lockedState, string creatorId, string networkId, IAsyncCollector <MatchLobby> matchlobbyCollection, DocumentClient documentClient)
        {
            var matchLobby = await GetMatchLobbyAsyncById(documentClient, matchLobbyId);

            if (matchLobby != null)
            {
                throw new Exception("Match already exists");
            }

            matchLobby = new MatchLobby
            {
                MatchLobbyId        = matchLobbyId,
                CurrentAvailability = 1,
                NetworkId           = networkId,
                CreatorId           = creatorId,
                Locked = lockedState
            };

            await matchlobbyCollection.AddAsync(matchLobby);

            return(matchLobby);
        }
Esempio n. 4
0
        private void InitializeSharedGroupData(GameState gameState = null, Match match = null, MatchLobby matchLobby = null)
        {
            if (ApplicationModel.CurrentSharedGroupData == null)
            {
                ApplicationModel.CurrentSharedGroupData = new TicTacToeSharedGroupData();
            }

            if (gameState != null)
            {
                ApplicationModel.CurrentGameState = gameState;
            }

            if (match != null)
            {
                ApplicationModel.CurrentMatch = match;
            }

            if (matchLobby != null)
            {
                ApplicationModel.CurrentMatchLobby = matchLobby;
            }
        }
Esempio n. 5
0
 private void onClickConnect(MatchLobby matchLobby)
 {
     Debug.Log($"Joining to: {JsonUtility.ToJson(matchLobby)}");
     ApplicationModel.CurrentMatchLobbyToJoin = matchLobby;
     ApplicationModel.JoinToMatchLobby        = true;
 }