/// <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)
 {
     AndroidJNI.PushLocalFrame(100);
     using (AndroidJavaClass jniStoreInventory = new AndroidJavaClass("com.soomla.store.StoreInventory")) {
         AndroidJNIHandler.CallStaticVoid(jniStoreInventory, "removeNonConsumableItem", nonConsItemId);
     }
     AndroidJNI.PopLocalFrame(IntPtr.Zero);
 }
 /// <summary>
 /// Takes from your user the given amount of the virtual item with the given <c>itemId</c>.
 /// For example, when your user requests a refund, you need to TAKE the item he/she is returning from him/her.
 /// </summary>
 /// <param name="itemId">Item identifier.</param>
 /// <param name="amount">Amount.</param>
 /// <exception cref="VirtualItemNotFoundException">Thrown if the item is not found.</exception>
 override protected void _takeItem(string itemId, int amount)
 {
     AndroidJNI.PushLocalFrame(100);
     using (AndroidJavaClass jniStoreInventory = new AndroidJavaClass("com.soomla.store.StoreInventory")) {
         AndroidJNIHandler.CallStaticVoid(jniStoreInventory, "takeVirtualItem", itemId, amount);
     }
     AndroidJNI.PopLocalFrame(IntPtr.Zero);
 }
 /// <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, string payload)
 {
     AndroidJNI.PushLocalFrame(100);
     using (AndroidJavaClass jniStoreInventory = new AndroidJavaClass("com.soomla.store.StoreInventory")) {
         AndroidJNIHandler.CallStaticVoid(jniStoreInventory, "buy", itemId, payload);
     }
     AndroidJNI.PopLocalFrame(IntPtr.Zero);
 }
 /// <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)
 {
     AndroidJNI.PushLocalFrame(100);
     using (AndroidJavaClass jniStoreInventory = new AndroidJavaClass("com.soomla.store.StoreInventory")) {
         AndroidJNIHandler.CallStaticVoid(jniStoreInventory, "removeUpgrades", goodItemId);
     }
     AndroidJNI.PopLocalFrame(IntPtr.Zero);
 }
 /// <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)
 {
     AndroidJNI.PushLocalFrame(100);
     using (AndroidJavaClass jniStoreInventory = new AndroidJavaClass("com.soomla.store.StoreInventory")) {
         AndroidJNIHandler.CallStaticVoid(jniStoreInventory, "unEquipVirtualGood", goodItemId);
     }
     AndroidJNI.PopLocalFrame(IntPtr.Zero);
 }
예제 #6
0
 /// <summary>
 /// Starts a purchase process in the market.
 /// </summary>
 /// <param name="productId">id of the item to buy.</param>
 protected override void _buyMarketItem(string productId, string payload)
 {
     AndroidJNI.PushLocalFrame(100);
     using (AndroidJavaObject jniPurchasableItem = AndroidJNIHandler.CallStatic <AndroidJavaObject>(
                new AndroidJavaClass("com.soomla.store.data.StoreInfo"), "getPurchasableItem", productId)) {
         AndroidJNIHandler.CallVoid(jniSoomlaStore, "buyWithMarket",
                                    jniPurchasableItem.Call <AndroidJavaObject>("getPurchaseType").Call <AndroidJavaObject>("getMarketItem"),
                                    payload);
     }
     AndroidJNI.PopLocalFrame(IntPtr.Zero);
 }
        /** 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)
        {
            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);
        }
        /** 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;

            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);
        }
        /// <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)
        {
            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);
        }
예제 #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;

            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);
        }
예제 #11
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;

            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);
        }
예제 #12
0
        /// <summary>
        /// Gets the category that the virtual good with the given <c>goodItemId</c> belongs to.
        /// </summary>
        /// <param name="goodItemId">Item id.</param>
        /// <returns>Category that the item with given id belongs to.</returns>
        /// <exception cref="VirtualItemNotFoundException">Exception is thrown if category is not found.</exception>
        override protected VirtualCategory _getCategoryForVirtualGood(string goodItemId)
        {
            VirtualCategory vc = null;

            AndroidJNI.PushLocalFrame(100);
            using (AndroidJavaObject jniVirtualVategory = AndroidJNIHandler.CallStatic <AndroidJavaObject>(
                       new AndroidJavaClass("com.soomla.store.data.StoreInfo"), "getCategory", goodItemId)) {
                vc = new VirtualCategory(jniVirtualVategory);
            }
            AndroidJNI.PopLocalFrame(IntPtr.Zero);
            return(vc);
        }
예제 #13
0
        /// <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)
        {
            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);
        }
예제 #14
0
        /// <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)
        {
            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);
        }