Exemplo n.º 1
0
 public void SelectCraftRecipe(CraftRecipe recipe)
 {
     currentCraftRecipe = recipe;
     if (recipe == null)
     {
         return;
     }
     UpdateSelection();
 }
Exemplo n.º 2
0
 public void Craft(CraftRecipe recipe)
 {
     if (localInventory.RemoveItems(recipe.GetRequirementsAsDictionary))
     {
         if (!localInventory.AddItem(recipe.result, recipe.resultAmount))
         {
             localInventory.DropItem(recipe.result, recipe.resultAmount);
         }
     }
 }
Exemplo n.º 3
0
 private CraftRecipeUI GetCraftRecipe(CraftRecipe recipe)
 {
     if (!craftRecipes.ContainsKey(recipe))
     {
         var result = Instantiate(craftRecipePrefab, craftRecipeRoot);
         craftRecipes.Add(recipe, result);
         result.SetRecipe(recipe);
         return(result);
     }
     return(craftRecipes[recipe]);
 }
Exemplo n.º 4
0
 public bool TryCraft(CraftRecipe recipe)
 {
     if (!craftRecipes.Contains(recipe))
     {
         return(false);
     }
     if (localInventory.TryRemoveItems(recipe.GetRequirementsAsDictionary))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 5
0
 public void ReciveSelectionCallback(CraftRecipe recipe)
 {
     if (recipe == this.recipe)
     {
         return;
     }
     if (selected)
     {
         selected = false;
         onDeSelectCallback?.Invoke();
     }
 }
Exemplo n.º 6
0
        public void StartCrafting(CraftTable craftTable)
        {
            currentCraftTable = craftTable;

            if (currentCraftRecipe != null)
            {
                craftSelectEvent?.InvokeWithCraftRecipe(null);
                SelectCraftRecipe(null);
            }
            craftButton.interactable = false;
            currentCraftRecipe       = null;
            RefreshCrafting();
        }
Exemplo n.º 7
0
        public void SetRecipe(CraftRecipe craftRecipe)
        {
            recipe = craftRecipe;
            resultImage.texture = craftRecipe.result.uiSprite;
            var count = craftRecipe.resultAmount;

            if (count == 1)
            {
                resultCount.gameObject.SetActive(false);
            }
            else
            {
                resultCount.gameObject.SetActive(true);
                resultCount.text = $"x {count}";
            }


            foreach (var item in craftRecipe.CraftRequirements)
            {
                var res = GetUIItem(item.item);
                res.SetItemData(item.item, item.amount);
            }
        }
Exemplo n.º 8
0
 public void InvokeWithCraftRecipe(CraftRecipe recipe)
 {
     Invoke(recipe);
 }