コード例 #1
0
        public static UpgradeVG GetLastUpgradeForVirtualGood(string goodItemId)
        {
#if UNITY_ANDROID && !UNITY_EDITOR
            UpgradeVG vgu = null;
            AndroidJNI.PushLocalFrame(100);
            using (AndroidJavaObject jniUpgradeVG = AndroidJNIHandler.CallStatic <AndroidJavaObject>(
                       new AndroidJavaClass("com.soomla.store.data.StoreInfo"), "getGoodLastUpgrade", goodItemId)) {
                vgu = new UpgradeVG(jniUpgradeVG);
            }
            AndroidJNI.PopLocalFrame(IntPtr.Zero);
            return(vgu);
#elif UNITY_IOS && !UNITY_EDITOR
            IntPtr p   = IntPtr.Zero;
            int    err = storeInfo_GetLastUpgradeForVirtualGood(goodItemId, out p);

            IOS_ErrorCodes.CheckAndThrowException(err);

            string json = Marshal.PtrToStringAnsi(p);
            Marshal.FreeHGlobal(p);

            JSONObject obj = new JSONObject(json);
            return(new UpgradeVG(obj));
#else
            return(null);
#endif
        }
コード例 #2
0
        public static PurchasableVirtualItem GetPurchasableItemWithProductId(string productId)
        {
#if UNITY_ANDROID && !UNITY_EDITOR
            VirtualItem vi = null;
            AndroidJNI.PushLocalFrame(100);
            using (AndroidJavaObject jniVirtualItem = AndroidJNIHandler.CallStatic <AndroidJavaObject>(
                       new AndroidJavaClass("com.soomla.store.data.StoreInfo"), "getPurchasableItem", productId)) {
                vi = VirtualItem.factoryItemFromJNI(jniVirtualItem);
            }
            AndroidJNI.PopLocalFrame(IntPtr.Zero);
            return((PurchasableVirtualItem)vi);
#elif UNITY_IOS && !UNITY_EDITOR
            IntPtr p   = IntPtr.Zero;
            int    err = storeInfo_GetPurchasableItemWithProductId(productId, out p);

            IOS_ErrorCodes.CheckAndThrowException(err);

            string nonConsJson = Marshal.PtrToStringAnsi(p);
            Marshal.FreeHGlobal(p);

            JSONObject obj = new JSONObject(nonConsJson);
            return((PurchasableVirtualItem)VirtualItem.factoryItemFromJSONObject(obj));
#else
            return(null);
#endif
        }
コード例 #3
0
        public static List <UpgradeVG> GetUpgradesForVirtualGood(string goodItemId)
        {
            StoreUtils.LogDebug(TAG, "Trying to fetch upgrades for " + goodItemId);
            List <UpgradeVG> vgus = new List <UpgradeVG>();

#if UNITY_ANDROID && !UNITY_EDITOR
            AndroidJNI.PushLocalFrame(100);
            using (AndroidJavaObject jniUpgradeVGs = new AndroidJavaClass("com.soomla.store.data.StoreInfo").CallStatic <AndroidJavaObject>("getGoodUpgrades")) {
                for (int i = 0; i < jniUpgradeVGs.Call <int>("size"); i++)
                {
                    using (AndroidJavaObject jnivgu = jniUpgradeVGs.Call <AndroidJavaObject>("get", i)) {
                        vgus.Add(new UpgradeVG(jnivgu));
                    }
                }
            }
            AndroidJNI.PopLocalFrame(IntPtr.Zero);
#elif UNITY_IOS && !UNITY_EDITOR
            IntPtr p   = IntPtr.Zero;
            int    err = storeInfo_GetUpgradesForVirtualGood(goodItemId, out p);

            IOS_ErrorCodes.CheckAndThrowException(err);

            string upgradesJson = Marshal.PtrToStringAnsi(p);
            Marshal.FreeHGlobal(p);

            StoreUtils.LogDebug(TAG, "Got json: " + upgradesJson);

            JSONObject upgradesArr = new JSONObject(upgradesJson);
            foreach (JSONObject obj in upgradesArr.list)
            {
                vgus.Add(new UpgradeVG(obj));
            }
#endif
            return(vgus);
        }
