Пример #1
0
    public void CheckRecipe()
    {
        Recipe recipe = FindReadyRecipe();

        if (recipe != null)
        {
            GameObject obj = GameObject.Find("CollectionCore");
            collectionCore = obj.GetComponent <CollectionCore>();

            Dictionary <string, ConversionFormula> formulas = collectionCore.GetFormulas();
            ConversionFormula formulaToUse = formulas [recipe.formulaName];

            User.CurrentProfile.Entitlements.ApplyConversion(formulaToUse.Id, (ConversionResult result, NPNFError error) => {
                if (error == null)
                {
                    InventoryController ctrler = (InventoryController)AppController.Instance.GetController(Controller.INVENTORY);

                    foreach (Entitlement entitlement in result.Added)
                    {
                        ctrler.OnNewInventory(entitlement.Id);
                    }
                    recipe.isDone = true;
                }
                else if (error != null)
                {
                    Debug.LogError("Conversion failed" + error);
                    AppController.Instance.IsNetworkError(error);
                }
            });
        }
    }