Пример #1
0
 private void BuyCash()
 {
     BuyCoinUtility.GoToBuyCashPage
     (
         Translation.NEED_CASH_TITLE,
         Translation.NEED_CASH_TEXT,
         delegate(string s)
     {
         Console.WriteLine("Opening cash store: " + s);
     },
         delegate()
     {
         GameFacade.Instance.SendNotification(GameFacade.GET_CASH_GUI_CLOSED);
     }
     );
 }
Пример #2
0
        /// <summary>
        /// Show the item detail popup
        /// </summary>
        /// <param name="button"></param>
        /// <param name="index">Index of the item on the current page that this button corresponds to</param>
        private void GridItemSelected(IWidget widget, XmlElement itemOfferNode, XmlElement itemNode)
        {
            XmlElement priceNode      = (XmlElement)itemOfferNode.SelectSingleNode("price/money");
            string     description    = itemOfferNode.GetAttribute("description");
            string     itemName       = itemOfferNode.GetAttribute("title");
            string     thumbnailUrl   = ConvertPaymentItemsUrl(itemNode.GetAttribute("smallImageUrl"));
            string     uniqueId       = itemNode.GetAttribute("name");
            string     itemExpiration = itemOfferNode.GetAttribute("endDate");
            string     itemQuantity   = itemOfferNode.GetAttribute("numAvailable");
            string     currency       = priceNode.GetAttribute("currencyName");
            string     price          = priceNode.GetAttribute("amount");
            string     itemType       = itemNode.GetAttribute("itemTypeName");
            XmlNode    assetsNode     = itemNode.SelectSingleNode("Assets");

            mCurrentSelectedItemOffer = itemOfferNode;

            ShowItemInfoOverlay(widget, thumbnailUrl, price, currency);

            ShowItemInfoFrame(itemName, description, itemExpiration, itemQuantity);

            SetupOverlayActionButtons(uniqueId, itemType, assetsNode);

            // Log for metrics
            if (currency == "HOUTS")
            {
                EventLogger.Log(LogGlobals.CATEGORY_SHOPPING, LogGlobals.CLICKED_ON_CASH_ITEM,
                                itemName, price);

                mItemOverlayActionButton.ClearOnPressedActions();
                mItemOverlayActionButton.AddOnPressedAction(delegate()
                {
                    mOverlayWindow.Showing = false;
                });

                // Disable the Buy button if you don't have enough currency to purchase.
                if (GameFacade.Instance.RetrieveProxy <InventoryProxy>().Houts < Double.Parse(price))
                {
                    mItemOverlayActionButton.AddOnPressedAction(delegate()
                    {
                        BuyCoinUtility.GoToBuyCashPage
                        (
                            Translation.NEED_CASH_TITLE,
                            Translation.NOT_ENOUGH_COIN,
                            delegate(string s)
                        {
                            Console.WriteLine("Opening cash store: " + s);
                        },
                            delegate()
                        {
                            GameFacade.Instance.SendNotification(GameFacade.GET_CASH_GUI_CLOSED);
                        }
                        );
                    });
                }
                else
                {
                    mItemOverlayActionButton.AddOnPressedAction(delegate()
                    {
                        Purchase();
                    });
                }
            }
            else
            {
                EventLogger.Log(LogGlobals.CATEGORY_SHOPPING, LogGlobals.CLICKED_ON_COIN_ITEM,
                                itemName, price);
                // Disable the Buy button if you don't have enough currency to purchase.
                if (GameFacade.Instance.RetrieveProxy <InventoryProxy>().VCoin < Double.Parse(price))
                {
                    mItemOverlayActionButton.AddOnPressedAction(delegate()
                    {
                        BuyCoinUtility.GoToBuyCashPage
                        (
                            Translation.NEED_CASH_TITLE,
                            Translation.NOT_ENOUGH_CASH,
                            delegate(string s)
                        {
                            Console.WriteLine("Opening cash store: " + s);
                        },
                            delegate()
                        {
                            GameFacade.Instance.SendNotification(GameFacade.GET_CASH_GUI_CLOSED);
                        }
                        );
                    });
                }
                else
                {
                    mItemOverlayActionButton.AddOnPressedAction(delegate()
                    {
                        Purchase();
                    });
                }
            }
            mRemoveButton.ClearOnPressedActions();
            mRemoveButton.AddOnPressedAction(delegate()
            {
                List <AssetInfo> assetInfos = new List <AssetInfo>();
                foreach (XmlNode assetNode in assetsNode.SelectNodes("Asset"))
                {
                    AssetInfo assetInfo = new ClientAssetInfo(assetNode);
                    assetInfos.Add(assetInfo);
                }
                GameFacade.Instance.RetrieveMediator <AvatarMediator>().LocalAvatarEntity.RemoveTempAssetInfos(assetInfos);
                mOverlayWindow.Showing = false;
            });
        }