Beispiel #1
0
        /// <summary>
        /// Calls <see cref="O:TransactionManager.BeginTransaction"/> with the purchase detail of the Transaction Item displayed in the button.
        /// Is automatically attached to the onClick event of the PurchaseButton.
        /// </summary>
        private void Purchase(VirtualTransaction transaction)
        {
            if (transaction == null)
            {
                Debug.LogError($"Transaction shouldn't be null.");
                return;
            }

            StartCoroutine(ExecuteTransaction(transaction));
        }
Beispiel #2
0
        /// <summary>
        /// Standard starting point for Unity scripts.
        /// </summary>
        void Start()
        {
            // The database has been properly setup.
            m_WrongDatabase = !SamplesHelper.VerifyDatabase();
            if (m_WrongDatabase)
            {
                wrongDatabasePanel.SetActive(true);
                return;
            }

            // Initialize must always be called before working with any game foundation code.
            GameFoundation.Initialize(new MemoryDataLayer());

            // Grab references to the transactions.
            m_AppleIngredientTransaction    = GameFoundation.catalogs.transactionCatalog.FindTransaction <VirtualTransaction>("appleIngredient");
            m_OrangeIngredientTransaction   = GameFoundation.catalogs.transactionCatalog.FindTransaction <VirtualTransaction>("orangeIngredient");
            m_BananaIngredientTransaction   = GameFoundation.catalogs.transactionCatalog.FindTransaction <VirtualTransaction>("bananaIngredient");
            m_BroccoliIngredientTransaction = GameFoundation.catalogs.transactionCatalog.FindTransaction <VirtualTransaction>("broccoliIngredient");
            m_CarrotIngredientTransaction   = GameFoundation.catalogs.transactionCatalog.FindTransaction <VirtualTransaction>("carrotIngredient");
            m_FruitSmoothieTransaction      = GameFoundation.catalogs.transactionCatalog.FindTransaction <VirtualTransaction>("fruitSmoothie");
            m_VeggieSmoothieTransaction     = GameFoundation.catalogs.transactionCatalog.FindTransaction <VirtualTransaction>("veggieSmoothie");

            // Here we bind listeners that will set an inventoryChanged flag to callbacks on the Inventory Manager.
            // These callbacks will automatically be invoked anytime an inventory item is added or removed.
            // This prevents us from having to manually invoke RefreshUI every time we perform one of these actions.
            InventoryManager.itemAdded   += OnInventoryItemChanged;
            InventoryManager.itemRemoved += OnInventoryItemChanged;

            // Here we bind listeners to callbacks on the Transaction Manager.
            // These callbacks will automatically be invoked during the processing of a transaction.
            TransactionManager.transactionInitiated  += OnTransactionInitiated;
            TransactionManager.transactionProgressed += OnTransactionProgress;
            TransactionManager.transactionSucceeded  += OnTransactionSucceeded;
            TransactionManager.transactionFailed     += OnTransactionFailed;

            // We'll initialize our WalletManager with some coin for smoothie ingredient purchases.
            WalletManager.AddBalance("coin", 100);

            RefreshUI();
        }