Esempio n. 1
0
        // Constructor
        void Start()
        {
            var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

            for (int i = 0; i < inAppPurchaseSettings.products.Length; i++)
            {
                InAppPurchaseSettings.GameProduct gameProduct = inAppPurchaseSettings.products [i];
                IDs ids = new IDs();
                ids.Add(inAppPurchaseSettings.mainId + "." + gameProduct.id, GooglePlay.Name);
                ids.Add(inAppPurchaseSettings.mainId + "." + gameProduct.id, AppleAppStore.Name);
                builder.AddProduct(gameProduct.id, gameProduct.type, ids);
            }

            UnityPurchasing.Initialize(this, builder);
        }
            private StoreManager()
            {
                catalog = ProductCatalog.LoadDefaultCatalog();

                StandardPurchasingModule module = StandardPurchasingModule.Instance();

                module.useFakeStoreUIMode = FakeStoreUIMode.StandardUser;

                ConfigurationBuilder builder = ConfigurationBuilder.Instance(module);

                foreach (var product in catalog.allProducts)
                {
                    if (product.allStoreIDs.Count > 0)
                    {
                        var ids = new IDs();
                        foreach (var storeID in product.allStoreIDs)
                        {
                            ids.Add(storeID.id, storeID.store);
                        }
                        builder.AddProduct(product.id, product.type, ids);
                    }
                    else
                    {
                        builder.AddProduct(product.id, product.type);
                    }
                }
                UnityPurchasing.Initialize(this, builder);
            }
