Пример #1
0
        /**
         * Queries the store for the details for all of the game's market items by product ids.
         * This operation will "fill" up the MarketItem objects with the information you provided in
         * the developer console including: localized price (as string), title and description.
         */
        public void refreshMarketItemsDetails(Dictionary <string, MarketProductInfos> marketInfos)
        {
            SoomlaUtils.LogDebug(TAG, "TODO refreshMarketItemsDetails");


            List <MarketItem> marketItems = new List <MarketItem>();

            foreach (var mpi in marketInfos)
            {
                String productId = mpi.Value.ProductId;
                String title     = mpi.Value.Name;
                String price     = mpi.Value.FormattedPrice;
                String desc      = mpi.Value.Description;

                try
                {
                    PurchasableVirtualItem pvi = StoreInfo.
                                                 getPurchasableItem(productId);
                    MarketItem mi = ((PurchaseWithMarket)
                                     pvi.GetPurchaseType()).getMarketItem();
                    mi.setMarketTitle(title);
                    mi.setMarketPrice(price);
                    mi.setMarketDescription(desc);

                    marketItems.Add(mi);
                }
                catch (VirtualItemNotFoundException e)
                {
                    String msg = "(refreshInventory) Couldn't find a "
                                 + "purchasable item associated with: " + productId + " " + e.Message;
                    SoomlaUtils.LogError(TAG, msg);
                }
            }
            StoreEvents.GetInstance().PostMarketItemsRefreshFinishedEvent(marketItems);

            /*
             * mInAppBillingService.initializeBillingService(
             *      new IabCallbacks.IabInitListener() {
             *
             *          @Override
             *          public void success(boolean alreadyInBg) {
             *              if (!alreadyInBg) {
             *                  notifyIabServiceStarted();
             *              }
             *              SoomlaUtils.LogDebug(TAG,
             *                      "Setup successful, refreshing market items details");
             *
             *              IabCallbacks.OnFetchSkusDetailsListener fetchSkusDetailsListener =
             *                      new IabCallbacks.OnFetchSkusDetailsListener() {
             *
             *                          @Override
             *                          public void success(List<IabSkuDetails> skuDetails) {
             *                              SoomlaUtils.LogDebug(TAG, "Market items details refreshed");
             *
             *                              List<MarketItem> marketItems = new ArrayList<MarketItem>();
             *                              if (skuDetails.size() > 0) {
             *                                  for (IabSkuDetails iabSkuDetails : skuDetails) {
             *                                      String productId = iabSkuDetails.getSku();
             *                                      String price = iabSkuDetails.getPrice();
             *                                      String title = iabSkuDetails.getTitle();
             *                                      String desc = iabSkuDetails.getDescription();
             *
             *                                      SoomlaUtils.LogDebug(TAG, "Got item details: " +
             *                                              "\ntitle:\t" + iabSkuDetails.getTitle() +
             *                                              "\nprice:\t" + iabSkuDetails.getPrice() +
             *                                              "\nproductId:\t" + iabSkuDetails.getSku() +
             *                                              "\ndesc:\t" + iabSkuDetails.getDescription());
             *
             *                                      try {
             *                                          PurchasableVirtualItem pvi = StoreInfo.
             *                                                  getPurchasableItem(productId);
             *                                          MarketItem mi = ((PurchaseWithMarket)
             *                                                  pvi.getPurchaseType()).getMarketItem();
             *                                          mi.setMarketTitle(title);
             *                                          mi.setMarketPrice(price);
             *                                          mi.setMarketDescription(desc);
             *
             *                                          marketItems.add(mi);
             *                                      } catch (VirtualItemNotFoundException e) {
             *                                          String msg = "(refreshInventory) Couldn't find a "
             + "purchasable item associated with: " + productId;
             +                                          SoomlaUtils.LogError(TAG, msg);
             +                                      }
             +                                  }
             +                              }
             +                              BusProvider.getInstance().post(new OnMarketItemsRefreshFinishedEvent(marketItems));
             +                          }
             +
             +                          @Override
             +                          public void fail(String message) {
             +
             +                          }
             +                      };
             +
             +              final List<String> purchasableProductIds = StoreInfo.getAllProductIds();
             +              mInAppBillingService.fetchSkusDetailsAsync(purchasableProductIds, fetchSkusDetailsListener);
             +
             +              BusProvider.getInstance().post(new OnMarketItemsRefreshStartedEvent());
             +          }
             +
             +          @Override
             +          public void fail(String message) {
             +              reportIabInitFailure(message);
             +          }
             +      }
             + );
             */
        }
