Esempio n. 1
0
        public void CheckRequirement()
        {
            var requiredItems    = RecipeManager.GetItemRequirement(currentItem.Code);
            var slotRequirements = requiredItems.Count;

            if (CookingEntity.SlotRequiredLevel(slotRequirements) > CookingEntity.NeededSkillLevel)
            {
                SetVisibility(SlotLock);
                return;
            }

            if (RecipeManager.HaveEnoughIngredients(currentRecipe, AvailableIngredients))
            {
                SetVisibility(Available);

                if (!SeenRecipes.Contains(currentItem.Code))
                {
                    SeenRecipes.Add(currentItem.Code);
                }
            }
            else
            {
                SetVisibility(CookedRecipes.Contains(currentItem.Code) ||
                              SeenRecipes.Contains(currentItem.Code) ?
                              Locked : Hidden);
            }
        }
 public static void Show(Item currentItem, bool sameItem = false)
 {
     if (instance != null)
     {
         instance.Show(currentItem, RecipeManager.GetItemRequirement(currentItem.Data.code), sameItem);
     }
 }
Esempio n. 3
0
        public ItemCode GetItem()
        {
            var lastCookItemCode = CookingEntity.LastCookedItem;

            return(RecipeManager.HaveEnoughIngredients(lastCookItemCode, CookingHandler.AvailableIngredients) ?
                   lastCookItemCode : GetCookableRecipe());
        }
Esempio n. 4
0
        private void TakeRequiredIngredients(Item item)
        {
            var requiredItems = RecipeManager.GetItemRequirement(item.Code);

            foreach (var requiredItem in requiredItems)
            {
                handler.TakeIngredient(requiredItem);
            }
        }
Esempio n. 5
0
 public override void SetData(Data data)
 {
     SetupData(data.item,
               RecipeManager.GetItemRequirement(data.item.Data.code),
               data.refreshItem,
               data.isLocked,
               data.isSlotLocked,
               data.quickCookLocked,
               data.price);
 }
        public void ReturnItem(Item item)
        {
            var requiredItems = RecipeManager.GetItemRequirement(item.Code);

            foreach (var requiredItem in requiredItems)
            {
                handler.ReturnIngredient(requiredItem);
            }

            recipeLoader.RefreshRecipeRequirements();
        }
        public void ReturnIngredients()
        {
            if (cookingSlots.Count > 0)
            {
                foreach (var cookingSlot in cookingSlots)
                {
                    var requiredItems = RecipeManager.GetItemRequirement(cookingSlot.Item.Code);
                    foreach (var requiredItem in requiredItems)
                    {
                        handler.ReturnIngredient(requiredItem, cookingSlot.CurrentItemCount);
                    }
                }
            }

            ClearList();
        }
Esempio n. 8
0
        private ItemCode GetCookableRecipe()
        {
            var cookableRecipes = new List <ItemCode>();

            foreach (var recipe in RecipeManager.Recipes)
            {
                if (RecipeManager.HaveEnoughIngredients(recipe, CookingHandler.AvailableIngredients) &&
                    SlotRequiredLevel(recipe.itemsRequired.Count) <= Stats.SkillLevel(Skill.Type.Cooking))
                {
                    cookableRecipes.Add(recipe.RecipeOutcome);
                }
            }

            if (cookableRecipes.Count > 0)
            {
                return(cookableRecipes[Random.Range(0, cookableRecipes.Count - 1)]);
            }

            return(CookingEntity.DefaultCookItem);
        }
Esempio n. 9
0
        private float GetTotalCost()
        {
            var ingredients = RecipeManager.GetItemRequirement(currentItem.Code);

            return(ingredients.Sum(ingredient => ingredient.Data.price));
        }