コード例 #4
0
        public static List <NonConsumableItem> GetNonConsumableItems()
        {
            StoreUtils.LogDebug(TAG, "Trying to fetch noncons");
            List <NonConsumableItem> nonConsumableItems = new List <NonConsumableItem>();

#if UNITY_ANDROID && !UNITY_EDITOR
            AndroidJNI.PushLocalFrame(100);
            using (AndroidJavaObject jniNonConsumableItems = new AndroidJavaClass("com.soomla.store.data.StoreInfo").CallStatic <AndroidJavaObject>("getNonConsumableItems")) {
                for (int i = 0; i < jniNonConsumableItems.Call <int>("size"); i++)
                {
                    using (AndroidJavaObject jniNon = jniNonConsumableItems.Call <AndroidJavaObject>("get", i)) {
                        nonConsumableItems.Add(new NonConsumableItem(jniNon));
                    }
                }
            }
            AndroidJNI.PopLocalFrame(IntPtr.Zero);
#elif UNITY_IOS && !UNITY_EDITOR
            IntPtr p   = IntPtr.Zero;
            int    err = storeInfo_GetNonConsumableItems(out p);

            IOS_ErrorCodes.CheckAndThrowException(err);

            string nonConsumableJson = Marshal.PtrToStringAnsi(p);
            Marshal.FreeHGlobal(p);

            StoreUtils.LogDebug(TAG, "Got json: " + nonConsumableJson);

            JSONObject nonConsArr = new JSONObject(nonConsumableJson);
            foreach (JSONObject obj in nonConsArr.list)
            {
                nonConsumableItems.Add(new NonConsumableItem(obj));
            }
#endif
            return(nonConsumableItems);
        }
コード例 #5
0
        public static string GetGoodCurrentUpgrade(string goodItemId)
        {
            if (!Application.isEditor)
            {
                StoreUtils.LogDebug(TAG, "SOOMLA/UNITY Calling GetGoodCurrentUpgrade with: " + goodItemId);
#if UNITY_ANDROID && !UNITY_EDITOR
                string currentItemId = "";
                AndroidJNI.PushLocalFrame(100);
                using (AndroidJavaClass jniStoreInventory = new AndroidJavaClass("com.soomla.store.StoreInventory")) {
                    currentItemId = AndroidJNIHandler.CallStatic <string>(jniStoreInventory, "getGoodCurrentUpgrade", goodItemId);
                }
                AndroidJNI.PopLocalFrame(IntPtr.Zero);
                return(currentItemId);
#elif UNITY_IOS && !UNITY_EDITOR
                IntPtr p   = IntPtr.Zero;
                int    err = storeInventory_GetGoodCurrentUpgrade(goodItemId, out p);

                IOS_ErrorCodes.CheckAndThrowException(err);

                string result = Marshal.PtrToStringAnsi(p);
                Marshal.FreeHGlobal(p);

                return(result);
#endif
            }
            return(null);
        }
コード例 #6
0
        public static VirtualItem GetItemByItemId(string itemId)
        {
            StoreUtils.LogDebug(TAG, "Trying to fetch an item with itemId: " + itemId);
#if UNITY_ANDROID && !UNITY_EDITOR
            VirtualItem vi = null;
            AndroidJNI.PushLocalFrame(100);
            using (AndroidJavaObject jniVirtualItem = AndroidJNIHandler.CallStatic <AndroidJavaObject>(
                       new AndroidJavaClass("com.soomla.store.data.StoreInfo"), "getVirtualItem", itemId)) {
                vi = VirtualItem.factoryItemFromJNI(jniVirtualItem);
            }
            AndroidJNI.PopLocalFrame(IntPtr.Zero);
            return(vi);
#elif UNITY_IOS && !UNITY_EDITOR
            IntPtr p   = IntPtr.Zero;
            int    err = storeInfo_GetItemByItemId(itemId, out p);

            IOS_ErrorCodes.CheckAndThrowException(err);

            string json = Marshal.PtrToStringAnsi(p);
            Marshal.FreeHGlobal(p);

            StoreUtils.LogDebug(TAG, "Got json: " + json);

            JSONObject obj = new JSONObject(json);
            return(VirtualItem.factoryItemFromJSONObject(obj));
#else
            return(null);
#endif
        }
