Example #1
0
	public VirtualGood[] GetGoods() {
		int i = 5;
		VirtualGood[] virtualGoods = new VirtualGood[i];
		virtualGoods[--i] = new SingleUseVG("ItemBalanceGate",
		                                    "", ITEM_ID_BALANCE_GATE,
#if UNITY_ANDROID
			                                    new PurchaseWithMarket("android.test.purchased", 1));
#else
												new PurchaseWithMarket("noads3", 1));
#endif
		virtualGoods[--i] = new SingleUseVG("ItemBalanceMission",
		                                    "", ITEM_ID_BALANCE_MISSION,
		                                    new PurchaseWithMarket(ITEM_ID_BALANCE_MISSION, 1));
		virtualGoods[--i] = new SingleUseVG("ItemBalanceMissionReward",
		                                    "", ITEM_ID_BALANCE_MISSION_REWARD,
		                                    new PurchaseWithMarket(ITEM_ID_BALANCE_MISSION_REWARD, 1));
		virtualGoods[--i] = new SingleUseVG("ItemVIScore",
		                                    "", ITEM_ID_VI_SCORE,
		                                    new PurchaseWithMarket(ITEM_ID_VI_SCORE, 1));
		virtualGoods[--i] = new SingleUseVG("ItemVIReward",
		                                    "", ITEM_ID_VI_REWARD,
		                                    new PurchaseWithMarket(ITEM_ID_VI_REWARD, 1));
		
		return virtualGoods;
	}
		protected override void _assignCurrentUpgrade(VirtualGood good, UpgradeVG upgradeVG, bool notify) {
			AndroidJNI.PushLocalFrame(100);
			using(AndroidJavaClass jniStorageManager = new AndroidJavaClass("com.soomla.store.data.StorageManager")) {
				using(AndroidJavaObject jniVGStorage = jniStorageManager.CallStatic<AndroidJavaObject>("getVirtualGoodsStorage")) {
					jniVGStorage.Call("assignCurrentUpgrade", good.ItemId, upgradeVG.ItemId, notify);
				}
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
		}
Example #3
0
    private void Awake()
    {
        this.VirtualGood = this.GetVirtualGood();
        this.ItemId = this.VirtualGood.ItemId;
        this.Description.text = this.VirtualGood.Name;
        this.Info.text = this.VirtualGood.Description;

        StoreEvents.OnGoodBalanceChanged += this.OnGoodBalanceChanged;
        ShopManager.Instance.ShopDataInitializedEvent += this.OnShopDataInitialized;
    }
Example #4
0
            public void PushEventOnGoodBalanceChanged(VirtualGood good, int balance, int amountAdded)
            {
                var eventJSON = new JSONObject();

                eventJSON.AddField("itemId", good.ItemId);
                eventJSON.AddField("balance", balance);
                eventJSON.AddField("amountAdded", amountAdded);

                _pushEventGoodBalanceChanged(eventJSON.print());
            }
		protected override UpgradeVG _getCurrentUpgrade(VirtualGood good) {
			string upgradeVGItemId;
			int err = vgStorage_GetCurrentUpgrade(good.ItemId, out upgradeVGItemId);
			IOS_ErrorCodes.CheckAndThrowException(err);

			if (!string.IsNullOrEmpty(upgradeVGItemId)) {
				return (UpgradeVG) StoreInfo.GetItemByItemId(upgradeVGItemId);
			}

			return null;
		}
Example #6
0
        /// <summary>
        /// Handles an <c>onGoodBalanceChanged</c> event, which is fired when the balance of a specific
        /// <c>VirtualGood</c> has changed.
        /// </summary>
        /// <param name="message">Message that contains information about the good whose balance has
        /// changed.</param>
        public void onGoodBalanceChanged(string message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGoodBalanceChanged:" + message);

            string[] vars = Regex.Split(message, "#SOOM#");

            VirtualGood vg          = (VirtualGood)StoreInfo.GetItemByItemId(vars[0]);
            int         balance     = int.Parse(vars[1]);
            int         amountAdded = int.Parse(vars[2]);

            StoreEvents.OnGoodBalanceChanged(vg, balance, amountAdded);
        }
Example #7
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>
        public static void RemoveGoodUpgrades(string goodItemId)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY Calling RemoveGoodUpgrades with: " + goodItemId);

            List <UpgradeVG> upgrades = StoreInfo.GetUpgradesForVirtualGood(goodItemId);

            foreach (UpgradeVG upgrade in upgrades)
            {
                VirtualGoodsStorage.Remove(upgrade, 1, true);
            }
            VirtualGood good = (VirtualGood)StoreInfo.GetItemByItemId(goodItemId);

            VirtualGoodsStorage.RemoveUpgrades(good);
        }
