示例#1
0
    public void InitCoinItems()
    {
        Debug.Log("金币总量为:" + PlayerDataManager.GetCoins());
        for (int i = 0; i != coinItems.Length; i++)
        {
            CoinItem item = coinItems[i];
            item.coinAmountText.text = item.coinAmount.ToString();
            if (item.dealValue > 0)
            {
                item.dealValueText.GetComponent <LocalizationParamsManager>().SetParameterValue("AMOUNT", $"+{item.dealValue.ToString()}");
                item.dealValueText.text = "<color=#9806FD>" + item.dealValue.ToString() + "%" + "额外赠送!";
            }
            item.priceText.text = item.gemPrice.ToString();

            item.button.onClick.AddListener(delegate
            {
                TryPurchase(item.gemPrice, CurrencyType.Gems, delegate
                {
                    AnimatedCurrencyController.AnimateCoins(item.coinAmount, MenuController.UICamera.WorldToViewportPoint(item.graphicButton.transform.position), MenuController.TotalCoinsPositionViewport, 1, null, delegate(int tc)
                    {
                    });
                    MenuController.instance.topTotalGemsText.Tick(-item.gemPrice);             //宝石扣除
                    PlayerDataManager.AddCoins(item.coinAmount, sync: true, cloudSync: false); //金币添加
                    MenuController.UpdateTopMenu();
                    Debug.Log("金币总量为:" + PlayerDataManager.GetCoins());
                    Debug.Log("钻石总量为:" + PlayerDataManager.GetGems());
                });
            });
        }
    }
示例#2
0
    public void ProcessPurchase(string id)
    {
        Debug.Log("购买的物品ID是:" + id);
        Product iAPInfo = GetIAPInfo(id);
        bool    flag    = true;

        if (id.Contains("gems")) //宝石
        {
            // Debug.Log("Getgems 自定义数量");
            //PlayerDataManager.AddGems((int)50);
            //MenuController.UpdateTopMenu();
        }
        else if (id.Contains("tank") && id.Contains("Cards"))
        {
            PlayerDataManager.AddTankCards(id.Replace("Cards", ""), (int)50);
        }
        else if (id.Contains("coins"))
        {
            Debug.Log("Getcoins 自定义数量");
            PlayerDataManager.AddCoins((int)50);
        }
//		if (id.Contains("sub"))
//		{
//			UnityEngine.Debug.Log("Product is a subscription");
////
//		}
//		else
//		{
//			UnityEngine.Debug.Log("Product is NOT a subscription");
//		}
        if (flag)
        {
            SetSomeIAPBought();
        }
        TankPrefs.SaveAndSendToCloud(true);
        if (iapCallback != null)
        {
            iapCallback();
            iapCallback = null;
        }
        IAPTransactionInProgress = false;
    }