コード例 #7
0
        public static List <VirtualCategory> GetVirtualCategories()
        {
            StoreUtils.LogDebug(TAG, "Trying to fetch categories");
            List <VirtualCategory> virtualCategories = new List <VirtualCategory>();

#if UNITY_ANDROID && !UNITY_EDITOR
            AndroidJNI.PushLocalFrame(100);
            using (AndroidJavaObject jniVirtualCategories = new AndroidJavaClass("com.soomla.store.data.StoreInfo").CallStatic <AndroidJavaObject>("getCategories")) {
                for (int i = 0; i < jniVirtualCategories.Call <int>("size"); i++)
                {
                    using (AndroidJavaObject jniCat = jniVirtualCategories.Call <AndroidJavaObject>("get", i)) {
                        virtualCategories.Add(new VirtualCategory(jniCat));
                    }
                }
            }
            AndroidJNI.PopLocalFrame(IntPtr.Zero);
#elif UNITY_IOS && !UNITY_EDITOR
            IntPtr p   = IntPtr.Zero;
            int    err = storeInfo_GetVirtualCategories(out p);

            IOS_ErrorCodes.CheckAndThrowException(err);

            string categoriesJson = Marshal.PtrToStringAnsi(p);
            Marshal.FreeHGlobal(p);

            StoreUtils.LogDebug(TAG, "Got json: " + categoriesJson);

            JSONObject categoriesArr = new JSONObject(categoriesJson);
            foreach (JSONObject obj in categoriesArr.list)
            {
                virtualCategories.Add(new VirtualCategory(obj));
            }
#endif
            return(virtualCategories);
        }
コード例 #8
0
        /// <summary>
        /// Checks if the virtual good with the given <c>goodItemId</c> is currently equipped.
        /// </summary>
        /// <param name="goodItemId">Id of the virtual good who we want to know if is equipped.</param>
        /// <returns>True if the virtual good is equipped, false otherwise.</returns>
        /// <exception cref="VirtualItemNotFoundException">Thrown if the item is not found.</exception>
        override protected bool _isVertualGoodEquipped(string goodItemId)
        {
            bool result = false;
            int  err    = storeInventory_IsVirtualGoodEquipped(goodItemId, out result);

            IOS_ErrorCodes.CheckAndThrowException(err);
            return(result);
        }
コード例 #9
0
        /** VIRTUAL ITEMS **/

        /// <summary>
        /// Retrieves the balance of the virtual item with the given <c>itemId</c>.
        /// </summary>
        /// <param name="itemId">Id of the virtual item to be fetched.</param>
        /// <returns>Balance of the virtual item with the given item id.</returns>
        /// <exception cref="VirtualItemNotFoundException">Thrown if the item is not found.</exception>
        override protected int _getItemBalance(string itemId)
        {
            int balance = 0;
            int err     = storeInventory_GetItemBalance(itemId, out balance);

            IOS_ErrorCodes.CheckAndThrowException(err);
            return(balance);
        }
