public void onGoodUpgrade(VirtualGood good, UpgradeVG currentUpgrade) { // good - the virtual good that was just upgraded // currentUpgrade - the upgrade after the operation completed Debug.Log("onGoodUpgrade"); }
public VirtualGood[] GetUpgradeableVirtualGoods() { UpgradeVG[] goods = new UpgradeVG[Map_UpgradeableVirtualGoods.Count]; Map_UpgradeableVirtualGoods.Values.CopyTo(goods, 0); return(goods); }
public void PostGoodUpgradeEvent(VirtualGood good, UpgradeVG upgradeVG) { LogEvent("GoodUpgrade"); if (OnGoodUpgradeEvent != null) { OnGoodUpgradeEvent(good, upgradeVG); } }
/** * Upgrades the good with the given <code>upgradeItemId</code> for FREE (you are GIVING him/her * the upgrade). In case that the good is not an upgradeable item, an error message will be * produced. <code>forceUpgrade()</code> is different than <code>upgradeVirtualGood()<code> * because <code>forceUpgrade()</code> is a FREE upgrade. * * @param upgradeItemId id of the virtual good who we want to force an upgrade upon * @throws VirtualItemNotFoundException */ public static void forceUpgrade(String upgradeItemId) { try { UpgradeVG upgradeVG = (UpgradeVG)StoreInfo.getVirtualItem(upgradeItemId); upgradeVG.give(1); } catch (InvalidCastException ex) { SoomlaUtils.LogError("SOOMLA StoreInventory", "The given itemId was of a non UpgradeVG VirtualItem. Can't force it." + " " + ex.Message); } }
public void onGoodUpgrade(string message) { StoreUtils.LogDebug(TAG, "SOOMLA/UNITY onGoodUpgrade:" + message); string[] vars = Regex.Split(message, "#SOOM#"); VirtualGood vg = (VirtualGood)StoreInfo.GetItemByItemId(vars[0]); UpgradeVG vgu = (UpgradeVG)StoreInfo.GetItemByItemId(vars[1]); Events.OnGoodUpgrade(vg, vgu); }
/** * Retrieves the itemId of the current upgrade of the virtual good with the given * <code>goodItemId</code>. * * @param goodItemId id of the virtual good whose upgrade id we want to know * @return upgrade id if exists, or empty string otherwise * @throws VirtualItemNotFoundException */ public static String getGoodCurrentUpgrade(String goodItemId) { VirtualGood good = (VirtualGood)StoreInfo.getVirtualItem(goodItemId); UpgradeVG upgradeVG = StorageManager.getVirtualGoodsStorage().getCurrentUpgrade(good); if (upgradeVG == null) { return(""); } return(upgradeVG.getItemId()); }
private void processUpgradeVirtualGood(Dictionary <string, string> atts) { string name = atts["name"]; UpgradeVG upgradeVG = new UpgradeVG(atts["localID"], atts["prevItem"], atts["nextItem"], name, atts["desc"], atts["localID"], new PurchaseWithVirtualItem(atts["localID"], Convert.ToInt32(atts["currencyCost"])) ); upgradeVG.imageIconPath = atts["spriteIcon"]; ourIAPAssets.Map_VirtualGoods[name] = upgradeVG; }
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] + ""; } } }
/** * Retrieves the upgrade level of the virtual good with the given <code>goodItemId</code>. * * 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. <code>SingleUseVG</code> for "strength" * 2. <code>UpgradeVG</code> for strength 'level 1'. * 3. <code>UpgradeVG</code> for strength 'level 2'. * 4. <code>UpgradeVG</code> for strength 'level 3'. * In the example, this function will retrieve the upgrade level for "strength" (1, 2, or 3). * * @param goodItemId id of the virtual good whose upgrade level we want to know * @return upgrade level of the good with the given id * @throws VirtualItemNotFoundException */ public static int getGoodUpgradeLevel(String goodItemId) { VirtualGood good = (VirtualGood)StoreInfo.getVirtualItem(goodItemId); UpgradeVG upgradeVG = StorageManager.getVirtualGoodsStorage().getCurrentUpgrade(good); if (upgradeVG == null) { return(0); //no upgrade } UpgradeVG first = StoreInfo.getGoodFirstUpgrade(goodItemId); int level = 1; while (!first.Equal(upgradeVG)) { first = (UpgradeVG)StoreInfo.getVirtualItem(first.getNextItemId()); level++; } return(level); }
/** * Assigns a specific upgrade to the given virtual good. * * @param good the VirtualGood to upgrade * @param upgradeVG the upgrade to assign * @param notify if true post event to bus */ public void assignCurrentUpgrade(VirtualGood good, UpgradeVG upgradeVG, bool notify) { if (getCurrentUpgrade(good) != null && getCurrentUpgrade(good).getItemId() == upgradeVG.getItemId()) { return; } SoomlaUtils.LogDebug(mTag, "Assigning upgrade " + upgradeVG.getName() + " to virtual good: " + good.getName()); String itemId = good.getItemId(); String key = keyGoodUpgrade(itemId); String upItemId = upgradeVG.getItemId(); KeyValueStorage.SetValue(key, upItemId); if (notify) { BusProvider.Instance.Post(new GoodUpgradeEvent(good, upgradeVG)); } }
/** * Upgrades the virtual good with the given <code>goodItemId</code> 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, or in * other words, <code>buy()</code>s the next upgrade. 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, or in other words, <code>buy()</code>s the first upgrade in the series. * * @param goodItemId the id of the virtual good to be upgraded * @throws VirtualItemNotFoundException * @throws InsufficientFundsException */ public static void upgradeVirtualGood(String goodItemId) { VirtualGood good = (VirtualGood)StoreInfo.getVirtualItem(goodItemId); UpgradeVG upgradeVG = StorageManager.getVirtualGoodsStorage().getCurrentUpgrade(good); if (upgradeVG != null) { String nextItemId = upgradeVG.getNextItemId(); if (String.IsNullOrEmpty(nextItemId)) { return; } UpgradeVG vgu = (UpgradeVG)StoreInfo.getVirtualItem(nextItemId); vgu.buy(""); } else { UpgradeVG first = StoreInfo.getGoodFirstUpgrade(goodItemId); if (first != null) { first.buy(""); } } }
private void GoodUpgrade(VirtualGood arg1, UpgradeVG arg2) { Debug.Log(arg1); }
private static void fromJSONObject(JSONObject storeJSON) { VirtualItems = new Dictionary<string, VirtualItem> (); PurchasableItems = new Dictionary<string, PurchasableVirtualItem> (); GoodsCategories = new Dictionary<string, VirtualCategory> (); GoodsUpgrades = new Dictionary<string, List<UpgradeVG>> (); CurrencyPacks = new List<VirtualCurrencyPack> (); Goods = new List<VirtualGood> (); Categories = new List<VirtualCategory> (); Currencies = new List<VirtualCurrency> (); if (storeJSON.HasField (StoreJSONConsts.STORE_CURRENCIES)) { List<JSONObject> objs = storeJSON [StoreJSONConsts.STORE_CURRENCIES].list; foreach (JSONObject o in objs) { VirtualCurrency c = new VirtualCurrency (o); Currencies.Add (c); } } if (storeJSON.HasField (StoreJSONConsts.STORE_CURRENCYPACKS)) { List<JSONObject> objs = storeJSON [StoreJSONConsts.STORE_CURRENCYPACKS].list; foreach (JSONObject o in objs) { VirtualCurrencyPack c = new VirtualCurrencyPack (o); CurrencyPacks.Add (c); } } if (storeJSON.HasField (StoreJSONConsts.STORE_GOODS)) { JSONObject goods = storeJSON [StoreJSONConsts.STORE_GOODS]; if (goods.HasField (StoreJSONConsts.STORE_GOODS_SU)) { List<JSONObject> suGoods = goods [StoreJSONConsts.STORE_GOODS_SU].list; foreach (JSONObject o in suGoods) { var c = new SingleUseVG (o); Goods.Add (c); } } if (goods.HasField (StoreJSONConsts.STORE_GOODS_LT)) { List<JSONObject> ltGoods = goods [StoreJSONConsts.STORE_GOODS_LT].list; foreach (JSONObject o in ltGoods) { LifetimeVG c = new LifetimeVG (o); Goods.Add (c); } } if (goods.HasField (StoreJSONConsts.STORE_GOODS_EQ)) { List<JSONObject> eqGoods = goods [StoreJSONConsts.STORE_GOODS_EQ].list; foreach (JSONObject o in eqGoods) { EquippableVG c = new EquippableVG (o); Goods.Add (c); } } if (goods.HasField (StoreJSONConsts.STORE_GOODS_PA)) { List<JSONObject> paGoods = goods [StoreJSONConsts.STORE_GOODS_PA].list; foreach (JSONObject o in paGoods) { SingleUsePackVG c = new SingleUsePackVG (o); Goods.Add (c); } } if (goods.HasField (StoreJSONConsts.STORE_GOODS_UP)) { List<JSONObject> upGoods = goods [StoreJSONConsts.STORE_GOODS_UP].list; foreach (JSONObject o in upGoods) { UpgradeVG c = new UpgradeVG (o); Goods.Add (c); } } } if (storeJSON.HasField(StoreJSONConsts.STORE_CATEGORIES)) { List<JSONObject> categories = storeJSON[StoreJSONConsts.STORE_CATEGORIES].list; foreach (JSONObject o in categories){ VirtualCategory category = new VirtualCategory(o); Categories.Add(category); } } updateAggregatedLists (); }
public GoodUpgradeEvent(VirtualGood good, UpgradeVG upgradeVG) : this(good, upgradeVG, null) { }
public void Prepare(int version, String JsonStoreAssets) { try { mVersion = version; JObject JObject = JObject.Parse(JsonStoreAssets); JArray virtualCurrencies = JObject.Value <JArray>(StoreJSONConsts.STORE_CURRENCIES); mVirtualCurrency = new VirtualCurrency[virtualCurrencies.Count]; for (int i = 0; i < virtualCurrencies.Count; i++) { JObject o = virtualCurrencies.Value <JObject>(i); VirtualCurrency c = new VirtualCurrency(o); mVirtualCurrency[i] = c; } JArray currencyPacks = JObject.Value <JArray>(StoreJSONConsts.STORE_CURRENCYPACKS); mVirtualCurrencyPack = new VirtualCurrencyPack[currencyPacks.Count]; for (int i = 0; i < currencyPacks.Count; i++) { JObject o = currencyPacks.Value <JObject>(i); VirtualCurrencyPack pack = new VirtualCurrencyPack(o); mVirtualCurrencyPack[i] = pack; } // The order in which VirtualGoods are created matters! // For example: VGU and VGP depend on other VGs JObject virtualGoods = JObject.Value <JObject>(StoreJSONConsts.STORE_GOODS); JArray suGoods = virtualGoods.Value <JArray>(StoreJSONConsts.STORE_GOODS_SU); JArray ltGoods = virtualGoods.Value <JArray>(StoreJSONConsts.STORE_GOODS_LT); JArray eqGoods = virtualGoods.Value <JArray>(StoreJSONConsts.STORE_GOODS_EQ); JArray upGoods = virtualGoods.Value <JArray>(StoreJSONConsts.STORE_GOODS_UP); JArray paGoods = virtualGoods.Value <JArray>(StoreJSONConsts.STORE_GOODS_PA); List <VirtualGood> goods = new List <VirtualGood>(); for (int i = 0; i < suGoods.Count; i++) { JObject o = suGoods.Value <JObject>(i); SingleUseVG g = new SingleUseVG(o); goods.Add(g); } for (int i = 0; i < ltGoods.Count; i++) { JObject o = ltGoods.Value <JObject>(i); LifetimeVG g = new LifetimeVG(o); goods.Add(g); } for (int i = 0; i < eqGoods.Count; i++) { JObject o = eqGoods.Value <JObject>(i); EquippableVG g = new EquippableVG(o); goods.Add(g); } for (int i = 0; i < paGoods.Count; i++) { JObject o = paGoods.Value <JObject>(i); SingleUsePackVG g = new SingleUsePackVG(o); goods.Add(g); } for (int i = 0; i < upGoods.Count; i++) { JObject o = upGoods.Value <JObject>(i); UpgradeVG g = new UpgradeVG(o); goods.Add(g); } mVirtualGood = new VirtualGood[goods.Count]; for (int i = 0; i < goods.Count; i++) { mVirtualGood[i] = goods[i]; } // categories depend on virtual goods. That's why the have to be initialized after! JArray virtualCategories = JObject.Value <JArray>(StoreJSONConsts.STORE_CATEGORIES); mVirtualCategory = new VirtualCategory[virtualCategories.Count]; for (int i = 0; i < virtualCategories.Count; i++) { JObject o = virtualCategories.Value <JObject>(i); VirtualCategory category = new VirtualCategory(o); mVirtualCategory[i] = category; } JArray nonConsumables = JObject.Value <JArray>(StoreJSONConsts.STORE_NONCONSUMABLES); mNonConsumableItem = new NonConsumableItem[nonConsumables.Count]; for (int i = 0; i < nonConsumables.Count; i++) { JObject o = nonConsumables.Value <JObject>(i); NonConsumableItem non = new NonConsumableItem(o); mNonConsumableItem[i] = non; } } catch (Exception ex) { SoomlaUtils.LogError(TAG, "An error occurred while trying to prepare storeAssets" + ex.Message); } }
public void onGoodUpgrade(VirtualGood good, UpgradeVG currentUpgrade) { //AndyUtils.LogDebug(TAG, "The current uprade of " + good.ItemId + " is " + currentUpgrade.ItemId); }
public GoodUpgradeEvent(VirtualGood good, UpgradeVG upgradeVG, object sender) : base(sender) { mGood = good; mUpgradeVG = upgradeVG; }
/// <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) { }
/** * Assigns a specific upgrade to the given virtual good. * * @param good the virtual good to upgrade * @param upgradeVG the upgrade to assign */ public void assignCurrentUpgrade(VirtualGood good, UpgradeVG upgradeVG) { assignCurrentUpgrade(good, upgradeVG, true); }
private void OnGoodUpgrade(VirtualGood good, UpgradeVG currentUpgrade) { Debug.Log(string.Format("GNOME: GoodUpgrade - ItemId: {0}", good.ItemId)); }
public void onGoodUpgrade(VirtualGood good, UpgradeVG currentUpgrade) { //AndyUtils.LogDebug(TAG, "The current uprade of " + good.ItemId + " is " + currentUpgrade.ItemId); }
/** Private functions **/ /** * Transforms given JObject to StoreInfo * * @param JObject * @throws JSONException */ private static void fromJObject(JObject JObject) { mVirtualItems = new Dictionary <String, VirtualItem>(); mPurchasableItems = new Dictionary <String, PurchasableVirtualItem>(); mGoodsCategories = new Dictionary <String, VirtualCategory>(); mGoodsUpgrades = new Dictionary <String, List <UpgradeVG> >(); mCurrencyPacks = new List <VirtualCurrencyPack>(); mGoods = new List <VirtualGood>(); mCategories = new List <VirtualCategory>(); mCurrencies = new List <VirtualCurrency>(); mNonConsumables = new List <NonConsumableItem>(); JToken value; if (JObject.TryGetValue(StoreJSONConsts.STORE_CURRENCIES, out value)) { JArray virtualCurrencies = JObject.Value <JArray>(StoreJSONConsts.STORE_CURRENCIES); for (int i = 0; i < virtualCurrencies.Count; i++) { JObject o = virtualCurrencies.Value <JObject>(i); VirtualCurrency c = new VirtualCurrency(o); mCurrencies.Add(c); mVirtualItems.Add(c.getItemId(), c); } } if (JObject.TryGetValue(StoreJSONConsts.STORE_CURRENCYPACKS, out value)) { JArray currencyPacks = JObject.Value <JArray>(StoreJSONConsts.STORE_CURRENCYPACKS); for (int i = 0; i < currencyPacks.Count; i++) { JObject o = currencyPacks.Value <JObject>(i); VirtualCurrencyPack pack = new VirtualCurrencyPack(o); mCurrencyPacks.Add(pack); mVirtualItems.Add(pack.getItemId(), pack); PurchaseType purchaseType = pack.GetPurchaseType(); if (purchaseType is PurchaseWithMarket) { mPurchasableItems.Add(((PurchaseWithMarket)purchaseType) .getMarketItem().getProductId(), pack); } } } // The order in which VirtualGoods are created matters! // For example: VGU and VGP depend on other VGs if (JObject.TryGetValue(StoreJSONConsts.STORE_GOODS, out value)) { JObject virtualGoods = JObject.Value <JObject>(StoreJSONConsts.STORE_GOODS); JToken valueVg; if (virtualGoods.TryGetValue(StoreJSONConsts.STORE_GOODS_SU, out valueVg)) { JArray suGoods = virtualGoods.Value <JArray>(StoreJSONConsts.STORE_GOODS_SU); for (int i = 0; i < suGoods.Count; i++) { JObject o = suGoods.Value <JObject>(i); SingleUseVG g = new SingleUseVG(o); addVG(g); } } if (virtualGoods.TryGetValue(StoreJSONConsts.STORE_GOODS_LT, out valueVg)) { JArray ltGoods = virtualGoods.Value <JArray>(StoreJSONConsts.STORE_GOODS_LT); for (int i = 0; i < ltGoods.Count; i++) { JObject o = ltGoods.Value <JObject>(i); LifetimeVG g = new LifetimeVG(o); addVG(g); } } if (virtualGoods.TryGetValue(StoreJSONConsts.STORE_GOODS_EQ, out valueVg)) { JArray eqGoods = virtualGoods.Value <JArray>(StoreJSONConsts.STORE_GOODS_EQ); for (int i = 0; i < eqGoods.Count; i++) { JObject o = eqGoods.Value <JObject>(i); EquippableVG g = new EquippableVG(o); addVG(g); } } if (virtualGoods.TryGetValue(StoreJSONConsts.STORE_GOODS_PA, out valueVg)) { JArray paGoods = virtualGoods.Value <JArray>(StoreJSONConsts.STORE_GOODS_PA); for (int i = 0; i < paGoods.Count; i++) { JObject o = paGoods.Value <JObject>(i); SingleUsePackVG g = new SingleUsePackVG(o); addVG(g); } } if (virtualGoods.TryGetValue(StoreJSONConsts.STORE_GOODS_UP, out valueVg)) { JArray upGoods = virtualGoods.Value <JArray>(StoreJSONConsts.STORE_GOODS_UP); for (int i = 0; i < upGoods.Count; i++) { JObject o = upGoods.Value <JObject>(i); UpgradeVG g = new UpgradeVG(o); addVG(g); List <UpgradeVG> upgrades = mGoodsUpgrades[g.getGoodItemId()]; if (upgrades == null) { upgrades = new List <UpgradeVG>(); mGoodsUpgrades.Add(g.getGoodItemId(), upgrades); } upgrades.Add(g); } } } // Categories depend on virtual goods. That's why the have to be initialized after! if (JObject.TryGetValue(StoreJSONConsts.STORE_CATEGORIES, out value)) { JArray virtualCategories = JObject.Value <JArray>(StoreJSONConsts.STORE_CATEGORIES); for (int i = 0; i < virtualCategories.Count; i++) { JObject o = virtualCategories.Value <JObject>(i); VirtualCategory category = new VirtualCategory(o); mCategories.Add(category); foreach (String goodItemId in category.getGoodsItemIds()) { mGoodsCategories.Add(goodItemId, category); } } } if (JObject.TryGetValue(StoreJSONConsts.STORE_NONCONSUMABLES, out value)) { JArray nonConsumables = JObject.Value <JArray>(StoreJSONConsts.STORE_NONCONSUMABLES); for (int i = 0; i < nonConsumables.Count; i++) { JObject o = nonConsumables.Value <JObject>(i); NonConsumableItem non = new NonConsumableItem(o); mNonConsumables.Add(non); mVirtualItems.Add(non.getItemId(), non); PurchaseType purchaseType = non.GetPurchaseType(); if (purchaseType is PurchaseWithMarket) { mPurchasableItems.Add(((PurchaseWithMarket)purchaseType) .getMarketItem().getProductId(), non); } } } }
/// <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) { }
/// <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) { messageText.text = "You Have Succesfully Upgraded \n " + currentUpgrade.Name; popUp.SetActive(true); }