Example #8
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>
        public static string GetGoodCurrentUpgrade(string goodItemId)
        {
            SoomlaUtils.LogDebug(TAG, "Checking " + goodItemId + " current upgrade");

            VirtualGood good = (VirtualGood)StoreInfo.GetItemByItemId(goodItemId);

            UpgradeVG upgradeVG = VirtualGoodsStorage.GetCurrentUpgrade(good);

            if (upgradeVG == null)
            {
                return("");
            }
            return(upgradeVG.ItemId);
        }
		protected override UpgradeVG _getCurrentUpgrade(VirtualGood good) {
			SoomlaWpStore.domain.virtualGoods.UpgradeVG uvg = null;
            SoomlaWpStore.domain.virtualGoods.VirtualGood vg = (SoomlaWpStore.domain.virtualGoods.VirtualGood)SoomlaWpStore.data.StoreInfo.getVirtualItem(good.ItemId);
            if (vg is SoomlaWpStore.domain.virtualGoods.UpgradeVG)
            {
                uvg = SoomlaWpStore.data.StorageManager.getVirtualGoodsStorage().getCurrentUpgrade(vg);
            }
            
			if (uvg!=null) {
				return (UpgradeVG) StoreInfo.GetItemByItemId(uvg.GetId());
			}

			return null;
		}
Example #10
0
        protected override UpgradeVG _getCurrentUpgrade(VirtualGood good)
        {
            string upgradeVGItemId;
            int    err = vgStorage_GetCurrentUpgrade(good.ItemId, out upgradeVGItemId);

            IOS_ErrorCodes.CheckAndThrowException(err);

            if (!string.IsNullOrEmpty(upgradeVGItemId))
            {
                return((UpgradeVG)StoreInfo.GetItemByItemId(upgradeVGItemId));
            }

            return(null);
        }
Example #11
0
        /// <summary>
        /// Takes upgrade from the user, or in other words DOWNGRADES the associated
        /// <code>VirtualGood</code> (mGood).
        /// Checks if the current Upgrade is really associated with the <code>VirtualGood</code> and:
        /// </summary>
        /// <param name="amount">NOT USED HERE!.</param>
        /// <param name="notify">see parent.</param>
        public override int Take(int amount, bool notify)
        {
            VirtualGood good = null;

            try {
                good = (VirtualGood)StoreInfo.GetItemByItemId(GoodItemId);
            } catch (VirtualItemNotFoundException) {
                SoomlaUtils.LogError(TAG, "VirtualGood with itemId: " + GoodItemId
                                     + " doesn't exist! Can't downgrade.");
                return(0);
            }

            UpgradeVG upgradeVG = VirtualGoodsStorage.GetCurrentUpgrade(good);

            // Case: Upgrade is not assigned to this Virtual Good
            if (upgradeVG != this)
            {
                SoomlaUtils.LogError(TAG, "You can't take an upgrade that's not currently assigned."
                                     + "The UpgradeVG " + Name + " is not assigned to " + "the VirtualGood: "
                                     + good.Name);
                return(0);
            }

            if (!string.IsNullOrEmpty(PrevItemId))
            {
                UpgradeVG prevUpgradeVG = null;
                // Case: downgrade is not possible because previous upgrade does not exist
                try {
                    prevUpgradeVG = (UpgradeVG)StoreInfo.GetItemByItemId(PrevItemId);
                } catch (VirtualItemNotFoundException) {
                    SoomlaUtils.LogError(TAG, "Previous UpgradeVG with itemId: " + PrevItemId
                                         + " doesn't exist! Can't downgrade.");
                    return(0);
                }
                // Case: downgrade is successful!
                SoomlaUtils.LogDebug(TAG, "Downgrading " + good.Name + " to: "
                                     + prevUpgradeVG.Name);
                VirtualGoodsStorage.AssignCurrentUpgrade(good, prevUpgradeVG, notify);
            }

            // Case: first Upgrade in the series - so we downgrade to NO upgrade.
            else
            {
                SoomlaUtils.LogDebug(TAG, "Downgrading " + good.Name + " to NO-UPGRADE");
                VirtualGoodsStorage.RemoveUpgrades(good, notify);
            }

            return(base.Take(amount, notify));
        }