コード例 #10
0
        /// <summary>
        /// Retrieves the upgrade level of the virtual good with the given <c>goodItemId</c>.
        /// For Example:
        /// Let's say there's a strength attribute to one of the characters in your game and you provide
        /// your users with the ability to upgrade that strength on a scale of 1-3.
        /// This is what you've created:
        /// 1. <c>SingleUseVG</c> for "strength".
        /// 2. <c>UpgradeVG</c> for strength 'level 1'.
        /// 3. <c>UpgradeVG</c> for strength 'level 2'.
        /// 4. <c>UpgradeVG</c> for strength 'level 3'.
        /// In the example, this function will retrieve the upgrade level for "strength" (1, 2, or 3).
        /// </summary>
        /// <param name="goodItemId">Good item identifier.</param>
        /// <returns>The good upgrade level.</returns>
        /// <exception cref="VirtualItemNotFoundException">Thrown if the item is not found.</exception>
        override protected int _getGoodUpgradeLevel(string goodItemId)
        {
            int level = 0;
            int err   = storeInventory_GetGoodUpgradeLevel(goodItemId, out level);

            IOS_ErrorCodes.CheckAndThrowException(err);
            return(level);
        }
コード例 #11
0
        /** NON-CONSUMABLES **/

        /// <summary>
        /// Checks if the non-consumable with the given <c>nonConsItemId</c> exists.
        /// </summary>
        /// <param name="nonConsItemId">Id of the item to check if exists.</param>
        /// <returns>True if non-consumable item with nonConsItemId exists, false otherwise.</returns>
        /// <exception cref="VirtualItemNotFoundException">Thrown if the item is not found.</exception>
        override protected bool _nonConsumableItemExists(string nonConsItemId)
        {
            bool result = false;
            int  err    = storeInventory_NonConsumableItemExists(nonConsItemId, out result);

            IOS_ErrorCodes.CheckAndThrowException(err);
            return(result);
        }
コード例 #12
0
        /// <summary>
        /// Retrieves the current upgrade of the good with the given id.
        /// </summary>
        /// <param name="goodItemId">Id of the good whose upgrade we want to fetch. </param>
        /// <returns>The good's current upgrade.</returns>
        /// <exception cref="VirtualItemNotFoundException">Thrown if the item is not found.</exception>
        override protected string _getGoodCurrentUpgrade(string goodItemId)
        {
            IntPtr p   = IntPtr.Zero;
            int    err = storeInventory_GetGoodCurrentUpgrade(goodItemId, out p);

            IOS_ErrorCodes.CheckAndThrowException(err);
            string result = Marshal.PtrToStringAnsi(p);

            Marshal.FreeHGlobal(p);
            return(result);
        }
コード例 #13
0
ファイル: StoreInfoIOS.cs プロジェクト: ricna/unity3d-store
        /// <summary>
        /// Gets the last upgrade for the virtual good with the given <c>goodItemId</c>.
        /// </summary>
        /// <param name="goodItemId">item id</param>
        /// <returns>last upgrade for virtual good with the given id</returns>
        override protected UpgradeVG _getLastUpgradeForVirtualGood(string goodItemId)
        {
            IntPtr p   = IntPtr.Zero;
            int    err = storeInfo_GetLastUpgradeForVirtualGood(goodItemId, out p);

            IOS_ErrorCodes.CheckAndThrowException(err);

            string json = Marshal.PtrToStringAnsi(p);

            Marshal.FreeHGlobal(p);

            JSONObject obj = new JSONObject(json);

            return(new UpgradeVG(obj));
        }
コード例 #14
0
ファイル: StoreInfoIOS.cs プロジェクト: ricna/unity3d-store
        /// <summary>
        /// Gets the purchasable item with the given <c>productId</c>.
        /// </summary>
        /// <param name="productId">Product id.</param>
        /// <returns>Purchasable virtual item with the given id.</returns>
        /// <exception cref="VirtualItemNotFoundException">Exception is thrown if item is not found.</exception>
        override protected PurchasableVirtualItem _getPurchasableItemWithProductId(string productId)
        {
            IntPtr p   = IntPtr.Zero;
            int    err = storeInfo_GetPurchasableItemWithProductId(productId, out p);

            IOS_ErrorCodes.CheckAndThrowException(err);

            string nonConsJson = Marshal.PtrToStringAnsi(p);

            Marshal.FreeHGlobal(p);

            JSONObject obj = new JSONObject(nonConsJson);

            return((PurchasableVirtualItem)VirtualItem.factoryItemFromJSONObject(obj));
        }
