Пример #1
0
    private void YesToBuy()
    {
        UserStockData userStock = UserStockData.Load();

        UserItemStock userItems = new UserItemStock();

        userItems.Load();

        if (Payment == PaymentType.Gem)
        {
            if (userStock.PlusMinGem(-Price))
            {
                for (int i = 0; i < ItemAlias.Length; i++)
                {
                    userItems.Add(ItemAlias);
                }
                messagePopup.Show("You have bought " + Name);

                string command = "{";
                command += "action:BUY_ITEM";
                command += ",item:" + Name;
                command += "}";
                ServerStatistic.DoRequest(command);

                if (UserItemStock.Items.Contains(ItemAlias[0]))
                {
                    textPrice.text = "Bought";
                    EffectedItem.SetActive(true);
                }
            }
            else
            {
                messagePopup.Show("You need " + (Price - userStock.Gems) + " more pearls!");
            }
        }
        else if (Payment == PaymentType.Gold)
        {
            if (userStock.PlusMinGold(-Price))
            {
                for (int i = 0; i < ItemAlias.Length; i++)
                {
                    userItems.Add(ItemAlias[i]);
                }
                messagePopup.Show("You have bought " + Name);

                string command = "{";
                command += "action:BUY_ITEM";
                command += ",item:" + Name;
                command += "}";
                ServerStatistic.DoRequest(command);

                if (UserItemStock.Items.Contains(ItemAlias[0]))
                {
                    textPrice.text = "Bought";
                    EffectedItem.SetActive(true);
                }
                //gameObject.SetActive(!UserItemStock.Items.Contains(ItemAlias[0]));
            }
            else
            {
                messagePopup.Show("You need " + (Price - userStock.Gold) + " more coins!");
            }
        }
    }