Example #1
0
    private void YesToBuy()
    {
        UserStockData userStock = UserStockData.Load();

        if (userStock.PlusMinGem(-Price))
        {
            if (userStock.PlusMinGold(Gold))
            {
                messagePopup.Show("You have bought " + Name);
                string command = "{";
                command += "action:BUY_COIN";
                command += ",item:" + Name;
                command += "}";
                ServerStatistic.DoRequest(command);
            }
            else
            {
                userStock.PlusMinGem(Price);
            }
        }
        else
        {
            messagePopup.Show("You need " + (Price - userStock.Gems) + " more pearls!");
        }
    }
    private void YesToBuy()
    {
        UserStockData userStock = UserStockData.Load();

        if (Payment == PaymentType.Gold)
        {
            if (userStock.PlusMinGold(-Price))
            {
                if (userStock.PlusMinBubble(WhiteBubble, RedBubble, OrangeBubble))
                {
                    messagePopup.Show("You have bought " + Name);
                    string command = "{";
                    command += "action:BUY_BUBBLE";
                    command += ",item:" + Name;
                    command += "}";
                    ServerStatistic.DoRequest(command);
                    if (reloadPopup)
                    {
                        reloadPopup.NewBuy(WhiteBubble, RedBubble, OrangeBubble);
                    }
                }
                else
                {
                    userStock.PlusMinGold(Price);
                }
            }
            else
            {
                messagePopup.Show("You need " + (Price - userStock.Gold) + " more coins!");
            }
        }
        else if (Payment == PaymentType.Gem)
        {
            if (userStock.PlusMinGem(-Price))
            {
                if (userStock.PlusMinBubble(WhiteBubble, RedBubble, OrangeBubble))
                {
                    messagePopup.Show("You have bought " + Name);
                    string command = "{";
                    command += "action:BUY_BUBBLE";
                    command += ",item:" + Name;
                    command += "}";
                    ServerStatistic.DoRequest(command);
                    if (reloadPopup)
                    {
                        reloadPopup.NewBuy(WhiteBubble, RedBubble, OrangeBubble);
                    }
                }
                else
                {
                    userStock.PlusMinGem(Price);
                }
            }
            else
            {
                messagePopup.Show("You need " + (Price - userStock.Gems) + " more pearls!");
            }
        }
    }
Example #3
0
    private void FinishWatching()
    {
        UserStockData userStock = UserStockData.Load();

        userStock.PlusMinGem(Gems);
        messagePopUp.Show("You have got 1 Pearl!");

        string command = "{";

        command += "action:BUY_PEARL";
        command += ",item:1_SUCCESS_PEARLD_ADS";
        command += "}";
        ServerStatistic.DoRequest(command);
    }
Example #4
0
    private void OnQueryInventorySucceeded(Inventory inventory)
    {
        SkuDetails skusDetail = inventory.GetSkuDetails(ItemPurchaseStore.AndroidStore);

        priceText.text = skusDetail.CurrencyCode + " " + skusDetail.PriceValue;

#if UNITY_ANDROID
        if (inventory.HasPurchase(ItemPurchaseStore.AndroidStore))
        {
            UserStockData userStock = UserStockData.Load();
            userStock.PlusMinGem(Gems);
            OpenIAB.consumeProduct(inventory.GetPurchase(ItemPurchaseStore.AndroidStore));
            MessagePopup.Show("You have bought " + Name);

            string command = "{";
            command += "action:BUY_PEARL";
            command += ",item:" + Name;
            command += "}";
            ServerStatistic.DoRequest(command);
        }
#elif UNITY_IOS
        if (inventory.HasPurchase(ItemPurchaseStore.IosStore))
        {
            UserStockData userStock = UserStockData.Load();
            userStock.PlusMinGem(Gems);
            OpenIAB.consumeProduct(inventory.GetPurchase(ItemPurchaseStore.IosStore));
            MessagePopup.Show("You have bought " + Name);

            string command = "{";
            command += "action:BUY_PEARL";
            command += ",item:" + Name;
            command += "}";
            ServerStatistic.DoRequest(command);
        }
#elif UNITY_WP8
        if (inventory.HasPurchase(ItemPurchaseStore.WpStore))
        {
            UserStockData userStock = UserStockData.Load();
            userStock.PlusMinGem(Gems);
            OpenIAB.consumeProduct(inventory.GetPurchase(ItemPurchaseStore.WpStore));
            MessagePopup.Show("You have bought " + Name);

            string command = "{";
            command += "action:BUY_PEARL";
            command += ",item:" + Name;
            command += "}";
            ServerStatistic.DoRequest(command);
        }
#endif
    }
Example #5
0
    private void OnPurchaseSucceded(Purchase purchase) //to VerifyDeveloperPayload to our own server
    {
#if UNITY_ANDROID
        if (purchase.Sku == ItemPurchaseStore.AndroidStore)
        {
            UserStockData userStock = UserStockData.Load();
            userStock.PlusMinGem(Gems);
            OpenIAB.consumeProduct(purchase);
            MessagePopup.Show("You have bought " + Name);

            string command = "{";
            command += "action:BUY_PEARL";
            command += ",item:" + Name;
            command += "}";
            ServerStatistic.DoRequest(command);
        }
#elif UNITY_IOS
        if (purchase.Sku == ItemPurchaseStore.IosStore)
        {
            UserStockData userStock = UserStockData.Load();
            userStock.PlusMinGem(Gems);
            OpenIAB.consumeProduct(purchase);
            MessagePopup.Show("You have bought " + Name);

            string command = "{";
            command += "action:BUY_PEARL";
            command += ",item:" + Name;
            command += "}";
            ServerStatistic.DoRequest(command);
        }
#elif UNITY_WP8
        if (purchase.Sku == ItemPurchaseStore.WpStore)
        {
            UserStockData userStock = UserStockData.Load();
            userStock.PlusMinGem(Gems);
            OpenIAB.consumeProduct(purchase);
            MessagePopup.Show("You have bought " + Name);

            string command = "{";
            command += "action:BUY_PEARL";
            command += ",item:" + Name;
            command += "}";
            ServerStatistic.DoRequest(command);
        }
#endif
    }
Example #6
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!");
            }
        }
    }