コード例 #15
0
ファイル: StoreInfoIOS.cs プロジェクト: ricna/unity3d-store
        /// <summary>
        /// Gets the item with the given <c>itemId</c>.
        /// </summary>
        /// <param name="itemId">Item id.</param>
        /// <returns>Item with the given id.</returns>
        /// <exception cref="VirtualItemNotFoundException">Exception is thrown if item is not found.</exception>
        override protected VirtualItem _getItemByItemId(string itemId)
        {
            IntPtr p   = IntPtr.Zero;
            int    err = storeInfo_GetItemByItemId(itemId, out p);

            IOS_ErrorCodes.CheckAndThrowException(err);

            string json = Marshal.PtrToStringAnsi(p);

            Marshal.FreeHGlobal(p);
            Utils.LogDebug(TAG, "Got json: " + json);

            JSONObject obj = new JSONObject(json);

            return(VirtualItem.factoryItemFromJSONObject(obj));
        }
コード例 #16
0
        public static void BuyItem(string itemId)
        {
            if (!Application.isEditor)
            {
                StoreUtils.LogDebug(TAG, "SOOMLA/UNITY Calling BuyItem with: " + itemId);
#if UNITY_ANDROID && !UNITY_EDITOR
                AndroidJNI.PushLocalFrame(100);
                using (AndroidJavaClass jniStoreInventory = new AndroidJavaClass("com.soomla.store.StoreInventory")) {
                    AndroidJNIHandler.CallStaticVoid(jniStoreInventory, "buy", itemId);
                }
                AndroidJNI.PopLocalFrame(IntPtr.Zero);
#elif UNITY_IOS && !UNITY_EDITOR
                int err = storeInventory_BuyItem(itemId);

                IOS_ErrorCodes.CheckAndThrowException(err);
#endif
            }
        }
コード例 #17
0
ファイル: StoreInfoIOS.cs プロジェクト: ricna/unity3d-store
        /// <summary>
        /// Fetches the virtual goods of your game.
        /// </summary>
        /// <returns>All virtual goods.</returns>
        override protected List <VirtualGood> _getVirtualGoods()
        {
            List <VirtualGood> virtualGoods = new List <VirtualGood>();
            IntPtr             p            = IntPtr.Zero;
            int err = storeInfo_GetVirtualGoods(out p);

            IOS_ErrorCodes.CheckAndThrowException(err);

            string goodsJson = Marshal.PtrToStringAnsi(p);

            Marshal.FreeHGlobal(p);

            Utils.LogDebug(TAG, "Got json: " + goodsJson);

            JSONObject goodsArr = new JSONObject(goodsJson);

            foreach (JSONObject obj in goodsArr.list)
            {
                virtualGoods.Add((VirtualGood)VirtualItem.factoryItemFromJSONObject(obj));
            }
            return(virtualGoods);
        }
コード例 #18
0
ファイル: StoreInfoIOS.cs プロジェクト: ricna/unity3d-store
        /// <summary>
        /// Fetches the virtual categories of your game.
        /// </summary>
        /// <returns>All virtual categories.</returns>
        override protected List <VirtualCategory> _getVirtualCategories()
        {
            List <VirtualCategory> virtualCategories = new List <VirtualCategory>();
            IntPtr p   = IntPtr.Zero;
            int    err = storeInfo_GetVirtualCategories(out p);

            IOS_ErrorCodes.CheckAndThrowException(err);

            string categoriesJson = Marshal.PtrToStringAnsi(p);

            Marshal.FreeHGlobal(p);

            Utils.LogDebug(TAG, "Got json: " + categoriesJson);

            JSONObject categoriesArr = new JSONObject(categoriesJson);

            foreach (JSONObject obj in categoriesArr.list)
            {
                virtualCategories.Add(new VirtualCategory(obj));
            }
            return(virtualCategories);
        }