Esempio n. 3
0
        public IDs GetIDs()
        {
            IDs productIDs = new IDs();
            int count      = storeIDs.Count;

            for (int i = count - 1; i >= 0; i--)
            {
                IAPPlatform platform = (IAPPlatform)System.Enum.Parse(typeof(IAPPlatform), storeIDs[i].store);
                if (platform == IAPPlatform.None || string.IsNullOrEmpty(storeIDs[i].id))
                {
                    storeIDs.RemoveAt(i);
                    continue;
                }

                productIDs.Add(storeIDs[i].id, storeIDs[i].store);
            }

            if (productIDs.Count() > 0)
            {
                return(productIDs);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 4
0
        private void InsertNewID(string value)
        {
            int wasDeclaratedIndex = -1;

            for (int j = 0; j < IDs.Count; j++)
            {
                if (value == IDs[j])
                {
                    wasDeclaratedIndex = j;
                    break;
                }
            }
            // It hasn't declarated.
            if (wasDeclaratedIndex != -1)
            {
                Out.Log(Out.State.LogInfo, "");
                throw new LexemException((line + 1), "Variable " + value + " has declarated earlier");
            }
            else
            {
                // Declaration zone //
                IDs.Add(value);
                Lexems.Add(new Lexem(line, value, dict.Count - 2));
                Out.Log(Out.State.LogInfo, dict.Count - 1 + "\t" + IDs.Count);
            }
        }
Esempio n. 5
0
    private void InitIAP()
    {
        var module = StandardPurchasingModule.Instance();
        ConfigurationBuilder builder = ConfigurationBuilder.Instance(module);

        var catalog = ProductCatalog.LoadDefaultCatalog();

        foreach (var product in catalog.allValidProducts)
        {
            if (product.allStoreIDs.Count > 0)
            {
                var ids = new IDs();
                foreach (var storeID in product.allStoreIDs)
                {
                    ids.Add(storeID.id, storeID.store);
                }
                builder.AddProduct(product.id, product.type, ids);
            }
            else
            {
                builder.AddProduct(product.id, product.type);
            }
        }


        UnityPurchasing.Initialize(this, builder);
    }
Esempio n. 6
0
            private IAPButtonStoreManager()
            {
                catalog = ProductCatalog.LoadDefaultCatalog();

                StandardPurchasingModule module = StandardPurchasingModule.Instance();

                module.useFakeStoreUIMode = FakeStoreUIMode.StandardUser;

                ConfigurationBuilder builder = ConfigurationBuilder.Instance(module);

                //This seems to be outdated/unneeded, the value should be set in unity services
                //builder.Configure<IGooglePlayConfiguration>().SetPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2O/9/H7jYjOsLFT/uSy3ZEk5KaNg1xx60RN7yWJaoQZ7qMeLy4hsVB3IpgMXgiYFiKELkBaUEkObiPDlCxcHnWVlhnzJBvTfeCPrYNVOOSJFZrXdotp5L0iS2NVHjnllM+HA1M0W2eSNjdYzdLmZl1bxTpXa4th+dVli9lZu7B7C2ly79i/hGTmvaClzPBNyX+Rtj7Bmo336zh2lYbRdpD5glozUq+10u91PMDPH+jqhx10eyZpiapr8dFqXl5diMiobknw9CgcjxqMTVBQHK6hS0qYKPmUDONquJn280fBs1PTeA6NMG03gb9FLESKFclcuEZtvM8ZwMMRxSLA9GwIDAQAB");

                foreach (var product in catalog.allProducts)
                {
                    if (product.allStoreIDs.Count > 0)
                    {
                        var ids = new IDs();
                        foreach (var storeID in product.allStoreIDs)
                        {
                            ids.Add(storeID.id, storeID.store);
                        }
                        builder.AddProduct(product.id, product.type, ids);
                    }
                    else
                    {
                        builder.AddProduct(product.id, product.type);
                    }
                }
                                #if RECEIPT_VALIDATION
                validator = new CrossPlatformValidator(GooglePlayTangle.Data(), AppleTangle.Data(), Application.bundleIdentifier);
                                #endif
                UnityPurchasing.Initialize(this, builder);
            }
Esempio n. 7
0
    public IAPManager()
    {
        ConfigurationBuilder builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
        ProductCatalog       catalog = ProductCatalog.LoadDefaultCatalog();

        foreach (ProductCatalogItem item in catalog.allProducts)
        {
            if (item.allStoreIDs.Count > 0)
            {
                IDs ids = new IDs();
                foreach (StoreID storeID in item.allStoreIDs)
                {
                    ids.Add(storeID.id, storeID.store);
                }
                builder.AddProduct(item.id, item.type, ids);
            }
            else
            {
                builder.AddProduct(item.id, item.type);
            }
        }

        if (builder.Configure <IAppleConfiguration> ().canMakePayments)
        {
            UnityPurchasing.Initialize(this, builder);
        }
        else
        {
            Alert.Show("当前设备不允许支付,请启用内购功能");
            Debug.Log("当前设备不允许支付");
        }
    }
Esempio n. 8
0
        //初始化内购项目,主要是从catalog中获取商品信息,设置给 UnityPurchasing
        void InitializePurchasing()
        {
            if (IsInitialized())
            {
                Debug.Log("初始化失败");
                return;
            }
            StandardPurchasingModule module = StandardPurchasingModule.Instance();

            module.useFakeStoreUIMode = FakeStoreUIMode.StandardUser;
            ConfigurationBuilder builder = ConfigurationBuilder.Instance(module);
            //通过编辑器中的Catalog添加,方便操作
            ProductCatalog catalog = ProductCatalog.LoadDefaultCatalog();

            // Debug.Log(catalog.allProducts.Count);
            foreach (var product in catalog.allProducts)
            {
                if (product.allStoreIDs.Count > 0)
                {
                    // Debug.Log("product:" + product.id);
                    var ids = new IDs();
                    foreach (var storeID in product.allStoreIDs)
                    {
                        ids.Add(storeID.id, storeID.store);
                        // Debug.Log("stordId:" + storeID.id  + ", " + storeID.store);
                    }
                    builder.AddProduct(product.id, product.type, ids);
                }
                else
                {
                    builder.AddProduct(product.id, product.type);
                }
            }
            UnityPurchasing.Initialize(this, builder);
        }
Esempio n. 9
0
            /// Populate a ConfigurationBuilder with products from a ProductCatalog
            public static void PopulateConfigurationBuilder(ref ConfigurationBuilder builder, ProductCatalog catalog)
            {
                foreach (var product in catalog.allProducts)
                {
                    IDs ids = null;

                    if (product.allStoreIDs.Count > 0)
                    {
                        ids = new IDs();
                        foreach (var storeID in product.allStoreIDs)
                        {
                            ids.Add(storeID.id, storeID.store);
                        }
                    }

#if UNITY_2017_2_OR_NEWER
                    var payoutDefinitions = new List <PayoutDefinition>();
                    foreach (var payout in product.Payouts)
                    {
                        payoutDefinitions.Add(new PayoutDefinition(payout.typeString, payout.subtype, payout.quantity, payout.data));
                    }
                    builder.AddProduct(product.id, product.type, ids, payoutDefinitions.ToArray());
#else
                    builder.AddProduct(product.id, product.type, ids);
#endif
                }
            }
Esempio n. 10
0
        //Parse
        private void ParseRSS()
        {
            try
            {
                var feed = SyndicationFeed.Load(XmlReader.Create(URL));

                this.Updated  = feed.LastUpdatedTime.ToString();
                this.Title    = feed.Title.ToString();
                this.Link     = feed.Links.First(l => l.RelationshipType.Trim().ToLower() == "alternate").Uri.ToString();
                this.Category = new Entry._Category(feed.Categories.FirstOrDefault(c => c.Name != "").Name, feed.Categories.FirstOrDefault(c => c.Name != "").Label);
                this.ID       = feed.Id;

                //Items
                foreach (var item in feed.Items)
                {
                    //Authors
                    List <Entry._Author> authors = new List <Entry._Author>();
                    foreach (SyndicationPerson author in item.Authors)
                    {
                        authors.Add(new Entry._Author(author.Name, author.Uri));
                    }

                    //Categories
                    List <Entry._Category> categories = new List <Entry._Category>();
                    foreach (SyndicationCategory category in item.Categories)
                    {
                        categories.Add(new Entry._Category(category.Name, category.Label));
                    }

                    //Links
                    List <string> Links = new List <string>();
                    foreach (SyndicationLink link in item.Links)
                    {
                        Links.Add(link.Uri.ToString());
                    }

                    //ID
                    IDs.Add(item.Id.ToString());

                    //Updated
                    Updateds.Add(item.LastUpdatedTime.ToString());

                    //Content
                    Contents.Add(item.Content.ToString());

                    //Titles
                    Titles.Add(item.Title.Text.ToString());
                    //Titles & Links
                    if (!TitlesLinks.ContainsKey(item.Title.ToString().Trim()))
                    {
                        TitlesLinks.Add(item.Title.Text.ToString().Trim(), Links);
                    }

                    //Add entry
                    Entries.Add(new Entry(authors, categories, item.Content.ToString(), item.Id.ToString(), Links, item.LastUpdatedTime.ToString(), item.Title.ToString()));
                }
            }
            catch (Exception e) { throw e; }
        }
Esempio n. 11
0
        public PlayerPositionAndLook()
        {
            IDs.Add(-1);
            IDs.Add(-1);
            IDs.Add(0x0C);

            ID   = 0x2E;
            Send = true;
        }
Esempio n. 12
0
    private void InitializePurchasing()
    {
#if (UNITY_ANDROID || UNITY_IOS) && UNITY_PURCHASING
        // If we have already connected to Purchasing ...
        if (IsPurchasingInitialized())
        {
            return;
        }

        // Create a builder, first passing in a suite of Unity provided stores.
        var module  = StandardPurchasingModule.Instance();
        var builder = ConfigurationBuilder.Instance(module);

        // Retrieve products from products list
        foreach (var product in products)
        {
            var productCatalogItem = product.ProductCatalogItem;
            if (productCatalogItem == null)
            {
                continue;
            }

            var logMessage = "[" + TAG_INIT + "]: Adding product " + productCatalogItem.id + " type " + productCatalogItem.type.ToString();
            Debug.Log(logMessage);
            if (productCatalogItem.allStoreIDs.Count > 0)
            {
                var ids = new IDs();
                foreach (var storeID in productCatalogItem.allStoreIDs)
                {
                    ids.Add(storeID.id, storeID.store);
                }
                builder.AddProduct(productCatalogItem.id, productCatalogItem.type, ids);
            }
            else
            {
                builder.AddProduct(productCatalogItem.id, productCatalogItem.type);
            }
            Products[productCatalogItem.id] = product;
        }

        // Kick off the remainder of the set-up with an asynchrounous call, passing the configuration
        // and this class' instance. Expect a response either in OnInitialized or OnInitializeFailed.
        try
        {
            UnityPurchasing.Initialize(this, builder);
        }
        catch (System.InvalidOperationException ex)
        {
            var errorMessage = "[" + TAG_INIT + "]: Cannot initialize purchasing, the platform may not supports.";
            Debug.LogError(errorMessage);
            Debug.LogException(ex);
        }
#else
        Debug.LogWarning("Cannot initialize purchasing, Unity Purchasing is not enabled or not supported platforms.");
#endif
    }
Esempio n. 13
0
        public void InitializeStore()
        {
            Debug.Log("Initializing Store");

            var catalogJson = LocalDataManager.Instance.GetConfigJson(typeof(ProductCatalog).Name);

            _productCatalog = ProductCatalog.Deserialize(catalogJson);

            if (IsInitialized())
            {
                OnInitSuccess.SafeInvoke();
                return;
            }

            if (_isInitializing)
            {
                return;
            }

            _isInitializing = true;
            var module  = StandardPurchasingModule.Instance();
            var builder = ConfigurationBuilder.Instance(module);

/*        var settings = new JsonSerializerSettings
 *      {
 *          NullValueHandling = NullValueHandling.Ignore,
 *          MissingMemberHandling = MissingMemberHandling.Ignore
 *      };
 *
 *      _productCatalog = JsonConvert.DeserializeObject<ProductCatalog>(catalogJson, settings);*/

#if UNITY_IOS
            appleConfig = builder.Configure <IAppleConfiguration> ();
#endif
            foreach (var product in _productCatalog.allProducts)
            {
                Debug.Log("Product: " + product.id + ", type: " + product.type);
                if (product.allStoreIDs.Count > 0)
                {
                    var ids = new IDs();
                    foreach (var storeId in product.allStoreIDs)
                    {
                        ids.Add(storeId.id, storeId.store);
                    }

                    builder.AddProduct(product.id, product.type, ids);
                }
                else
                {
                    builder.AddProduct(product.id, product.type);
                }
            }

            UnityPurchasing.Initialize(this, builder);
        }
Esempio n. 14
0
    public void Init(IAPSetting iapSetting)
    {
        IAPSetting = iapSetting;
        var module = StandardPurchasingModule.Instance();

        builder = ConfigurationBuilder.Instance(module);
        builder.Configure <IGooglePlayConfiguration>().SetPublicKey(IAPSetting.GooglePublicKey);
        //StoreListener = new StoreListener(this);

        for (var i = 0; i < IAPSetting.Products.Length; i++)
        {
            var ids = new IDs();
            if (!string.IsNullOrEmpty(IAPSetting.Products[i].GooglePlayStoreProductId))
            {
                ids.Add(IAPSetting.Products[i].GooglePlayStoreProductId, GooglePlay.Name);
            }
            if (!string.IsNullOrEmpty(IAPSetting.Products[i].IosStoreProductId))
            {
                ids.Add(IAPSetting.Products[i].IosStoreProductId, AppleAppStore.Name);
            }
            if (!string.IsNullOrEmpty(IAPSetting.Products[i].MacStoreProductId))
            {
                ids.Add(IAPSetting.Products[i].MacStoreProductId, MacAppStore.Name);
            }
            if (!string.IsNullOrEmpty(IAPSetting.Products[i].WindowsStoreProductId))
            {
                ids.Add(IAPSetting.Products[i].WindowsStoreProductId, WindowsStore.Name);
            }
            if (!string.IsNullOrEmpty(IAPSetting.Products[i].AmazonStoreProductId))
            {
                ids.Add(IAPSetting.Products[i].AmazonStoreProductId, AmazonApps.Name);
            }
            builder.AddProduct(IAPSetting.Products[i].Id, IAPSetting.Products[i].Type, ids);
        }

        if (IAPSetting.SandboxEnable)
        {
            builder.Configure <IAmazonConfiguration>().WriteSandboxJSON(builder.products);
            builder.Configure <IMicrosoftConfiguration>().useMockBillingSystem = true;
        }
        UnityPurchasing.Initialize(this, builder);
    }
Esempio n. 15
0
 private IDs GetStoreIDs(CustomProduct product)
 {
     IDs ids = new IDs();
     foreach (KeyValuePair<string, string> storeIDs in product.storeIDs)
     {
         string storeName = storeIDs.Key;
         string storeID = storeIDs.Value;
         ids.Add(storeID, storeName);
     }
     return ids;
 }
Esempio n. 16
0
 private ID getIDByName(String name)
 {
     foreach (ID id in IDs)
     {
         if (id.Value.Equals(name))
         {
             return(id);
         }
     }
     IDs.Add(new ID(IDs.Count + 1, name));
     return(IDs[IDs.Count - 1]);
 }
Esempio n. 17
0
 /// <summary> Adds a new ID with all keyframes with a given type. </summary>
 /// <param name="id"> the ID to add </param>
 /// <param name="type"> the type to set each keyframe to </param>
 /// <returns> whether the element was added or not </returns>
 public bool AddID(int id, Hitbox.Type type)
 {
     if (IDs.Contains(id))
     {
         return(false);
     }
     IDs.Add(id);
     foreach (HitboxKeyframe hitboxKeyframe in Keyframes)
     {
         hitboxKeyframe.States.Add(type);
     }
     return(true);
 }
        private void timer_Tick(object sender, EventArgs e)
        {
            try
            {
                DataTable val = InvConsultas.ValeEntregaPendiente(Lugar, UsuarioIniciado.Almacen, "PENDIENTE", FuncionesComunes.horaInicial(DateTime.Today), split(Vales));
                if (val != null && val.Rows.Count > 0)
                {
                    VentaAEntregar va = new VentaAEntregar();
                    va.Mi_Click += new System.EventHandler(this.Entrega_Click);
                    va.ID        = val.Rows[0]["ID"].ToString();
                    va.Mov       = val.Rows[0]["Mov"].ToString();
                    va.MovID     = val.Rows[0]["MovID"].ToString();
                    va.Agente    = val.Rows[0]["Usuario"].ToString();
                    va.Cliente   = val.Rows[0]["Cliente"].ToString();
                    va.Name      = "Vale" + va.ID.ToString();
                    foreach (DataRow r in val.Rows)
                    {
                        va.Detalle += r["Cantidad"].ToString() + " - " + r["Articulo"].ToString() + ": " + r["Descripcion"].ToString() + '\n';
                    }
                    va.TopLevel = false;
                    fpContenedor.Controls.Add(va);
                    Vales.Add(va.ID.ToString());
                    va.Show();
                }

                DataTable dt = InvConsultas.PendienteDeEntrega(Lugar, UsuarioIniciado.Almacen, "POR ENTREGAR", FuncionesComunes.horaInicial(DateTime.Today), split(IDs));
                if (dt != null && dt.Rows.Count > 0)
                {
                    VentaAEntregar ve = new VentaAEntregar();
                    ve.Mi_Click += new System.EventHandler(this.Entrega_Click);
                    ve.ID        = "V" + dt.Rows[0]["ID"].ToString();
                    ve.Mov       = dt.Rows[0]["Mov"].ToString();
                    ve.MovID     = dt.Rows[0]["MovID"].ToString();
                    ve.Agente    = dt.Rows[0]["Agente"].ToString();
                    ve.Cliente   = dt.Rows[0]["Cliente"].ToString();
                    ve.Name      = ve.ID.ToString();
                    foreach (DataRow r in dt.Rows)
                    {
                        ve.Detalle += r["Cantidad"].ToString() + " - " + r["Articulo"].ToString() + ": " + r["Descripcion"].ToString() + '\n';
                    }
                    ve.TopLevel = false;
                    fpContenedor.Controls.Add(ve);
                    IDs.Add(ve.ID.ToString());
                    ve.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ocurrio el siguiente problema: " + ex.Message, "Entrega de Mercancia", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 19
0
        /// <summary>
        /// 課金システム初期化.
        /// </summary>
        private void InitializePurchasing(ProductDefinition[] productDefinitions)
        {
            storeController        = null;
            storeExtensionProvider = null;

            // Unityの課金システム構築.
            var module = StandardPurchasingModule.Instance();

            #if UNITY_EDITOR
            module.useFakeStoreUIMode = FakeStoreUIMode.StandardUser;
            #endif

            var builder = ConfigurationBuilder.Instance(module);

            if (productDefinitions.Any())
            {
                foreach (var productDefinition in productDefinitions)
                {
                    var ids       = new IDs();
                    var storeName = string.Empty;

                    switch (Application.platform)
                    {
                    case RuntimePlatform.Android:
                        storeName = GooglePlay.Name;
                        break;

                    case RuntimePlatform.IPhonePlayer:
                        storeName = AppleAppStore.Name;
                        break;

                    case RuntimePlatform.WindowsPlayer:
                    case RuntimePlatform.WindowsEditor:
                    case RuntimePlatform.OSXPlayer:
                    case RuntimePlatform.OSXEditor:
                        storeName = UnityEditorStore;
                        break;
                    }

                    if (!string.IsNullOrEmpty(storeName))
                    {
                        ids.Add(productDefinition.storeSpecificId, storeName);
                    }

                    builder.AddProduct(productDefinition.storeSpecificId, productDefinition.type, ids);
                }
            }

            // 非同期の課金処理の初期化を開始.
            UnityPurchasing.Initialize(this, builder);
        }
Esempio n. 20
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            Webcam.Retrieve(Frame);
            var imageFrame = Frame.ToImage <Gray, byte>();

            if (TimerCounter < TimeLimit)
            {
                TimerCounter++;

                if (imageFrame != null)
                {
                    Rectangle[] faces = FaceDetection.DetectMultiScale(imageFrame, 1.3, 5);

                    if (faces.Any())
                    {
                        var processedImage = imageFrame.Copy(faces[0]).Resize(ProcessedImageWidth, ProcessedImageHeight, Inter.Cubic); // Will zoom into the rectangle it finds to only see that.
                        Faces.Add(processedImage.Mat);
                        IDs.Add(userId);
                        ScanCounter++;
                        OutputBox.AppendText($"{ScanCounter} Successful Scans Taken...{Environment.NewLine}");
                        OutputBox.ScrollToCaret();
                    }
                }
            }
            else
            {
                FaceRecognition.Train(new VectorOfMat(Faces.ToArray()), new VectorOfInt(IDs.ToArray())); // Here we finally train on face and ID collection we just captures and is written to the pathfile "YMLPath"
                FaceRecognition.Write(YMLPath);

                Timer.Stop();
                TimerCounter = 0;

                //IDBox.Clear();
                nameBox.Clear();

                TrainButton.Enabled = !TrainButton.Enabled;
                //IDBox.Enabled = !IDBox.Enabled;
                nameBox.Enabled = !nameBox.Enabled;

                OutputBox.AppendText($"Training Complete! {Environment.NewLine}");
                //MessageBox.Show("Training Complete");

                doneTraining = true;

                Timer          = new Timer();
                Timer.Interval = 500;         // ticks every 0.5 sec
                Timer.Tick    += Timer_Tick1; // this method gets called every time the timer fires.
                Timer.Start();
            }
        }
Esempio n. 21
0
        public IDs GetIDs()
        {
            IDs productIDs = new IDs();

            for (int i = 0; i < localIDs.Count; i++)
            {
                string localId = localIDs[i].GetIdentifier();
                if (string.IsNullOrEmpty(localId))
                {
                    localId = id;
                }

                productIDs.Add(localId, ((IAPPlatform)i).ToString());
            }

            return(productIDs);
        }
        public override void VisitVariableDeclaration(VariableDeclarationSyntax node)
        {
            string type = GetType(node.Type.ToString());

            if (IsRequiredType(type) && !IsInUsing(node))
            {
                var variableIds = node.Variables.Select(v => v.Identifier.ValueText);
                foreach (var variableId in variableIds)
                {
                    if (!IDs.ContainsKey(variableId))
                    {
                        IDs.Add(variableId, type);
                    }
                }
            }
            base.VisitVariableDeclaration(node);
        }
Esempio n. 23
0
        public void SetupProducts()
        {
#if USE_IAP
            var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

            foreach (var product in consumableProductList)
            {
                var storeIDs = new IDs();
                foreach (var storeId in product.storeIDs)
                {
                    storeIDs.Add(storeId.id, storeId.GetPlatformName());
                }
                builder.AddProduct(product.id, ProductType.Consumable, storeIDs);
            }

            UnityPurchasing.Initialize(this, builder);
#endif
        }
Esempio n. 24
0
        public static void InitializePurchasing()
        {
            #if EM_UIAP
            if (IsInitialized())
            {
                return;
            }

            // Create a builder, first passing in a suite of Unity provided stores.
            var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

            // Add products
            foreach (IAPProduct pd in EM_Settings.InAppPurchasing.Products)
            {
                if (pd.StoreSpecificIds != null && pd.StoreSpecificIds.Length > 0)
                {
                    // Add store-specific id if any
                    IDs storeIDs = new IDs();

                    foreach (IAPProduct.StoreSpecificId sId in pd.StoreSpecificIds)
                    {
                        storeIDs.Add(sId.id, new string[] { GetStoreName(sId.store) });
                    }

                    // Add product with store-specific ids
                    builder.AddProduct(pd.Id, GetProductType(pd.Type), storeIDs);
                }
                else
                {
                    // Add product using store-independent id
                    builder.AddProduct(pd.Id, GetProductType(pd.Type));
                }
            }

            // Kick off the remainder of the set-up with an asynchrounous call, passing the configuration
            // and this class' instance. Expect a response either in OnInitialized or OnInitializeFailed.
            UnityPurchasing.Initialize(_storeListener, builder);
            #else
            if (Debug.isDebugBuild)
            {
                Debug.Log("InitializePurchase FAILED: SDK missing. Please enable Unity Purchasing service.");
            }
            #endif
        }
Esempio n. 25
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            webCam.Retrieve(frame);
            var imageFrame = frame.ToImage <Gray, byte>();

            if (TimerCounter < TimeLimit)
            {
                TimerCounter++;

                if (imageFrame != null)
                {
                    var faces = faceDetection.DetectMultiScale(imageFrame, 1.3, 5);

                    if (faces.Count() > 0)
                    {
                        var processedImage = imageFrame.Copy(faces[0]).Resize(ProcessedImageWidth, ProcessedImageHeight, Emgu.CV.CvEnum.Inter.Cubic);
                        Faces.Add(processedImage);
                        IDs.Add(Convert.ToInt32(IdBox.Text));
                        ScanCounter++;
                        OutPutBox.AppendText($"{ScanCounter} Success Scan Taken... {Environment.NewLine}");
                        OutPutBox.ScrollToCaret();
                    }
                }
            }
            else
            {
                Mat[] faceImages = new Mat[Faces.Count];

                faceImages = Faces.Select(c => c.Mat).ToArray();

                faceRecognition.Train(faceImages, IDs.ToArray());
                faceRecognition.Write(YMLPath);
                timer.Stop();
                Trainbottom.Enabled = !Trainbottom.Enabled;
                IdBox.Enabled       = !IdBox.Enabled;

                OutPutBox.AppendText($"Training Complete!{Environment.NewLine}");
                MessageBox.Show("Training Completed!");

                PredictButton.Enabled = true;
            }
        }
Esempio n. 26
0
    private void init()
    {
        StandardPurchasingModule first = StandardPurchasingModule.Instance();

        first.useFakeStoreUIMode = FakeStoreUIMode.StandardUser;
        ConfigurationBuilder builder = ConfigurationBuilder.Instance(first, Array.Empty <IPurchasingModule>());

        builder.useCatalogProvider = true;
        builder.Configure <IMoolahConfiguration>().appKey  = "ea6cb49d4d909aa31691e0472c6044f4";
        builder.Configure <IMoolahConfiguration>().hashKey = "cc";
        builder.Configure <IUnityChannelConfiguration>().fetchReceiptPayloadOnPurchase = false;
        ProductCatalog catalog = ProductCatalog.LoadDefaultCatalog();
        int            key     = 0;

        foreach (ProductCatalogItem item in catalog.allValidProducts)
        {
            if (item.allStoreIDs.Count > 0)
            {
                IDs storeIDs = new IDs();
                foreach (StoreID eid in item.allStoreIDs)
                {
                    string[] stores = new string[] { eid.store };
                    storeIDs.Add(eid.id, stores);
                }
                this.mProductList.Add(key, item.id);
                key++;
                builder.AddProduct(item.id, item.type, storeIDs);
            }
            else
            {
                this.mProductList.Add(key, item.id);
                key++;
                builder.AddProduct(item.id, item.type);
            }
        }
        builder.Configure <IMoolahConfiguration>().SetMode(CloudMoolahMode.AlwaysSucceed);
        this.validator = new CrossPlatformValidator(GooglePlayTangle.Data(), AppleTangle.Data(), Application.identifier);
        UnityPurchasing.Initialize(this, builder);
    }
Esempio n. 27
0
        /// <summary>
        /// 課金システム初期化.
        /// </summary>
        private void InitializePurchasing(ProductDefinition[] productDefinitions)
        {
            storeController        = null;
            storeExtensionProvider = null;

            // Unityの課金システム構築.
            var module = StandardPurchasingModule.Instance();

            #if UNITY_EDITOR
            module.useFakeStoreUIMode = FakeStoreUIMode.StandardUser;
            #endif

            var builder = ConfigurationBuilder.Instance(module);

            if (productDefinitions.Any())
            {
                foreach (var productDefinition in productDefinitions)
                {
                    var ids = new IDs();

                    var storeName = DummyStoreName;

                    if (storePurchasing != null)
                    {
                        storeName = storePurchasing.GetStoreName();
                    }

                    if (!string.IsNullOrEmpty(storeName))
                    {
                        ids.Add(productDefinition.storeSpecificId, storeName);
                    }

                    builder.AddProduct(productDefinition.storeSpecificId, productDefinition.type, ids);
                }
            }

            // 非同期の課金処理の初期化を開始.
            UnityPurchasing.Initialize(this, builder);
        }
Esempio n. 28
0
        /// <summary>
        /// Randomly creates ID without a chance of a duplicate.
        /// </summary>
        /// <returns></returns>
        private int CreateId()
        {
            var rnd       = new Random();
            int rndNumber = -1;

            do
            {
                int num = rnd.Next();

                //If IDs contains the randomly generated number (if a duplication would occur).
                if (!IDs.Contains(num))
                {
                    rndNumber = rnd.Next();
                }

                //rndNumber cannot be -1 as integers returned from rnd.Next() is always a natural number.
            } while (rndNumber == -1);

            //Add the generated number to the list of used IDs
            IDs.Add(rndNumber);
            return(rndNumber);
        }
Esempio n. 29
0
        public IDs GetIDs()
        {
			IDs productIDs = new IDs();
			
			for(int i = 0; i < localIDs.Count; i++)
			{
				string localId = localIDs[i].GetIdentifier();
				if(string.IsNullOrEmpty(localId))
					localId = id;
						
				productIDs.Add(localId, ((IAPPlatform)i).ToString());
			}
			
			return productIDs;
        }
Esempio n. 30
0
    public void Awake()
    {
        StandardPurchasingModule module = StandardPurchasingModule.Instance();

        // The FakeStore supports: no-ui (always succeeding), basic ui (purchase pass/fail), and
        // developer ui (initialization, purchase, failure code setting). These correspond to
        // the FakeStoreUIMode Enum values passed into StandardPurchasingModule.useFakeStoreUIMode.
        module.useFakeStoreUIMode = FakeStoreUIMode.StandardUser;

        ConfigurationBuilder builder = ConfigurationBuilder.Instance(module);

        // Set this to true to enable the Microsoft IAP simulator for local testing.
        builder.Configure <IMicrosoftConfiguration>().useMockBillingSystem = false;

        m_IsGooglePlayStoreSelected =
            Application.platform == RuntimePlatform.Android && module.appStore == AppStore.GooglePlay;

#if AGGRESSIVE_INTERRUPT_RECOVERY_GOOGLEPLAY
        // For GooglePlay, if we have access to a backend server to deduplicate purchases, query purchase history
        // when attempting to recover from a network-interruption encountered during purchasing. Strongly recommend
        // deduplicating transactions across app reinstallations because this relies upon the on-device, deletable
        // TransactionLog database.
        builder.Configure <IGooglePlayConfiguration>().aggressivelyRecoverLostPurchases = true;
        // Use purchaseToken instead of orderId for all transactions to avoid non-unique transactionIDs for a
        // single purchase; two ProcessPurchase calls for one purchase, differing only by which field of the receipt
        // is used for the Product.transactionID. Automatically true if aggressivelyRecoverLostPurchases is enabled
        // and this API is not called at all.
        builder.Configure <IGooglePlayConfiguration>().UsePurchaseTokenForTransactionId(true);
#endif

        // Define our products.
        // Either use the Unity IAP Catalog, or manually use the ConfigurationBuilder.AddProduct API.
        // Use IDs from both the Unity IAP Catalog and hardcoded IDs via the ConfigurationBuilder.AddProduct API.

        // Use the products defined in the IAP Catalog GUI.
        // E.g. Menu: "Window" > "Unity IAP" > "IAP Catalog", then add products, then click "App Store Export".
        ProductCatalog catalog = ProductCatalog.LoadDefaultCatalog();

        foreach (ProductCatalogItem product in catalog.allValidProducts)
        {
            if (product.allStoreIDs.Count > 0)
            {
                IDs ids = new IDs();
                foreach (StoreID storeID in product.allStoreIDs)
                {
                    ids.Add(storeID.id, storeID.store);
                }
                builder.AddProduct(product.id, product.type, ids);
            }
            else
            {
                builder.AddProduct(product.id, product.type);
            }
        }

        // In this case our products have the same identifier across all the App stores,
        // except on the Mac App store where product IDs cannot be reused across both Mac and
        // iOS stores.
        // So on the Mac App store our products have different identifiers,
        // and we tell Unity IAP this by using the IDs class.

        builder.AddProduct("100.gold.coins", ProductType.Consumable, new IDs
        {
            { "com.unity3d.unityiap.unityiapdemo.100goldcoins.7", MacAppStore.Name },
            { "100.gold.coins", AmazonApps.Name },
            { "100.gold.coins", AppleAppStore.Name }
        }
#if USE_PAYOUTS
                           , new List <PayoutDefinition> {
            new PayoutDefinition(PayoutType.Item, "", 1, "item_id:76543"),
            new PayoutDefinition(PayoutType.Currency, "gold", 50)
        }
#endif //USE_PAYOUTS
                           );

        builder.AddProduct("500.gold.coins", ProductType.Consumable, new IDs
        {
            { "com.unity3d.unityiap.unityiapdemo.500goldcoins.7", MacAppStore.Name },
            { "500.gold.coins", AmazonApps.Name },
        }
#if USE_PAYOUTS
                           , new PayoutDefinition(PayoutType.Currency, "gold", 500)
#endif //USE_PAYOUTS
                           );

        builder.AddProduct("300.gold.coins", ProductType.Consumable, new IDs()
#if USE_PAYOUTS
                           , new List <PayoutDefinition> {
            new PayoutDefinition(PayoutType.Item, "", 1, "item_id:76543"),
            new PayoutDefinition(PayoutType.Currency, "gold", 50)
        }
#endif //USE_PAYOUTS
                           );

        builder.AddProduct("sub1", ProductType.Subscription, new IDs());

        builder.AddProduct("sub2", ProductType.Subscription, new IDs());


        // Write Amazon's JSON description of our products to storage when using Amazon's local sandbox.
        // This should be removed from a production build.
        //builder.Configure<IAmazonConfiguration>().WriteSandboxJSON(builder.products);

        // This enables simulated purchase success for Samsung IAP.
        // You would remove this, or set to SamsungAppsMode.Production, before building your release package.
        builder.Configure <ISamsungAppsConfiguration>().SetMode(SamsungAppsMode.AlwaysSucceed);
        // This records whether we are using Samsung IAP. Currently ISamsungAppsExtensions.RestoreTransactions
        // displays a blocking Android Activity, so:
        // A) Unity IAP does not automatically restore purchases on Samsung Galaxy Apps
        // B) IAPDemo (this) displays the "Restore" GUI button for Samsung Galaxy Apps
        m_IsSamsungAppsStoreSelected =
            Application.platform == RuntimePlatform.Android && module.appStore == AppStore.SamsungApps;

#if INTERCEPT_PROMOTIONAL_PURCHASES
        // On iOS and tvOS we can intercept promotional purchases that come directly from the App Store.
        // On other platforms this will have no effect; OnPromotionalPurchase will never be called.
        builder.Configure <IAppleConfiguration>().SetApplePromotionalPurchaseInterceptorCallback(OnPromotionalPurchase);
        Debug.Log("Setting Apple promotional purchase interceptor callback");
#endif

#if RECEIPT_VALIDATION
        string appIdentifier;
        #if UNITY_5_6_OR_NEWER
        appIdentifier = Application.identifier;
        #else
        appIdentifier = Application.bundleIdentifier;
        #endif
        validator = new CrossPlatformValidator(GooglePlayTangle.Data(), AppleTangle.Data(), appIdentifier);
#endif

        // Now we're ready to initialize Unity IAP.
        UnityPurchasing.Initialize(this, builder);
    }
Esempio n. 31
0
    public void Awake()
    {
        var module = StandardPurchasingModule.Instance();

        // The FakeStore supports: no-ui (always succeeding), basic ui (purchase pass/fail), and
        // developer ui (initialization, purchase, failure code setting). These correspond to
        // the FakeStoreUIMode Enum values passed into StandardPurchasingModule.useFakeStoreUIMode.
        module.useFakeStoreUIMode = FakeStoreUIMode.StandardUser;

        var builder = ConfigurationBuilder.Instance(module);

        // This enables the Microsoft IAP simulator for local testing.
        // You would remove this before building your release package.
        builder.Configure <IMicrosoftConfiguration>().useMockBillingSystem = true;
        m_IsGooglePlayStoreSelected = Application.platform == RuntimePlatform.Android && module.appStore == AppStore.GooglePlay;

        // CloudMoolah Configuration setings
        // All games must set the configuration. the configuration need to apply on the CloudMoolah Portal.
        // CloudMoolah APP Key
        builder.Configure <IMoolahConfiguration>().appKey = "d93f4564c41d463ed3d3cd207594ee1b";
        // CloudMoolah Hash Key
        builder.Configure <IMoolahConfiguration>().hashKey = "cc";
        // This enables the CloudMoolah test mode for local testing.
        // You would remove this, or set to CloudMoolahMode.Production, before building your release package.
        builder.Configure <IMoolahConfiguration>().SetMode(CloudMoolahMode.AlwaysSucceed);
        // This records whether we are using Cloud Moolah IAP.
        // Cloud Moolah requires logging in to access your Digital Wallet, so:
        // A) IAPDemo (this) displays the Cloud Moolah GUI button for Cloud Moolah
        m_IsCloudMoolahStoreSelected = Application.platform == RuntimePlatform.Android && module.appStore == AppStore.CloudMoolah;

        // UnityChannel, provides access to Xiaomi MiPay.
        // Products are required to be set in the IAP Catalog window.  The file "MiProductCatalog.prop"
        // is required to be generated into the project's
        // Assets/Plugins/Android/assets folder, based off the contents of the
        // IAP Catalog window, for MiPay.
        m_IsUnityChannelSelected = Application.platform == RuntimePlatform.Android && module.appStore == AppStore.XiaomiMiPay;
        // UnityChannel supports receipt validation through a backend fetch.
        builder.Configure <IUnityChannelConfiguration>().fetchReceiptPayloadOnPurchase = m_FetchReceiptPayloadOnPurchase;

        // Define our products.
        // Either use the Unity IAP Catalog, or manually use the ConfigurationBuilder.AddProduct API.
        // Use IDs from both the Unity IAP Catalog and hardcoded IDs via the ConfigurationBuilder.AddProduct API.

        // Use the products defined in the IAP Catalog GUI.
        // E.g. Menu: "Window" > "Unity IAP" > "IAP Catalog", then add products, then click "App Store Export".
        var catalog = ProductCatalog.LoadDefaultCatalog();

        foreach (var product in catalog.allProducts)
        {
            if (product.allStoreIDs.Count > 0)
            {
                var ids = new IDs();
                foreach (var storeID in product.allStoreIDs)
                {
                    ids.Add(storeID.id, storeID.store);
                }
                builder.AddProduct(product.id, product.type, ids);
            }
            else
            {
                builder.AddProduct(product.id, product.type);
            }
        }

        // In this case our products have the same identifier across all the App stores,
        // except on the Mac App store where product IDs cannot be reused across both Mac and
        // iOS stores.
        // So on the Mac App store our products have different identifiers,
        // and we tell Unity IAP this by using the IDs class.
        builder.AddProduct("100.gold.coins", ProductType.Consumable, new IDs
        {
            { "100.gold.coins.mac", MacAppStore.Name },
            { "000000596586", TizenStore.Name },
            { "com.ff", MoolahAppStore.Name },
        }
#if USE_PAYOUTS
                           , new PayoutDefinition(PayoutType.Currency, "gold", 100)
#endif //USE_PAYOUTS
                           );

        builder.AddProduct("500.gold.coins", ProductType.Consumable, new IDs
        {
            { "500.gold.coins.mac", MacAppStore.Name },
            { "000000596581", TizenStore.Name },
            { "com.ee", MoolahAppStore.Name },
        }
#if USE_PAYOUTS
                           , new PayoutDefinition(PayoutType.Currency, "gold", 500)
#endif //USE_PAYOUTS
                           );

        builder.AddProduct("sword", ProductType.NonConsumable, new IDs
        {
            { "sword.mac", MacAppStore.Name },
            { "000000596583", TizenStore.Name },
        }
#if USE_PAYOUTS
                           , new List <PayoutDefinition> {
            new PayoutDefinition(PayoutType.Item, "", 1, "item_id:76543"),
            new PayoutDefinition(PayoutType.Currency, "gold", 50)
        }
#endif //USE_PAYOUTS
                           );

        builder.AddProduct("subscription", ProductType.Subscription, new IDs
        {
            { "subscription.mac", MacAppStore.Name }
        });

        // Write Amazon's JSON description of our products to storage when using Amazon's local sandbox.
        // This should be removed from a production build.
        builder.Configure <IAmazonConfiguration>().WriteSandboxJSON(builder.products);

        // This enables simulated purchase success for Samsung IAP.
        // You would remove this, or set to SamsungAppsMode.Production, before building your release package.
        builder.Configure <ISamsungAppsConfiguration>().SetMode(SamsungAppsMode.AlwaysSucceed);
        // This records whether we are using Samsung IAP. Currently ISamsungAppsExtensions.RestoreTransactions
        // displays a blocking Android Activity, so:
        // A) Unity IAP does not automatically restore purchases on Samsung Galaxy Apps
        // B) IAPDemo (this) displays the "Restore" GUI button for Samsung Galaxy Apps
        m_IsSamsungAppsStoreSelected = Application.platform == RuntimePlatform.Android && module.appStore == AppStore.SamsungApps;


        // This selects the GroupId that was created in the Tizen Store for this set of products
        // An empty or non-matching GroupId here will result in no products available for purchase
        builder.Configure <ITizenStoreConfiguration>().SetGroupId("100000085616");


        #if RECEIPT_VALIDATION
        string appIdentifier;
        #if UNITY_5_6_OR_NEWER
        appIdentifier = Application.identifier;
        #else
        appIdentifier = Application.bundleIdentifier;
        #endif
        validator = new CrossPlatformValidator(GooglePlayTangle.Data(), AppleTangle.Data(),
                                               UnityChannelTangle.Data(), appIdentifier);
        #endif

        Action initializeUnityIap = () =>
        {
            // Now we're ready to initialize Unity IAP.
            UnityPurchasing.Initialize(this, builder);
        };

        bool needExternalLogin = m_IsUnityChannelSelected;

        if (!needExternalLogin)
        {
            initializeUnityIap();
        }
        else
        {
            // Call UnityChannel initialize and (later) login asynchronously

            // UnityChannel configuration settings. Required for Xiaomi MiPay.
            // Collect this app configuration from the Unity Developer website at
            // [2017-04-17 PENDING - Contact support representative]
            // https://developer.cloud.unity3d.com/ providing your Xiaomi MiPay App
            // ID, App Key, and App Secret. This permits Unity to proxy from the
            // user's device into the MiPay system.
            // IMPORTANT PRE-BUILD STEP: For mandatory Chinese Government app auditing
            // and for MiPay testing, enable debug mode (test mode)
            // using the `AppInfo.debug = true;` when initializing Unity Channel.

            AppInfo unityChannelAppInfo = new AppInfo();
            unityChannelAppInfo.appId     = "abc123appId";
            unityChannelAppInfo.appKey    = "efg456appKey";
            unityChannelAppInfo.clientId  = "hij789clientId";
            unityChannelAppInfo.clientKey = "klm012clientKey";
            unityChannelAppInfo.debug     = false;

            // Shared handler for Unity Channel initialization, here, and login, later
            unityChannelLoginHandler = new UnityChannelLoginHandler();
            unityChannelLoginHandler.initializeFailedAction = (string message) =>
            {
                Debug.LogError("Failed to initialize and login to UnityChannel: " + message);
            };
            unityChannelLoginHandler.initializeSucceededAction = () =>
            {
                initializeUnityIap();
            };

            StoreService.Initialize(unityChannelAppInfo, unityChannelLoginHandler);
        }
    }