Example #12
0
        /// <summary>
        /// Handles an <c>onGoodUpgrade</c> event, which is fired when a specific <c>UpgradeVG</c> has
        /// been upgraded/downgraded.
        /// </summary>
        /// <param name="message">Message that contains information about the good that has been
        /// upgraded/downgraded.</param>
        public void onGoodUpgrade(string message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGoodUpgrade:" + message);

            string[] vars = Regex.Split(message, "#SOOM#");

            VirtualGood vg  = (VirtualGood)StoreInfo.GetItemByItemId(vars[0]);
            UpgradeVG   vgu = null;

            if (vars.Length > 1)
            {
                vgu = (UpgradeVG)StoreInfo.GetItemByItemId(vars[1]);
            }
            StoreEvents.OnGoodUpgrade(vg, vgu);
        }
Example #13
0
    void bought(VirtualGood arg1, UpgradeVG arg2)
    {
        if (upgrades) {
            int upgdLevel = StoreInventory.GetGoodUpgradeLevel (id);
            if(upgdLevel==5){
                el_desc.text = LanguageManager.current.getText(LanguageNode.FullUpgraded);
                buy.gameObject.SetActive(false);
                el_upgradeMeter.fillAmount = 1f;
            }else{
                el_upgradeMeter.fillAmount = upgdLevel / 5f;
                el_price.text = AnimineStoreAssets.UPGRADE_PRICE [upgdLevel]+"";
            }

        }
    }
        protected override UpgradeVG _getCurrentUpgrade(VirtualGood good)
        {
            string upgradeVGItemId = null;
            SoomlaWpStore.domain.virtualGoods.VirtualGood vg = (SoomlaWpStore.domain.virtualGoods.VirtualGood)SoomlaWpStore.data.StoreInfo.getVirtualItem(good.ItemId);
            if (vg is SoomlaWpStore.domain.virtualGoods.UpgradeVG)
            {
                upgradeVGItemId = SoomlaWpStore.data.StorageManager.getVirtualGoodsStorage().getCurrentUpgrade(vg).getItemId();
            }

            if (!string.IsNullOrEmpty(upgradeVGItemId)) {
                return (UpgradeVG) StoreInfo.GetItemByItemId(upgradeVGItemId);
            }

            return null;
        }
Example #15
0
        protected override UpgradeVG _getCurrentUpgrade(VirtualGood good)
        {
            SoomlaWpStore.domain.virtualGoods.UpgradeVG   uvg = null;
            SoomlaWpStore.domain.virtualGoods.VirtualGood vg  = (SoomlaWpStore.domain.virtualGoods.VirtualGood)SoomlaWpStore.data.StoreInfo.getVirtualItem(good.ItemId);
            if (vg is SoomlaWpStore.domain.virtualGoods.UpgradeVG)
            {
                uvg = SoomlaWpStore.data.StorageManager.getVirtualGoodsStorage().getCurrentUpgrade(vg);
            }

            if (uvg != null)
            {
                return((UpgradeVG)StoreInfo.GetItemByItemId(uvg.GetId()));
            }

            return(null);
        }
Example #16
0
        /** Unity-Editor Functions **/

        protected virtual void _removeUpgrades(VirtualGood good, bool notify)
        {
#if UNITY_EDITOR
            string itemId = good.ItemId;
            string key    = keyGoodUpgrade(itemId);

            PlayerPrefs.DeleteKey(key);

            if (notify)
            {
                JSONObject eventJSON = new JSONObject();
                eventJSON.AddField("itemId", good.ItemId);
                StoreEvents.Instance.onGoodUpgrade(eventJSON.print());
            }
#endif
        }
		protected override UpgradeVG _getCurrentUpgrade(VirtualGood good) {
			string upgradeVGItemId;
			AndroidJNI.PushLocalFrame(100);
			using(AndroidJavaClass jniStorageManager = new AndroidJavaClass("com.soomla.store.data.StorageManager")) {
				using(AndroidJavaObject jniVGStorage = jniStorageManager.CallStatic<AndroidJavaObject>("getVirtualGoodsStorage")) {
					upgradeVGItemId = jniVGStorage.Call<string>("getCurrentUpgrade", good.ItemId);
				}
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);

			if (!string.IsNullOrEmpty(upgradeVGItemId)) {
				return (UpgradeVG) StoreInfo.GetItemByItemId(upgradeVGItemId);
			}

			return null;
		}
        protected override UpgradeVG _getCurrentUpgrade(VirtualGood good)
        {
            string upgradeVGItemId = null;

            SoomlaWpStore.domain.virtualGoods.VirtualGood vg = (SoomlaWpStore.domain.virtualGoods.VirtualGood)SoomlaWpStore.data.StoreInfo.getVirtualItem(good.ItemId);
            if (vg is SoomlaWpStore.domain.virtualGoods.UpgradeVG)
            {
                upgradeVGItemId = SoomlaWpStore.data.StorageManager.getVirtualGoodsStorage().getCurrentUpgrade(vg).getItemId();
            }

            if (!string.IsNullOrEmpty(upgradeVGItemId))
            {
                return((UpgradeVG)StoreInfo.GetItemByItemId(upgradeVGItemId));
            }

            return(null);
        }
