Exemplo n.º 1
0
        protected override void Awake()
        {
            var playFabAuth   = new PlayFabAuth(_titleId);
            var playFabUser   = new PlayFabUser(playFabAuth);
            var playFabWallet = new PlayFabWallet()
            {
                CurrencyMap = PlayFabWalletCurrencyMap
            };
            var playFabInventory = new PlayFabInventory(_catalogVersion, playFabUser, playFabWallet)
            {
                ItemMap = PlayFabInventoryItemMap
            };
            var playFabStore = new PlayFabStore(_catalogVersion, _storeId)
            {
                PriceMap   = PlayFabStorePriceMap,
                ProductMap = PlayFabStoreProductMap
            };

            var customPlayFabAuth = new CustomPlayFabAuth(playFabAuth, _customId);

            Auth      = customPlayFabAuth;
            Inventory = playFabInventory;
            Store     = playFabStore;
            User      = playFabUser;
            Wallet    = playFabWallet;
        }
        protected override void Awake()
        {
            var playFabAuth   = new PlayFabAuth(_titleId);
            var playFabUser   = new PlayFabUser(playFabAuth);
            var playFabWallet = new PlayFabWallet()
            {
                CurrencyMap = PlayFabWalletCurrencyMap
            };
            var playFabInventory = new PlayFabInventory(_catalogVersion, playFabUser, playFabWallet)
            {
                ItemMap = PlayFabInventoryItemMap
            };
            var playFabStore = new PlayFabStore(_catalogVersion, _storeId)
            {
                PriceMap   = PlayFabStorePriceMap,
                ProductMap = PlayFabStoreProductMap
            };

            var googlePlayAuth  = new GooglePlayAuth();
            var googlePlayStore = new GooglePlayStore(_publicKey)
            {
                ProductMap      = UnityStoreProductMap,
                SubscriptionMap = UnityStoreSubscriptionMap
            };

            var googlePlayPlayFabAuth  = new GooglePlayPlayFabAuth(playFabAuth, googlePlayAuth);
            var googlePlayPlayFabStore = new GooglePlayPlayFabStore(playFabStore, googlePlayStore);

            Auth      = googlePlayPlayFabAuth;
            Inventory = playFabInventory;
            Store     = googlePlayPlayFabStore;
            User      = playFabUser;
            Wallet    = playFabWallet;
        }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        // use transform.Find for objects that are not active
        enterNameDialog = GameObject.Find("Canvas").transform.Find("EnterNameDialog").gameObject;

        if (string.IsNullOrEmpty(Globals.SessionTicket))
        {
            PlayFabAuth.Login(
                result =>
            {
                Debug.Log($"User '{Globals.DisplayName}' logged in with ticket {Globals.SessionTicket}");

                // user has no DisplayName, allow them to create one
                if (string.IsNullOrEmpty(Globals.DisplayName))
                {
                    Animation a = enterNameDialog.GetComponent <Animation>();
                    a.Play();
                }

                UpdateUI(true);
            },
                error =>
            {
                Debug.Log("Failed logging in: " + error.GenerateErrorReport());
                DialogBox.Show(error.GenerateErrorReport());
            });
        }
        else
        {
            UpdateUI(true);
        }
    }
Exemplo n.º 4
0
    public void OnAuthRequestMessage(NetworkConnection conn, AuthRequestMessage msg)
    {
        PlayFabAuth checkAuth = CheckPlayFabAuth;

        Debug.LogFormat("Authentication Request: {0} {1}", msg.playFabID, msg.sessionTicket);

        //AuthResponseMessage authResponseMessage = new AuthResponseMessage
        //{
        //     code = 100,
        //    message = "Success"
        //};
        //NetworkServer.SendToClient(conn.connectionId, authResponseMessage);

        // Invoke the event to complete a successful authentication
        //base.OnServerAuthenticated.Invoke(conn);

        // TESTING REMOVE
        //msg.playFabID = username;
        //msg.sessionTicket = password;
        // TESTING REMOVE\

        //NetworkManager.userAuthDetails.Add(msg.playFabID, conn);

        /*
         *
         * if (NetworkManager.singleton.PlayFabIDs.Contains(result.UserInfo.PlayFabID))
         * {
         *  NetworkConnection conn = NetworkManager.singleton.PlayFabIDs(result.UserInfo.PlayFabID);
         *  NetworkManager.singleton.PlayFabIDs.Remove(result.UserInfo.PlayFabID);
         * }
         *
         */
        // Add in the user that is authing to the dictionary
        authDictionary.Add(msg.playFabID, conn);

        checkAuth(msg.playFabID, conn, msg);

        // check the credentials by calling your web server, database table, playfab api, or any method appropriate.
        //if (msg.playFabID == username && msg.sessionTicket == password)
        //    {
        //        // create and send msg to client so it knows to proceed
        //        AuthResponseMessage authResponseMessage = new AuthResponseMessage
        //        {
        //            code = 100,
        //            message = "Success"
        //        };

        //        NetworkServer.SendToClient(conn.connectionId, authResponseMessage);

        //        // Invoke the event to complete a successful authentication
        //        base.OnServerAuthenticated.Invoke(conn);
        //    }
        //    else
        //    {
        //        // create and send msg to client so it knows to disconnect
        //        AuthResponseMessage authResponseMessage = new AuthResponseMessage
        //        {
        //            code = 200,
        //            message = "Invalid Credentials"
        //        };

        //        NetworkServer.SendToClient(conn.connectionId, authResponseMessage);

        //        // must set NetworkConnection isAuthenticated = false
        //        conn.isAuthenticated = false;

        //        // disconnect the client after 1 second so that response message gets delivered
        //        Invoke(nameof(conn.Disconnect), 1);
        //    }
    }