示例#1
0
        /// <summary>
        /// see parent
        /// </returns>
        protected PurchasableVirtualItem(JSONObject jsonItem) :
            base(jsonItem)
        {
            JSONObject purchasableObj = (JSONObject)jsonItem[JSONConsts.PURCHASABLE_ITEM];
            string     purchaseType   = purchasableObj[JSONConsts.PURCHASE_TYPE].str;

            if (purchaseType == JSONConsts.PURCHASE_TYPE_MARKET)
            {
                JSONObject marketItemObj = (JSONObject)purchasableObj[JSONConsts.PURCHASE_MARKET_ITEM];

                PurchaseType = new PurchaseWithMarket(new MarketItem(marketItemObj));
            }
            else if (purchaseType == JSONConsts.PURCHASE_TYPE_VI)
            {
                string itemId = purchasableObj[JSONConsts.PURCHASE_VI_ITEMID].str;
                int    amount = System.Convert.ToInt32(((JSONObject)purchasableObj[JSONConsts.PURCHASE_VI_AMOUNT]).n);

                PurchaseType = new PurchaseWithVirtualItem(itemId, amount);
            }
            else
            {
                StoreUtils.LogError(TAG, "Couldn't determine what type of class is the given purchaseType.");
            }
        }
示例#2
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);
        }
示例#3
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);
        }
示例#4
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);
        }
示例#5
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);
        }
示例#6
0
        public void onBillingNotSupported(string message)
        {
            StoreUtils.LogDebug(TAG, "SOOMLA/UNITY onBillingNotSupported");

            StoreEvents.OnBillingNotSupported();
        }
示例#7
0
        public void onIabServiceStopped(string message)
        {
            StoreUtils.LogDebug(TAG, "SOOMLA/UNITY onIabServiceStopped");

            StoreEvents.OnIabServiceStopped();
        }
示例#8
0
        public void onStoreControllerInitialized(string message)
        {
            StoreUtils.LogDebug(TAG, "SOOMLA/UNITY onStoreControllerInitialized");

            StoreEvents.OnStoreControllerInitialized();
        }
示例#9
0
        public void onUnexpectedErrorInStore(string message)
        {
            StoreUtils.LogDebug(TAG, "SOOMLA/UNITY onUnexpectedErrorInStore");

            StoreEvents.OnUnexpectedErrorInStore(message);
        }
示例#10
0
        public void onRestoreTransactionsStarted(string message)
        {
            StoreUtils.LogDebug(TAG, "SOOMLA/UNITY onRestoreTransactionsStarted");

            StoreEvents.OnRestoreTransactionsStarted();
        }
