/** * Helper function for <code>equip</code> and <code>unequip</code> functions. */ private void equipPriv(EquippableVG good, bool equip, bool notify) { SoomlaUtils.LogDebug(mTag, (!equip ? "unequipping " : "equipping ") + good.getName() + "."); String itemId = good.getItemId(); String key = keyGoodEquipped(itemId); if (equip) { KeyValueStorage.SetValue(key, ""); if (notify) { BusProvider.Instance.Post(new GoodEquippedEvent(good)); } } else { KeyValueStorage.DeleteKeyValue(key); if (notify) { BusProvider.Instance.Post(new GoodUnEquippedEvent(good)); } } }
private void UpdateGoodUnequip(EquippableVG good) { Button equipB = (Button)MainStackPanel.FindName(good.getItemId() + "equip"); equipB.Content = "equip"; equipB.Click += equipItem; equipB.Click -= unequipItem; }
/** * Checks if the given <code>EquippableVG</code> is currently equipped or not. * * @param good the <code>EquippableVG</code> to check the status for * @return true if the given good is equipped, false otherwise */ public bool isEquipped(EquippableVG good) { SoomlaUtils.LogDebug(mTag, "checking if virtual good with itemId: " + good.getItemId() + " is equipped."); String itemId = good.getItemId(); String key = keyGoodEquipped(itemId); String val = KeyValueStorage.GetValue(key); return val != null; }
public void Prepare(int version, String JsonStoreAssets) { try { SoomlaUtils.LogDebug(TAG,"Prepare :\n"+JsonStoreAssets); mVersion = version; JSONObject jSONObject = new JSONObject(JsonStoreAssets,-10); JSONObject virtualCurrencies = jSONObject[StoreJSONConsts.STORE_CURRENCIES]; mVirtualCurrency = new VirtualCurrency[virtualCurrencies.Count]; for (int i = 0; i < virtualCurrencies.Count; i++) { JSONObject o = virtualCurrencies[i]; VirtualCurrency c = new VirtualCurrency(o); mVirtualCurrency[i] = c; } JSONObject currencyPacks = jSONObject[StoreJSONConsts.STORE_CURRENCYPACKS]; mVirtualCurrencyPack = new VirtualCurrencyPack[currencyPacks.Count]; for (int i = 0; i < currencyPacks.Count; i++) { JSONObject o = currencyPacks[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 JSONObject virtualGoods = jSONObject[StoreJSONConsts.STORE_GOODS]; JSONObject suGoods = virtualGoods[StoreJSONConsts.STORE_GOODS_SU]; JSONObject ltGoods = virtualGoods[StoreJSONConsts.STORE_GOODS_LT]; JSONObject eqGoods = virtualGoods[StoreJSONConsts.STORE_GOODS_EQ]; JSONObject upGoods = virtualGoods[StoreJSONConsts.STORE_GOODS_UP]; JSONObject paGoods = virtualGoods[StoreJSONConsts.STORE_GOODS_PA]; List<VirtualGood> goods = new List<VirtualGood>(); for (int i = 0; i < suGoods.Count; i++) { JSONObject o = suGoods[i]; SingleUseVG g = new SingleUseVG(o); SoomlaUtils.LogDebug(TAG, "SingleUseVG " + g.getItemId()); goods.Add(g); } for (int i = 0; i < ltGoods.Count; i++) { JSONObject o = ltGoods[i]; LifetimeVG g = new LifetimeVG(o); SoomlaUtils.LogDebug(TAG, "LifetimeVG " + g.getItemId()); goods.Add(g); } for (int i = 0; i < eqGoods.Count; i++) { JSONObject o = eqGoods[i]; EquippableVG g = new EquippableVG(o); SoomlaUtils.LogDebug(TAG, "EquippableVG " + g.getItemId()); goods.Add(g); } for (int i = 0; i < paGoods.Count; i++) { JSONObject o = paGoods[i]; SingleUsePackVG g = new SingleUsePackVG(o); SoomlaUtils.LogDebug(TAG, "SingleUsePackVG " + g.getItemId()); goods.Add(g); } for (int i = 0; i < upGoods.Count; i++) { JSONObject o = upGoods[i]; UpgradeVG g = new UpgradeVG(o); SoomlaUtils.LogDebug(TAG, "UpgradeVG " + g.getItemId()); goods.Add(g); } mVirtualGood = new VirtualGood[goods.Count]; for(int i = 0; i < goods.Count; i++) { SoomlaUtils.LogDebug(TAG, "VirtualGood " + goods[i].getItemId()); mVirtualGood[i] = goods[i]; } // categories depend on virtual goods. That's why the have to be initialized after! JSONObject virtualCategories = jSONObject[StoreJSONConsts.STORE_CATEGORIES]; mVirtualCategory = new VirtualCategory[virtualCategories.Count]; for (int i = 0; i < virtualCategories.Count; i++) { JSONObject o = virtualCategories[i]; VirtualCategory category = new VirtualCategory(o); mVirtualCategory[i] = category; } /* JArray nonConsumables = JSONObject.Value<JArray>(StoreJSONConsts.STORE_NONCONSUMABLES); mNonConsumableItem = new NonConsumableItem[nonConsumables.Count]; for (int i = 0; i < nonConsumables.Count; i++) { JSONObject o = nonConsumables.Value<JSONObject>(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); } }