コード例 #19
0
ファイル: StoreInfoIOS.cs プロジェクト: ricna/unity3d-store
        /// <summary>
        /// Fetches the non consumable items of your game.
        /// </summary>
        /// <returns>All non consumable items.</returns>
        override protected List <NonConsumableItem> _getNonConsumableItems()
        {
            List <NonConsumableItem> nonConsumableItems = new List <NonConsumableItem>();
            IntPtr p   = IntPtr.Zero;
            int    err = storeInfo_GetNonConsumableItems(out p);

            IOS_ErrorCodes.CheckAndThrowException(err);

            string nonConsumableJson = Marshal.PtrToStringAnsi(p);

            Marshal.FreeHGlobal(p);

            Utils.LogDebug(TAG, "Got json: " + nonConsumableJson);

            JSONObject nonConsArr = new JSONObject(nonConsumableJson);

            foreach (JSONObject obj in nonConsArr.list)
            {
                nonConsumableItems.Add(new NonConsumableItem(obj));
            }
            return(nonConsumableItems);
        }
コード例 #20
0
ファイル: StoreInfoIOS.cs プロジェクト: ricna/unity3d-store
        /// <summary>
        /// Fetches the virtual currency packs of your game.
        /// </summary>
        /// <returns>All virtual currency packs.</returns>
        override protected List <VirtualCurrencyPack> _getVirtualCurrencyPacks()
        {
            List <VirtualCurrencyPack> vcps = new List <VirtualCurrencyPack>();
            IntPtr p   = IntPtr.Zero;
            int    err = storeInfo_GetVirtualCurrencyPacks(out p);

            IOS_ErrorCodes.CheckAndThrowException(err);

            string packsJson = Marshal.PtrToStringAnsi(p);

            Marshal.FreeHGlobal(p);

            Utils.LogDebug(TAG, "Got json: " + packsJson);

            JSONObject packsArr = new JSONObject(packsJson);

            foreach (JSONObject obj in packsArr.list)
            {
                vcps.Add(new VirtualCurrencyPack(obj));
            }
            return(vcps);
        }
コード例 #21
0
ファイル: StoreInfoIOS.cs プロジェクト: ricna/unity3d-store
        /// <summary>
        /// Gets all the upgrades for the virtual good with the given <c>goodItemId</c>.
        /// </summary>
        /// <param name="goodItemId">Item id.</param>
        /// <returns>All upgrades for virtual good with the given id.</returns>
        override protected List <UpgradeVG> _getUpgradesForVirtualGood(string goodItemId)
        {
            List <UpgradeVG> vgus = new List <UpgradeVG>();
            IntPtr           p    = IntPtr.Zero;
            int err = storeInfo_GetUpgradesForVirtualGood(goodItemId, out p);

            IOS_ErrorCodes.CheckAndThrowException(err);

            string upgradesJson = Marshal.PtrToStringAnsi(p);

            Marshal.FreeHGlobal(p);

            Utils.LogDebug(TAG, "Got json: " + upgradesJson);

            JSONObject upgradesArr = new JSONObject(upgradesJson);

            foreach (JSONObject obj in upgradesArr.list)
            {
                vgus.Add(new UpgradeVG(obj));
            }
            return(vgus);
        }
