public void SelectCraftRecipe(CraftRecipe recipe) { currentCraftRecipe = recipe; if (recipe == null) { return; } UpdateSelection(); }
public void Craft(CraftRecipe recipe) { if (localInventory.RemoveItems(recipe.GetRequirementsAsDictionary)) { if (!localInventory.AddItem(recipe.result, recipe.resultAmount)) { localInventory.DropItem(recipe.result, recipe.resultAmount); } } }
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]); }
public bool TryCraft(CraftRecipe recipe) { if (!craftRecipes.Contains(recipe)) { return(false); } if (localInventory.TryRemoveItems(recipe.GetRequirementsAsDictionary)) { return(true); } return(false); }
public void ReciveSelectionCallback(CraftRecipe recipe) { if (recipe == this.recipe) { return; } if (selected) { selected = false; onDeSelectCallback?.Invoke(); } }
public void StartCrafting(CraftTable craftTable) { currentCraftTable = craftTable; if (currentCraftRecipe != null) { craftSelectEvent?.InvokeWithCraftRecipe(null); SelectCraftRecipe(null); } craftButton.interactable = false; currentCraftRecipe = null; RefreshCrafting(); }
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); } }
public void InvokeWithCraftRecipe(CraftRecipe recipe) { Invoke(recipe); }