Example #19
0
        public static void onGoodBalanceChanged(GoodBalanceChangedEvent _Event, bool alsoPush)
        {
            SoomlaWpStore.domain.virtualGoods.VirtualGood good = _Event.GetGood();
            int balance     = _Event.GetBalance();
            int amountAdded = _Event.GetAmountAdded();

            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGoodBalanceChanged:" + good.getItemId() + " " + balance.ToString() + " " + amountAdded.ToString());

            VirtualGood vg = (VirtualGood)StoreInfo.GetItemByItemId(good.getItemId());

            StoreInventory.RefreshOnGoodBalanceChanged(vg, balance, amountAdded);
            StoreEvents.OnGoodBalanceChanged(vg, balance, amountAdded);

            if (alsoPush)
            {
                sep.PushEventOnGoodBalanceChanged(_Event);
            }
        }
Example #20
0
        /// <summary>
        /// Assigns the current upgrade to the associated <code>VirtualGood</code> (mGood).
        /// </summary>
        /// <param name="amount">NOT USED HERE!</param>
        /// <param name="notify">notify of change in user's balance of current virtual item.</param>
        public override int Give(int amount, bool notify)
        {
            SoomlaUtils.LogDebug(TAG, "Assigning " + Name + " to: " + GoodItemId);

            VirtualGood good = null;

            try {
                good = (VirtualGood)StoreInfo.GetItemByItemId(GoodItemId);
            } catch (VirtualItemNotFoundException) {
                SoomlaUtils.LogError(TAG, "VirtualGood with itemId: " + GoodItemId +
                                     " doesn't exist! Can't upgrade.");
                return(0);
            }

            VirtualGoodsStorage.AssignCurrentUpgrade(good, this, notify);

            return(base.Give(amount, notify));
        }
Example #21
0
        protected override UpgradeVG _getCurrentUpgrade(VirtualGood good)
        {
            string upgradeVGItemId;

            AndroidJNI.PushLocalFrame(100);
            using (AndroidJavaClass jniStorageManager = new AndroidJavaClass("com.soomla.store.data.StorageManager")) {
                using (AndroidJavaObject jniVGStorage = jniStorageManager.CallStatic <AndroidJavaObject>("getVirtualGoodsStorage")) {
                    upgradeVGItemId = jniVGStorage.Call <string>("getCurrentUpgrade", good.ItemId);
                }
            }
            AndroidJNI.PopLocalFrame(IntPtr.Zero);

            if (!string.IsNullOrEmpty(upgradeVGItemId))
            {
                return((UpgradeVG)StoreInfo.GetItemByItemId(upgradeVGItemId));
            }

            return(null);
        }
Example #22
0
        /// <summary>
        /// Determines if the user is in a state that allows him/her to buy an <code>UpgradeVG</code>
        ///	This method enforces allowing/rejecting of upgrades here so users won't buy them when
        /// they are not supposed to.
        /// If you want to give your users free upgrades, use the <code>give</code> function.
        /// </summary>
        /// <returns><c>true</c>, if can buy, <c>false</c> otherwise.</returns>
        protected override bool canBuy()
        {
            VirtualGood good = null;

            try {
                good = (VirtualGood)StoreInfo.GetItemByItemId(GoodItemId);
            } catch (VirtualItemNotFoundException) {
                SoomlaUtils.LogError(TAG, "VirtualGood with itemId: " + GoodItemId +
                                     " doesn't exist! Returning NO (can't buy).");
                return(false);
            }

            UpgradeVG upgradeVG = VirtualGoodsStorage.GetCurrentUpgrade(good);

            return(((upgradeVG == null && string.IsNullOrEmpty(PrevItemId)) ||
                    (upgradeVG != null && ((upgradeVG.NextItemId == this.ItemId) ||
                                           (upgradeVG.PrevItemId == this.ItemId)))) &&
                   base.canBuy());
        }