コード例 #22
0
        public static List <VirtualGood> GetVirtualGoods()
        {
            StoreUtils.LogDebug(TAG, "Trying to fetch goods");
            List <VirtualGood> virtualGoods = new List <VirtualGood>();

#if UNITY_ANDROID && !UNITY_EDITOR
            AndroidJNI.PushLocalFrame(100);
            using (AndroidJavaObject jniVirtualGoods = new AndroidJavaClass("com.soomla.store.data.StoreInfo").CallStatic <AndroidJavaObject>("getGoods")) {
                for (int i = 0; i < jniVirtualGoods.Call <int>("size"); i++)
                {
                    AndroidJNI.PushLocalFrame(100);
                    using (AndroidJavaObject jniGood = jniVirtualGoods.Call <AndroidJavaObject>("get", i)) {
                        virtualGoods.Add((VirtualGood)VirtualItem.factoryItemFromJNI(jniGood));
                    }
                    AndroidJNI.PopLocalFrame(IntPtr.Zero);
                }
            }
            AndroidJNI.PopLocalFrame(IntPtr.Zero);
#elif UNITY_IOS && !UNITY_EDITOR
            IntPtr p   = IntPtr.Zero;
            int    err = storeInfo_GetVirtualGoods(out p);

            IOS_ErrorCodes.CheckAndThrowException(err);

            string goodsJson = Marshal.PtrToStringAnsi(p);
            Marshal.FreeHGlobal(p);

            StoreUtils.LogDebug(TAG, "Got json: " + goodsJson);

            JSONObject goodsArr = new JSONObject(goodsJson);
            foreach (JSONObject obj in goodsArr.list)
            {
                virtualGoods.Add((VirtualGood)VirtualItem.factoryItemFromJSONObject(obj));
            }
#endif
            return(virtualGoods);
        }
コード例 #23
0
        public static bool IsVirtualGoodEquipped(string goodItemId)
        {
            if (!Application.isEditor)
            {
                StoreUtils.LogDebug(TAG, "SOOMLA/UNITY Calling IsVirtualGoodEquipped with: " + goodItemId);
#if UNITY_ANDROID && !UNITY_EDITOR
                bool result = false;
                AndroidJNI.PushLocalFrame(100);
                using (AndroidJavaClass jniStoreInventory = new AndroidJavaClass("com.soomla.store.StoreInventory")) {
                    result = AndroidJNIHandler.CallStatic <bool>(jniStoreInventory, "isVirtualGoodEquipped", goodItemId);
                }
                AndroidJNI.PopLocalFrame(IntPtr.Zero);
                return(result);
#elif UNITY_IOS && !UNITY_EDITOR
                bool result = false;
                int  err    = storeInventory_IsVirtualGoodEquipped(goodItemId, out result);

                IOS_ErrorCodes.CheckAndThrowException(err);

                return(result);
#endif
            }
            return(false);
        }
コード例 #24
0
        /** NonConsumables **/


        public static bool NonConsumableItemExists(string nonConsItemId)
        {
            if (!Application.isEditor)
            {
                StoreUtils.LogDebug(TAG, "SOOMLA/UNITY Calling NonConsumableItemExists with: " + nonConsItemId);
#if UNITY_ANDROID && !UNITY_EDITOR
                bool result = false;
                AndroidJNI.PushLocalFrame(100);
                using (AndroidJavaClass jniStoreInventory = new AndroidJavaClass("com.soomla.store.StoreInventory")) {
                    result = AndroidJNIHandler.CallStatic <bool>(jniStoreInventory, "nonConsumableItemExists", nonConsItemId);
                }
                AndroidJNI.PopLocalFrame(IntPtr.Zero);
                return(result);
#elif UNITY_IOS && !UNITY_EDITOR
                bool result = false;
                int  err    = storeInventory_NonConsumableItemExists(nonConsItemId, out result);

                IOS_ErrorCodes.CheckAndThrowException(err);

                return(result);
#endif
            }
            return(false);
        }
コード例 #25
0
        /** Virtual Items **/


        public static int GetItemBalance(string itemId)
        {
            if (!Application.isEditor)
            {
                StoreUtils.LogDebug(TAG, "SOOMLA/UNITY Calling GetItemBalance with: " + itemId);
#if UNITY_ANDROID && !UNITY_EDITOR
                AndroidJNI.PushLocalFrame(100);
                int balance = 0;
                using (AndroidJavaClass jniStoreInventory = new AndroidJavaClass("com.soomla.store.StoreInventory")) {
                    balance = AndroidJNIHandler.CallStatic <int>(jniStoreInventory, "getVirtualItemBalance", itemId);
                }
                AndroidJNI.PopLocalFrame(IntPtr.Zero);
                return(balance);
#elif UNITY_IOS && !UNITY_EDITOR
                int balance = 0;
                int err     = storeInventory_GetItemBalance(itemId, out balance);

                IOS_ErrorCodes.CheckAndThrowException(err);

                return(balance);
#endif
            }
            return(0);
        }
