Ejemplo n.º 1
0
    /**
     * Removes any upgrade associated with the given VirtualGood.
     *
     * @param good the virtual good to remove the upgrade from
     * @param notify if true post event to bus
     */
    public void removeUpgrades(VirtualGood good, bool notify) {
        SoomlaUtils.LogDebug(mTag, "Removing upgrade information from virtual good: " +
                good.getName());

        String itemId = good.getItemId();
        String key = keyGoodUpgrade(itemId);

        KeyValueStorage.DeleteKeyValue(key);

        if (notify) {
            BusProvider.Instance.Post(new GoodUpgradeEvent(good, null));
        }
    }
Ejemplo n.º 2
0
        /**
         * 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));
            }
        }
Ejemplo n.º 3
0
        /**
         * Retrieves the current upgrade for the given virtual good.
         *
         * @param good the virtual good to retrieve upgrade for
         * @return the current upgrade for the given virtual good
         */
        public UpgradeVG getCurrentUpgrade(VirtualGood good)
        {
            SoomlaUtils.LogDebug(mTag, "Fetching upgrade to virtual good: " + good.getName());

            String itemId = good.getItemId();
            String key = keyGoodUpgrade(itemId);

            String upItemId = KeyValueStorage.GetValue(key);

            if (upItemId == null) {
            SoomlaUtils.LogDebug(mTag, "You tried to fetch the current upgrade of " + good.getName()
                    + " but there's not upgrade to it.");
            return null;
            }

            try {
            return (UpgradeVG) StoreInfo.getVirtualItem(upItemId);
            } catch (VirtualItemNotFoundException e) {
            SoomlaUtils.LogError(mTag,
                    "The current upgrade's itemId from the DB is not found in StoreInfo." + " " + e.Message);
            } catch (InvalidCastException e) {
            SoomlaUtils.LogError(mTag,
                    "The current upgrade's itemId from the DB is not an UpgradeVG." + " " + e.Message);
            }

            return null;
        }
Ejemplo n.º 4
0
    /**
     * Adds the given virtual good to <code>StoreInfo</code>'s <code>mGoods</code>,
     * <code>mVirtualItems</code>, and if the good has purchase type <code>PurchaseWithMarket</code>
     * then it is also added to <code>mPurchasableItems</code>.
     *
     * @param g virtual good to be added
     */
    private static void addVG(VirtualGood g) {
        mGoods.Add(g);

        mVirtualItems.Add(g.getItemId(), g);

        PurchaseType purchaseType = g.GetPurchaseType();
        if (purchaseType is PurchaseWithMarket) {
            mPurchasableItems.Add(((PurchaseWithMarket) purchaseType)
                    .getMarketItem().getProductId(), g);
        }
    }
Ejemplo n.º 5
0
 private void UpdateGoodBalance(VirtualGood good, int balance, int amountAdded)
 {
     TextBlock balanceText = (TextBlock)MainStackPanel.FindName(good.getItemId() + "balance");
     balanceText.Text = "balance: " + balance.ToString();
 }