Example #23
0
        public static void onGoodUpgrade(GoodUpgradeEvent _Event, bool alsoPush)
        {
            SoomlaWpStore.domain.virtualGoods.VirtualGood good      = _Event.GetGood();
            SoomlaWpStore.domain.virtualGoods.UpgradeVG   upgradeVG = _Event.GetUpgradeVG();
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGoodUpgrade:" + good.getItemId() + " " + upgradeVG.getItemId());

            VirtualGood vg  = (VirtualGood)StoreInfo.GetItemByItemId(good.getItemId());
            UpgradeVG   vgu = null;

            if (upgradeVG != null)
            {
                vgu = (UpgradeVG)StoreInfo.GetItemByItemId(upgradeVG.getItemId());
            }
            StoreInventory.RefreshOnGoodUpgrade(vg, vgu);
            StoreEvents.OnGoodUpgrade(vg, vgu);

            if (alsoPush)
            {
                sep.PushEventOnGoodUpgrade(_Event);
            }
        }
Example #24
0
        public void onGoodBalanceChanged(string message, bool alsoPush)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGoodBalanceChanged:" + message);

            JSONObject eventJSON = new JSONObject(message);

            VirtualGood vg          = (VirtualGood)StoreInfo.GetItemByItemId(eventJSON["itemId"].str);
            int         balance     = (int)eventJSON["balance"].n;
            int         amountAdded = (int)eventJSON["amountAdded"].n;

            StoreInventory.RefreshOnGoodBalanceChanged(vg, balance, amountAdded);

            StoreEvents.OnGoodBalanceChanged(vg, balance, amountAdded);

            if (alsoPush)
            {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
                sep.PushEventOnGoodBalanceChanged(vg, balance, amountAdded);
#endif
            }
        }
Example #25
0
        /** A set of private functions to refresh the local inventory whenever there are changes on runtime. **/

        public static void RefreshOnGoodUpgrade(VirtualGood vg, UpgradeVG uvg)
        {
            if (uvg == null)
            {
                localUpgrades.Remove(vg.ItemId);
            }
            else
            {
                int          upgradeLevel = GetGoodUpgradeLevel(vg.ItemId);
                LocalUpgrade upgrade;
                if (localUpgrades.TryGetValue(vg.ItemId, out upgrade))
                {
                    upgrade.itemId = uvg.ItemId;
                    upgrade.level  = upgradeLevel;
                }
                else
                {
                    localUpgrades.Add(vg.ItemId, new LocalUpgrade {
                        itemId = uvg.ItemId, level = upgradeLevel
                    });
                }
            }
        }
Example #26
0
        protected virtual void _assignCurrentUpgrade(VirtualGood good, UpgradeVG upgradeVG, bool notify)
        {
#if UNITY_EDITOR
            UpgradeVG upgrade = GetCurrentUpgrade(good);
            if (upgrade != null && upgrade.ItemId == upgradeVG.ItemId)
            {
                return;
            }

            string itemId   = good.ItemId;
            string key      = keyGoodUpgrade(itemId);
            string upItemId = upgradeVG.ItemId;

            PlayerPrefs.SetString(key, upItemId);

            if (notify)
            {
                var eventJSON = new JSONObject();
                eventJSON.AddField("itemId", good.ItemId);
                eventJSON.AddField("upgradeItemId", upgradeVG.ItemId);
                StoreEvents.Instance.onGoodUpgrade(eventJSON.print());
            }
#endif
        }
		protected override void _assignCurrentUpgrade(VirtualGood good, UpgradeVG upgradeVG, bool notify) {
			int err = vgStorage_AssignCurrentUpgrade(good.ItemId, upgradeVG.ItemId, notify);
			IOS_ErrorCodes.CheckAndThrowException(err);
		}
Example #28
0
		public GoodBalanceChangedEvent (VirtualGood item, int balance, int amountAdded) : this(item, balance, amountAdded, null)
		{

		}
		protected override void _removeUpgrades(VirtualGood good, bool notify) {
			int err = vgStorage_RemoveUpgrades(good.ItemId, notify);
			IOS_ErrorCodes.CheckAndThrowException(err);
		}
