예제 #1
0
        /// <summary>
        /// purchase consumable virtual product based on its product id
        /// </summary>
        public static void PurchaseConsumableVirtualProduct(string productId)
        {
            //check whether the player has enough funds
            bool didSucceed = DBManager.VerifyVirtualPurchase(GetIAPObject(productId));

            if (instance.debug)
            {
                Debug.Log("purchasing consumable virtual product " + productId + " result: " + didSucceed);
            }
            //on success, save new substracted fund value to the database
            //and fire the succeeded event
            if (didSucceed)
            {
                DBManager.Save();
                purchaseSucceededEvent(productId);
            }
            //otherwise show fail message
            else
            {
                PurchaseFailed("Insufficient funds.");
            }
        }