/** * Equips the current <code>EquippableVG</code>. * The equipping is done according to the equipping model ('GLOBAL', 'CATEGORY', or 'LOCAL'). * * @param notify if true post event to bus * @throws NotEnoughGoodsException */ public void equip(bool notify) { // only if the user has bought this EquippableVG, the EquippableVG is equipped. if (StorageManager.getVirtualGoodsStorage().getBalance(this) > 0) { if (mEquippingModel == EquippingModel.CATEGORY) { VirtualCategory category = null; try { category = StoreInfo.getCategory(getItemId()); } catch (VirtualItemNotFoundException e) { SoomlaUtils.LogError(TAG, "Tried to unequip all other category VirtualGoods but there was no " + "associated category. virtual good itemId: " + getItemId() + " " + e.Message); return; } foreach (String goodItemId in category.getGoodsItemIds()) { EquippableVG equippableVG = null; try { equippableVG = (EquippableVG)StoreInfo.getVirtualItem(goodItemId); if (equippableVG != null && equippableVG != this) { equippableVG.unequip(notify); } } catch (VirtualItemNotFoundException e) { SoomlaUtils.LogError(TAG, "On equip, couldn't find one of the itemIds " + "in the category. Continuing to the next one. itemId: " + goodItemId + " " + e.Message); } catch (InvalidCastException ex) { SoomlaUtils.LogDebug(TAG, "On equip, an error occurred. It's a debug " + "message b/c the VirtualGood may just not be an EquippableVG. " + "itemId: " + goodItemId + " " + ex.Message); } } } else if (mEquippingModel == EquippingModel.GLOBAL) { foreach (VirtualGood good in StoreInfo.getGoods()) { if (good != this && good is EquippableVG) { ((EquippableVG)good).unequip(notify); } } } StorageManager.getVirtualGoodsStorage().equip(this, notify); } else { throw new NotEnoughGoodsException(getItemId()); } }