Example #30
0
			public void PushEventOnGoodBalanceChanged(VirtualGood good, int balance, int amountAdded) {
				var eventJSON = new JSONObject();
				eventJSON.AddField("itemId", good.ItemId);
				eventJSON.AddField("balance", balance);
				eventJSON.AddField("amountAdded", amountAdded);

				_pushEventGoodBalanceChanged(eventJSON.print());
			}
    private void UpdateItemView(VirtualGood item)
    {
        var virtualStoreItemView =
            FindObjectsOfType<VirtualStoreItemView>()
            .SingleOrDefault(v => v.Item != null && v.Item.ItemId == item.ItemId);

        if (virtualStoreItemView != null)
        {
            virtualStoreItemView.Item = item;
        }
    }
		/// <summary>
		/// Removes any upgrade associated with the given <code>VirtualGood</code>.
		/// </summary>
		/// <param name="good">VirtualGood to remove upgrade from.</param>
		/// <param name="notify">true will also post event.</param>
		public static void RemoveUpgrades(VirtualGood good, bool notify){
			SoomlaUtils.LogDebug(TAG, "Removing upgrade information from virtual good: "
			                     + good.ItemId);
			
			instance._removeUpgrades(good, notify);
		}
Example #33
0
 /// <summary>
 /// Removes any upgrade associated with the given <code>VirtualGood</code>.
 /// </summary>
 /// <param name="good">VirtualGood to remove upgrade from.</param>
 public static void RemoveUpgrades(VirtualGood good)
 {
     RemoveUpgrades(good, true);
 }
		/** Unity-Editor Functions **/

		protected virtual void _removeUpgrades(VirtualGood good, bool notify) {
#if UNITY_EDITOR
			string itemId = good.ItemId;
			string key = keyGoodUpgrade(itemId);

			PlayerPrefs.DeleteKey(key);
			
			if (notify) {
				JSONObject eventJSON = new JSONObject();
				eventJSON.AddField("itemId", good.ItemId);
				StoreEvents.Instance.onGoodUpgrade(eventJSON.print());
			}
#endif
		}
		protected virtual UpgradeVG _getCurrentUpgrade(VirtualGood good) {
#if UNITY_EDITOR
			string itemId = good.ItemId;
			string key = keyGoodUpgrade(itemId);
			
			string upItemId = PlayerPrefs.GetString(key);
			
			if (string.IsNullOrEmpty(upItemId)) {
				SoomlaUtils.LogDebug(TAG, "You tried to fetch the current upgrade of " + good.ItemId
				                     + " but there's no upgrade for it.");
				return null;
			}
			
			try {
				return (UpgradeVG) StoreInfo.GetItemByItemId(upItemId);
			} catch (VirtualItemNotFoundException) {
				SoomlaUtils.LogError(TAG,
				                     "The current upgrade's itemId from the DB is not found in StoreInfo.");
			} catch (InvalidCastException) {
				SoomlaUtils.LogError(TAG,
				                     "The current upgrade's itemId from the DB is not an UpgradeVG.");
			}
			return null;
#else			
			return null;
#endif
		}
Example #36
0
 /** A set of private functions to refresh the local inventory whenever there are changes on runtime. **/
 public static void RefreshOnGoodUpgrade(VirtualGood vg, UpgradeVG uvg)
 {
     if (uvg == null) {
         localUpgrades.Remove(vg.ItemId);
     } else {
         int upgradeLevel = GetGoodUpgradeLevel(vg.ItemId);
         LocalUpgrade upgrade;
         if (localUpgrades.TryGetValue(vg.ItemId, out upgrade)) {
             upgrade.itemId = uvg.ItemId;
             upgrade.level = upgradeLevel;
         } else {
             localUpgrades.Add(vg.ItemId, new LocalUpgrade { itemId = uvg.ItemId, level = upgradeLevel });
         }
     }
 }
Example #37
0
 /// <summary>
 /// Handles a good upgraded event.
 /// </summary>
 /// <param name="good">Virtual good that is being upgraded.</param>
 /// <param name="currentUpgrade">The current upgrade that the given virtual
 /// good is being upgraded to.</param>
 public void onGoodUpgrade(VirtualGood good, UpgradeVG currentUpgrade)
 {
 }
Example #38
0
			public void PushEventOnGoodUpgrade(VirtualGood good, UpgradeVG upgrade) {
				var eventJSON = new JSONObject();
				eventJSON.AddField("itemId", good.ItemId);
				eventJSON.AddField("upgradeItemId", (upgrade==null ? null : upgrade.ItemId));

				_pushEventGoodUpgrade(eventJSON.print());
			}