Пример #2
0
        private void buildShopLine(VirtualItem item)
        {
            StackPanel stackP = new StackPanel();

            stackP.Orientation = System.Windows.Controls.Orientation.Horizontal;
            stackP.Margin      = new Thickness(0, 15, 0, 0);

            StackPanel buttonStack = new StackPanel();

            buttonStack.Orientation = System.Windows.Controls.Orientation.Vertical;

            StackPanel textStack = new StackPanel();

            textStack.Orientation = System.Windows.Controls.Orientation.Vertical;

            stackP.Children.Add(buttonStack);
            stackP.Children.Add(textStack);

            Button buy = new Button();

            buy.Margin              = new Thickness(0, 0, 10, 0);
            buy.Click              += buyItem;
            buy.Content             = "buy";
            buy.CommandParameter    = item.getItemId();
            buy.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            buy.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
            buttonStack.Children.Add(buy);

            if (item is EquippableVG)
            {
                Button equip = new Button();
                equip.Name                = item.getItemId() + "equip";
                equip.Margin              = new Thickness(0, 0, 10, 0);
                equip.CommandParameter    = item.getItemId();
                equip.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                equip.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
                EquippableVG evg = (EquippableVG)item;
                if (StoreInventory.isVirtualGoodEquipped(item.getItemId()))
                {
                    equip.Content = "unequip";
                    equip.Click  += unequipItem;
                }
                else
                {
                    equip.Content = "equip";
                    equip.Click  += equipItem;
                }
                buttonStack.Children.Add(equip);
            }

            TextBlock balance = new TextBlock();

            balance.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            balance.Margin            = new Thickness(0, 0, 10, 0);
            if (!(item is VirtualCurrencyPack) && !(item is NonConsumableItem))
            {
                balance.Text = "balance: " + StoreInventory.getVirtualItemBalance(item.getItemId()).ToString();
            }
            balance.Name = item.getItemId() + "balance";
            textStack.Children.Add(balance);

            TextBlock name = new TextBlock();

            name.Margin            = new Thickness(0, 0, 10, 0);
            name.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            name.Text = "id: " + item.getItemId();
            textStack.Children.Add(name);

            TextBlock price = new TextBlock();

            price.Margin            = new Thickness(0, 0, 10, 0);
            price.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            TextBlock currency = new TextBlock();

            currency.Margin            = new Thickness(0, 0, 10, 0);
            currency.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            if (item is PurchasableVirtualItem)
            {
                PurchasableVirtualItem pvi = (PurchasableVirtualItem)item;
                if (pvi.GetPurchaseType() is PurchaseWithVirtualItem)
                {
                    PurchaseWithVirtualItem purchaseType = (PurchaseWithVirtualItem)pvi.GetPurchaseType();
                    price.Text    = "price: " + purchaseType.getAmount().ToString();
                    currency.Text = "currency: " + purchaseType.getTargetItemId();
                }
                if (pvi.GetPurchaseType() is PurchaseWithMarket)
                {
                    PurchaseWithMarket purchaseType = (PurchaseWithMarket)pvi.GetPurchaseType();
                    price.Text = "price: " + purchaseType.getMarketItem().getMarketPrice();
                }

                textStack.Children.Add(price);
                textStack.Children.Add(currency);
            }

            if (item is VirtualCurrencyPack)
            {
                VirtualCurrencyPack vcp = (VirtualCurrencyPack)item;

                TextBlock currencyId = new TextBlock();
                currencyId.Text = "give currency: " + vcp.getCurrencyItemId().ToString();

                TextBlock currencyAmount = new TextBlock();
                currencyAmount.Text = "give amount: " + vcp.getCurrencyAmount().ToString();
                textStack.Children.Add(currencyId);
                textStack.Children.Add(currencyAmount);
            }

            MainStackPanel.Children.Add(stackP);
        }