public void FinishProduct()
 {
     if (craftingCoroutine != null)
     {
         input = new Carryable(recipe.recipe.output[0].item);
         recipe = null;
         craftingCoroutine = null;
     }
 }
    protected void StartCraft(Item item, int index)
    {
        pipeline[index].input = item;

        RecipeItemScriptableObject recipe = GetRecipeForItem(item);

        if (recipe != null)
        {
            pipeline[index].input.Unreturn();
            pipeline[index].recipe = recipe;
            pipeline[index].craftingStart = Time.time;
            pipeline[index].craftingEnd = Time.time + recipe.recipe.craftTime;
            pipeline[index].craftingCoroutine = StartCoroutine(WaitForCraftingTime(index));
        }
    }
Esempio n. 3
0
        public void StartProcess(RecipeItemScriptableObject recipe)
        {
            if (craftingCoroutine == null)
            {
                foreach (var item in input)
                {
                    collectiveGarbageCount += item.data.garbageValue;
                }

                craftingStart = Time.time;
                craftingEnd   = Time.time + recipe.recipe.craftTime;
                input.Clear();

                this.recipe = recipe;
            }
        }
Esempio n. 4
0
    void Craft(RecipeItemScriptableObject recipe)
    {
        pipeline.StartProcess(recipe);
        pipeline.craftingCoroutine = StartCoroutine(WaitForCraftingTime());

        /*
         * Dictionary<string, int> inputItemMap = new Dictionary<string, int>();
         * Dictionary<string, int> recipeItemMap = new Dictionary<string, int>();
         *
         * foreach (var item in inputItems)
         * {
         *      if (inputItemMap.ContainsKey(item.data.id))
         *              inputItemMap[item.data.id]++;
         *      else
         *              inputItemMap.Add(item.data.id, 1);
         * }
         *
         * foreach (var item in recipe.recipe.input)
         * {
         *      if (recipeItemMap.ContainsKey(item.item.id))
         *              recipeItemMap[item.item.id]++;
         *      else
         *              recipeItemMap.Add(item.item.id, Mathf.Max(item.count, 1));
         * }
         *
         * for (int i = recipeItemMap.Count - 1; i > -1; i--)
         * {
         *      string inputId = inputItemMap.Keys.ToArray()[i];
         *      int inputCount = inputItemMap.Values.ToArray()[i];
         *
         *      for (int j = 0; j < inputCount; j++)
         *      {
         *              inputItems.Remove(GetItem(inputId));
         *      }
         * }
         *
         * currentRecipeCrafting = recipe;
         * craftingStart = Time.time;
         * craftingEnd = Time.time + currentRecipeCrafting.recipe.craftTime;
         * crafting = true;
         *
         * craftingCoroutine = StartCoroutine(WaitForCraftingTime());*/

        OnWorkAreaUpdate?.Invoke(this);
    }