Example #39
0
        /// <summary>
        /// Retrieves the current upgrade for the given virtual good.
        /// </summary>
        /// <param name="good">the virtual good to retrieve upgrade for.</param>
        /// <return>the current upgrade for the given virtual good.</return>
        public static UpgradeVG GetCurrentUpgrade(VirtualGood good)
        {
            SoomlaUtils.LogDebug(TAG, "Fetching upgrade to virtual good: " + good.ItemId);

            return(instance._getCurrentUpgrade(good));
        }
		/// <summary>
		/// Assigns a specific upgrade to the given virtual good.
		/// </summary>
		/// <param name="good">the virtual good to upgrade.</param>
		/// <param name="upgradeVG">the upgrade to assign.</param>
		/// <param name="notify">true will also post event.</param>
		public static void AssignCurrentUpgrade(VirtualGood good, UpgradeVG upgradeVG, bool notify){
			SoomlaUtils.LogDebug(TAG, "Assigning upgrade " + upgradeVG.ItemId + " to virtual good: "
			                     + good.ItemId);

			instance._assignCurrentUpgrade(good, upgradeVG, notify);
		}
Example #41
0
        protected override void _assignCurrentUpgrade(VirtualGood good, UpgradeVG upgradeVG, bool notify)
        {
            int err = vgStorage_AssignCurrentUpgrade(good.ItemId, upgradeVG.ItemId, notify);

            IOS_ErrorCodes.CheckAndThrowException(err);
        }
Example #42
0
 private void OnGoodUpgrade(VirtualGood good, UpgradeVG currentUpgrade)
 {
     Debug.Log(string.Format("GNOME: GoodUpgrade - ItemId: {0}", good.ItemId));
 }
Example #43
0
 public static void RefreshOnGoodBalanceChanged(VirtualGood good, int balance, int amountAdded)
 {
     UpdateLocalBalance(good.ItemId, balance);
 }
Example #44
0
 /// <summary>
 /// Handles a good balance changed event.
 /// </summary>
 /// <param name="good">Virtual good whose balance has changed.</param>
 /// <param name="balance">Balance.</param>
 /// <param name="amountAdded">Amount added.</param>
 public void onGoodBalanceChanged(VirtualGood good, int balance, int amountAdded)
 {
 }
		/// <summary>
		/// Retrieves the current upgrade for the given virtual good.
		/// </summary>
		/// <param name="good">the virtual good to retrieve upgrade for.</param>
		/// <return>the current upgrade for the given virtual good.</return>
		public static UpgradeVG GetCurrentUpgrade(VirtualGood good){
			SoomlaUtils.LogDebug(TAG, "Fetching upgrade to virtual good: " + good.ItemId);
			
			return instance._getCurrentUpgrade(good);
		}
Example #46
0
 protected override void _assignCurrentUpgrade(VirtualGood good, UpgradeVG upgradeVG, bool notify)
 {
     SoomlaWpStore.domain.virtualGoods.VirtualGood vg  = (SoomlaWpStore.domain.virtualGoods.VirtualGood)SoomlaWpStore.data.StoreInfo.getVirtualItem(good.ItemId);
     SoomlaWpStore.domain.virtualGoods.UpgradeVG   uvg = (SoomlaWpStore.domain.virtualGoods.UpgradeVG)SoomlaWpStore.data.StoreInfo.getVirtualItem(upgradeVG.ItemId);
     SoomlaWpStore.data.StorageManager.getVirtualGoodsStorage().assignCurrentUpgrade(vg, uvg, notify);
 }
		protected virtual void _assignCurrentUpgrade(VirtualGood good, UpgradeVG upgradeVG, bool notify) {
#if UNITY_EDITOR
			UpgradeVG upgrade = GetCurrentUpgrade(good);
			if (upgrade != null && upgrade.ItemId == upgradeVG.ItemId) {
				return;
			}
			
			string itemId = good.ItemId;
			string key = keyGoodUpgrade(itemId);
			string upItemId = upgradeVG.ItemId;

			PlayerPrefs.SetString(key, upItemId);
			
			if (notify) {
				var eventJSON = new JSONObject();
				eventJSON.AddField("itemId", good.ItemId);
				eventJSON.AddField("upgradeItemId", upgradeVG.ItemId);
				StoreEvents.Instance.onGoodUpgrade(eventJSON.print());
			}
#endif
		}