示例#11
0
        public static void Initialize(IStoreAssets storeAssets)
        {
//			StoreUtils.LogDebug(TAG, "Adding currency");
            JSONObject currencies = new JSONObject(JSONObject.Type.ARRAY);

            foreach (VirtualCurrency vi in storeAssets.GetCurrencies())
            {
                currencies.Add(vi.toJSONObject());
            }

//			StoreUtils.LogDebug(TAG, "Adding packs");
            JSONObject packs = new JSONObject(JSONObject.Type.ARRAY);

            foreach (VirtualCurrencyPack vi in storeAssets.GetCurrencyPacks())
            {
                packs.Add(vi.toJSONObject());
            }

//			StoreUtils.LogDebug(TAG, "Adding goods");
            JSONObject suGoods = new JSONObject(JSONObject.Type.ARRAY);
            JSONObject ltGoods = new JSONObject(JSONObject.Type.ARRAY);
            JSONObject eqGoods = new JSONObject(JSONObject.Type.ARRAY);
            JSONObject upGoods = new JSONObject(JSONObject.Type.ARRAY);
            JSONObject paGoods = new JSONObject(JSONObject.Type.ARRAY);

            foreach (VirtualGood g in storeAssets.GetGoods())
            {
                if (g is SingleUseVG)
                {
                    suGoods.Add(g.toJSONObject());
                }
                else if (g is EquippableVG)
                {
                    eqGoods.Add(g.toJSONObject());
                }
                else if (g is UpgradeVG)
                {
                    upGoods.Add(g.toJSONObject());
                }
                else if (g is LifetimeVG)
                {
                    ltGoods.Add(g.toJSONObject());
                }
                else if (g is SingleUsePackVG)
                {
                    paGoods.Add(g.toJSONObject());
                }
            }
            JSONObject goods = new JSONObject(JSONObject.Type.OBJECT);

            goods.AddField(JSONConsts.STORE_GOODS_SU, suGoods);
            goods.AddField(JSONConsts.STORE_GOODS_LT, ltGoods);
            goods.AddField(JSONConsts.STORE_GOODS_EQ, eqGoods);
            goods.AddField(JSONConsts.STORE_GOODS_UP, upGoods);
            goods.AddField(JSONConsts.STORE_GOODS_PA, paGoods);

//			StoreUtils.LogDebug(TAG, "Adding categories");
            JSONObject categories = new JSONObject(JSONObject.Type.ARRAY);

            foreach (VirtualCategory vi in storeAssets.GetCategories())
            {
                categories.Add(vi.toJSONObject());
            }

//			StoreUtils.LogDebug(TAG, "Adding nonConsumables");
            JSONObject nonConsumables = new JSONObject(JSONObject.Type.ARRAY);

            foreach (NonConsumableItem vi in storeAssets.GetNonConsumableItems())
            {
                nonConsumables.Add(vi.toJSONObject());
            }

//			StoreUtils.LogDebug(TAG, "Preparing StoreAssets  JSONObject");
            JSONObject storeAssetsObj = new JSONObject(JSONObject.Type.OBJECT);

            storeAssetsObj.AddField(JSONConsts.STORE_CATEGORIES, categories);
            storeAssetsObj.AddField(JSONConsts.STORE_CURRENCIES, currencies);
            storeAssetsObj.AddField(JSONConsts.STORE_CURRENCYPACKS, packs);
            storeAssetsObj.AddField(JSONConsts.STORE_GOODS, goods);
            storeAssetsObj.AddField(JSONConsts.STORE_NONCONSUMABLES, nonConsumables);

            string storeAssetsJSON = storeAssetsObj.print();

#if UNITY_ANDROID && !UNITY_EDITOR
            StoreUtils.LogDebug(TAG, "pushing data to StoreAssets on java side");
            using (AndroidJavaClass jniStoreAssets = new AndroidJavaClass("com.soomla.unity.StoreAssets")) {
                jniStoreAssets.CallStatic("prepare", storeAssets.GetVersion(), storeAssetsJSON);
            }
            StoreUtils.LogDebug(TAG, "done! (pushing data to StoreAssets on java side)");
#elif UNITY_IOS && !UNITY_EDITOR
            StoreUtils.LogDebug(TAG, "pushing data to StoreAssets on ios side");
            storeAssets_Init(storeAssets.GetVersion(), storeAssetsJSON);
            StoreUtils.LogDebug(TAG, "done! (pushing data to StoreAssets on ios side)");
#endif
        }
示例#12
0
		public void onMarketPurchaseCancelled(string message) {
			StoreUtils.LogDebug(TAG, "SOOMLA/UNITY onMarketPurchaseCancelled: " + message);
			
			PurchasableVirtualItem pvi = (PurchasableVirtualItem)StoreInfo.GetItemByItemId(message);
			Events.OnMarketPurchaseCancelled(pvi);
		}
示例#13
0
		public void onGoodUnequipped(string message) {
			StoreUtils.LogDebug(TAG, "SOOMLA/UNITY onVirtualGoodUnEquipped:" + message);
			
			EquippableVG vg = (EquippableVG)StoreInfo.GetItemByItemId(message);
			Events.OnGoodUnEquipped(vg);
		}
示例#14
0
        public void onItemDetailsRetrievedFailedEvent(string message)
        {
            StoreUtils.LogDebug(TAG, "SOOMLA/UNITY ItemDetailsRetrievedFailedEvent");

            Events.OnItemDetailsRetrievedFailed();
        }
示例#15
0
		public void onRestoreTransactions(string message) {
			StoreUtils.LogDebug(TAG, "SOOMLA/UNITY onRestoreTransactions:" + message);
			
			bool success = Convert.ToBoolean(int.Parse(message));
			Events.OnRestoreTransactions(success);
		}