コード例 #1
0
    void BuyPackage(CoinPackage package)
    {
        // Play sound
        SoundManager.PlayButtonClick();

        if (!Helper.IsOnline())
        {
            Manager.Instance.ShowMessage(Settings.NoInternetConnection);
            return;
        }

        // Close popup
        Close();

        // Purchase
        CompleteProject.Purchaser purchaser = GetComponent <CompleteProject.Purchaser>();

        if (purchaser != null)
        {
            if (_purchaseCallback != null)
            {
                purchaser.BuyPackage(package, _purchaseCallback);
            }
            else
            {
                purchaser.BuyPackage(package, (purchasedPackage) => {
                    //Debug.Log("Purchase finish: add " + purchasedPackage.GetCoins() + " coins");
                    NotificationManager.CoinChanged(UserData.Instance.Coin + purchasedPackage.GetCoins());
                    MyAdmob.Instance.isPurchased = true;
                    PlayerPrefs.SetInt(MyAdmob.purchaseText, 1);
                });
            }
        }
    }
コード例 #2
0
ファイル: Purchaser.cs プロジェクト: Jturesson90/MayThirteen
        void Awake()
        {
            #if UNITY_IOS
            gameObject.SetActive(false);
            #endif
            if (_instance == null)
                _instance = this;
            else if (_instance != this)
            {
                Destroy(gameObject);
            }

            DontDestroyOnLoad(gameObject);
        }