コード例 #26
0
        public static int GetGoodUpgradeLevel(string goodItemId)
        {
            if (!Application.isEditor)
            {
                StoreUtils.LogDebug(TAG, "SOOMLA/UNITY Calling GetGoodUpgradeLevel with: " + goodItemId);
#if UNITY_ANDROID && !UNITY_EDITOR
                int level = 0;
                AndroidJNI.PushLocalFrame(100);
                using (AndroidJavaClass jniStoreInventory = new AndroidJavaClass("com.soomla.store.StoreInventory")) {
                    level = AndroidJNIHandler.CallStatic <int>(jniStoreInventory, "getGoodUpgradeLevel", goodItemId);
                }
                AndroidJNI.PopLocalFrame(IntPtr.Zero);
                return(level);
#elif UNITY_IOS && !UNITY_EDITOR
                int level = 0;
                int err   = storeInventory_GetGoodUpgradeLevel(goodItemId, out level);

                IOS_ErrorCodes.CheckAndThrowException(err);

                return(level);
#endif
            }
            return(0);
        }
コード例 #27
0
        /// <summary>
        /// Unequips the virtual good with the given <c>goodItemId</c>. Unequipping means that the
        /// user decides to stop using the virtual good he/she is currently using.
        /// For more details and examples <see cref="com.soomla.store.domain.virtualGoods.EquippableVG"/>.
        /// </summary>
        /// <param name="goodItemId">Id of the good to be unequipped.</param>
        /// <exception cref="VirtualItemNotFoundException">Thrown if the item is not found.</exception>
        override protected void _unEquipVirtualGood(string goodItemId)
        {
            int err = storeInventory_UnEquipVirtualGood(goodItemId);

            IOS_ErrorCodes.CheckAndThrowException(err);
        }
コード例 #28
0
        /// <summary>
        /// Removes all upgrades from the virtual good with the given <c>goodItemId</c>.
        /// </summary>
        /// <param name="goodItemId">Id of the good whose upgrades are to be removed.</param>
        /// <exception cref="VirtualItemNotFoundException">Thrown if the item is not found.</exception>
        override protected void _removeGoodUpgrades(string goodItemId)
        {
            int err = storeInventory_RemoveGoodUpgrades(goodItemId);

            IOS_ErrorCodes.CheckAndThrowException(err);
        }
コード例 #29
0
        /// <summary>
        /// Removes the non-consumable item with the given <c>nonConsItemId</c> from the non-consumable
        /// items storage.
        /// </summary>
        /// <param name="nonConsItemId">Id of the item to be removed.</param>
        /// <exception cref="VirtualItemNotFoundException">Thrown if the item is not found.</exception>
        override protected void _removeNonConsumableItem(string nonConsItemId)
        {
            int err = storeInventory_RemoveNonConsumableItem(nonConsItemId);

            IOS_ErrorCodes.CheckAndThrowException(err);
        }
コード例 #30
0
        /// <summary>
        /// Buys the item with the given <c>itemId</c>.
        /// </summary>
        /// <param name="itemId">id of item to be bought</param>
        /// <exception cref="VirtualItemNotFoundException">Thrown if the item to be bought is not found.</exception>
        /// <exception cref="InsufficientFundsException">Thrown if the user does not have enough funds.</exception>
        override protected void _buyItem(string itemId)
        {
            int err = storeInventory_BuyItem(itemId);

            IOS_ErrorCodes.CheckAndThrowException(err);
        }