Exemple #1
0
        public TableShop Get(int id)
        {
            TableShop data = null;

            _ins.mDict.TryGetValue(id, out data);
            return(data);
        }
Exemple #2
0
 public void SetData(int goodsID)
 {
     mTable     = TableShop.Get(goodsID);
     title.text = LT.Get(mTable.nameID);
     icon.SetSprite(mTable.image);
     price.text = LT.Get(mTable.priceID);
     extraObj.SetActive(mTable.extra > 0);
     extra.text = $"+{mTable.extra}";
 }
 private void RefreshUI()
 {
     levelPanel.SetData();
     shopGoods.SetData <ShopGoodsItem, TableShop>(TableShop.GetAll().ToList(a => a.type == 0)
                                                  , (index, item, _data) =>
     {
         item.SetData(_data.id);
     });
     vipBtn.targetImage.SetGrey(!D.I.IsVip());
     vipRewardText.gameObject.SetActive(D.I.IsVip());
 }
Exemple #4
0
        /// <summary>
        /// Called when a purchase completes.
        ///
        /// May be called at any time after OnInitialized().
        /// </summary>
        public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e)
        {
            bool validPurchase = true; // Presume valid for platforms with no R.V.

            System.DateTime purchaseData = System.DateTime.Now;

            // Unity IAP's validation logic is only included on these platforms.
#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IOS)
            // Prepare the validator with the secrets we prepared in the Editor
            // obfuscation window.
            purchaseData = System.DateTime.MinValue;
            var validator = new CrossPlatformValidator(GooglePlayTangle.Data(),
                                                       AppleTangle.Data(), Application.identifier);

            try
            {
                // On Google Play, result has a single product ID.
                // On Apple stores, receipts contain multiple products.
                var result = validator.Validate(e.purchasedProduct.receipt);
                // For informational purposes, we list the receipt(s)
                //Debug.Log("Receipt is valid. Contents:");
                foreach (IPurchaseReceipt productReceipt in result)
                {
                    if (purchaseData.Ticks < productReceipt.purchaseDate.Ticks)
                    {
                        purchaseData = productReceipt.purchaseDate;
                    }
                }
            }
            catch (IAPSecurityException ex)
            {
                Debug.LogError("Invalid receipt:" + ex.Message);
                validPurchase = false;
            }
#endif

            if (validPurchase)
            {
                var pid   = e.purchasedProduct.definition.id;
                var goods = TableShop.Get(a => a.productID == pid);
                D.I.OnPurchaseSuccess(goods.id, purchaseData);
            }
            else
            {
                Toast.Show("Purchase Failed, Invalid receipt.");
            }
            return(PurchaseProcessingResult.Complete);
        }
        public void OnPurchaseSuccess(int shopGoodsID, DateTime date)
        {
            var t = TableShop.Get(shopGoodsID);

            if (t.type == 0) // Consumable
            {
                AddDiamondWithEffect(t.diamonds + t.extra);
                SaveLocalData();
                DispatchEvent(EventGameData.Action.DataChange);
            }
            else if (t.type == 2) // Subscription
            {
                localData.lastVipTicks = date.Ticks;
                SaveLocalData();
                DispatchEvent(EventGameData.Action.DataChange);
            }
        }
Exemple #6
0
        public void Init()
        {
            var module = StandardPurchasingModule.Instance();

            appStore = module.appStore;
            var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

            foreach (var t in TableShop.GetAll())
            {
                builder.AddProduct(t.productID, (ProductType)t.type, new IDs
                {
                    { t.productID, GooglePlay.Name },
                    { t.productID, AppleAppStore.Name }
                });
            }
            builder.Configure <IGooglePlayConfiguration>().SetPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAt1lvHFO1vq2djnUEgv3PGrTsieVKtLUIRSlW99wnqHZMYLRoXnK0qOnWU6Lz/jt07LkktqJzWrW+OE/w67VtLJMrycBaA0eCDqErr62pg4HkXK4tS9+0oJJxJ9pvr+QACLigJlHefPGtoZ+JumUILnxM6dPwW7xalxaCTmhSpfg3CVZ75NXTmIx4X5qLAHFPOCPrjdTTZPdX7zZMRTdIYAAseXn4X+BE2gRhhyCVA0T9+m1AD8lC+wftuQz+xRksYjEj9XgNJJ3A0Z9QKr3MZoyqYQ0+6HPpNzKY6owf7t3fix36oJl4OYu+99ksO2p2oqVrpbPSJVWFkmbJRrFepQIDAQAB");
            builder.useCatalogProvider = false;
            UnityPurchasing.Initialize(this, builder);
        }
 public void Purchase(int shopGoodsID)
 {
     var t = TableShop.Get(shopGoodsID);
     // IAPManager.Instance.Purchase(t.productID);
 }