Exemple #1
0
        /// <summary>
        /// Upgrades the virtual good with the given <c>goodItemId</c> by doing the following:
        /// 1. Checks if the good is currently upgraded or if this is the first time being upgraded.
        /// 2. If the good is currently upgraded, upgrades to the next upgrade in the series.
        /// In case there are no more upgrades available(meaning the current upgrade is the last available),
        /// the function returns.
        /// 3. If the good has never been upgraded before, the function upgrades it to the first
        /// available upgrade with the first upgrade of the series.
        /// </summary>
        /// <param name="goodItemId">Good item identifier.</param>
        /// <exception cref="VirtualItemNotFoundException">Thrown if the item is not found.</exception>
        public static void UpgradeGood(string goodItemId)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY Calling UpgradeGood with: " + goodItemId);
            VirtualGood good = (VirtualGood)StoreInfo.GetItemByItemId(goodItemId);

            UpgradeVG upgradeVG = VirtualGoodsStorage.GetCurrentUpgrade(good);

            if (upgradeVG != null)
            {
                String nextItemId = upgradeVG.NextItemId;
                if (string.IsNullOrEmpty(nextItemId))
                {
                    return;
                }
                UpgradeVG vgu = (UpgradeVG)StoreInfo.GetItemByItemId(nextItemId);
                vgu.Buy("");
            }
            else
            {
                UpgradeVG first = StoreInfo.GetFirstUpgradeForVirtualGood(goodItemId);
                if (first != null)
                {
                    first.Buy("");
                }
            }
        }