Example #48
0
		public GoodBalanceChangedEvent (VirtualGood item, int balance, int amountAdded, Object sender) : base(sender)
		{
			mItem = item;
			mBalance = balance;
			mAmountAdded = amountAdded;
		}
		/// <summary>
		/// Removes any upgrade associated with the given <code>VirtualGood</code>.
		/// </summary>
		/// <param name="good">VirtualGood to remove upgrade from.</param>
		public static void RemoveUpgrades(VirtualGood good){
			RemoveUpgrades(good, true);
		}
Example #50
0
        protected override void _removeUpgrades(VirtualGood good, bool notify)
        {
            int err = vgStorage_RemoveUpgrades(good.ItemId, notify);

            IOS_ErrorCodes.CheckAndThrowException(err);
        }
		/// <summary>
		/// Assigns a specific upgrade to the given virtual good.
		/// </summary>
		/// <param name="good">the virtual good to upgrade.</param>
		/// <param name="upgradeVG">the upgrade to assign.</param>
		public static void AssignCurrentUpgrade(VirtualGood good, UpgradeVG upgradeVG){
			AssignCurrentUpgrade(good, upgradeVG, true);
		}
Example #52
0
 /// <summary>
 /// Handles a good balance changed event.
 /// </summary>
 /// <param name="good">Virtual good whose balance has changed.</param>
 /// <param name="balance">Balance.</param>
 /// <param name="amountAdded">Amount added.</param>
 public void onGoodBalanceChanged(VirtualGood good, int balance, int amountAdded)
 {
 }
Example #53
0
 protected override void _removeUpgrades(VirtualGood good, bool notify)
 {
     SoomlaWpStore.domain.virtualGoods.VirtualGood vg = (SoomlaWpStore.domain.virtualGoods.VirtualGood)SoomlaWpStore.data.StoreInfo.getVirtualItem(good.ItemId);
     SoomlaWpStore.data.StorageManager.getVirtualGoodsStorage().removeUpgrades(vg, notify);
 }
Example #54
0
 private void OnGoodBalanceChanged(VirtualGood vg, int balance, int amountAdded)
 {
     Debug.Log(string.Format("GNOME: VirtualGoodBalanceChanged - Id: {0}, Balance: {1}", vg.ItemId, balance));
     GoodsBalances[vg.ItemId] = balance;
 }
 protected override void _removeUpgrades(VirtualGood good, bool notify)
 {
     SoomlaWpStore.domain.virtualGoods.VirtualGood vg = (SoomlaWpStore.domain.virtualGoods.VirtualGood)SoomlaWpStore.data.StoreInfo.getVirtualItem(good.ItemId);
     SoomlaWpStore.data.StorageManager.getVirtualGoodsStorage().removeUpgrades(vg, notify);
 }
Example #56
0
 /// <summary>
 /// Handles a good upgraded event.
 /// </summary>
 /// <param name="good">Virtual good that is being upgraded.</param>
 /// <param name="currentUpgrade">The current upgrade that the given virtual
 /// good is being upgraded to.</param>
 public void onGoodUpgrade(VirtualGood good, UpgradeVG currentUpgrade)
 {
 }
Example #57
0
 // updating counters, when balance of goods changed
 void onGoodBalanceChanged(VirtualGood good, int balance, int amountAdded)
 {
     ItemCounter.RefreshAll ();
 }
Example #58
0
 /// <summary>
 /// Assigns a specific upgrade to the given virtual good.
 /// </summary>
 /// <param name="good">the virtual good to upgrade.</param>
 /// <param name="upgradeVG">the upgrade to assign.</param>
 public static void AssignCurrentUpgrade(VirtualGood good, UpgradeVG upgradeVG)
 {
     AssignCurrentUpgrade(good, upgradeVG, true);
 }
Example #59
0
 public static void RefreshOnGoodBalanceChanged(VirtualGood good, int balance, int amountAdded)
 {
     UpdateLocalBalance(good.ItemId, balance);
 }
 protected override void _assignCurrentUpgrade(VirtualGood good, UpgradeVG upgradeVG, bool notify)
 {
     SoomlaWpStore.domain.virtualGoods.VirtualGood vg = (SoomlaWpStore.domain.virtualGoods.VirtualGood)SoomlaWpStore.data.StoreInfo.getVirtualItem(good.ItemId);
     SoomlaWpStore.domain.virtualGoods.UpgradeVG uvg = (SoomlaWpStore.domain.virtualGoods.UpgradeVG)SoomlaWpStore.data.StoreInfo.getVirtualItem(upgradeVG.ItemId);
     SoomlaWpStore.data.StorageManager.getVirtualGoodsStorage().assignCurrentUpgrade(vg, uvg, notify);
 }