protected virtual void SetBlueprintResults(CraftingBlueprint blueprint) { if (blueprintItemResultContainer != null) { if (blueprint != null) { foreach (Transform child in blueprintItemResultContainer) { Destroy(child.gameObject); } foreach (var row in blueprint.resultItems) { var wrapper = Instantiate <ItemCollectionSlotUIBase>(blueprintItemResultPrefab); wrapper.item = row.item; wrapper.item.currentStackSize = row.amount; wrapper.Repaint(); wrapper.item.currentStackSize = 1; // Reset wrapper.transform.SetParent(blueprintItemResultContainer); InventoryUtility.ResetTransform(wrapper.transform); } } else { foreach (Transform child in blueprintItemResultContainer) { Destroy(child.gameObject); } } } }
public override void SetCraftingBlueprint(CraftingBlueprint blueprint) { base.SetCraftingBlueprint(blueprint); if (window.isVisible == false) { return; } blueprintRequiredItemsPool.DestroyAll(); foreach (var item in blueprint.requiredItems) { var ui = blueprintRequiredItemsPool.Get(); item.item.currentStackSize = (uint)item.amount; ui.transform.SetParent(blueprintRequiredItemsContainer); InventoryUtility.ResetTransform(ui.transform); ui.item = item.item; if (InventoryManager.GetItemCount(item.item.ID, currentCategory.alsoScanBankForRequiredItems) >= item.amount) { ui.icon.color = itemsAvailableColor; } else { ui.icon.color = itemsNotAvailableColor; } ui.Repaint(); item.item.currentStackSize = 1; // Reset } }
public virtual void SetCraftingBlueprint(CraftingBlueprint blueprint) { currentBlueprint = blueprint; if (blueprint != null) { // Set all the details for the blueprint. if (blueprintTitle != null) { blueprintTitle.text = blueprint.name; } if (blueprintDescription != null) { blueprintDescription.text = blueprint.description; } if (blueprintCraftCost != null) { blueprintCraftCost.Repaint(blueprint.craftingCost); } } else { // Set all the details for the blueprint. if (blueprintTitle != null) { blueprintTitle.text = string.Empty; } if (blueprintDescription != null) { blueprintDescription.text = string.Empty; } if (blueprintCraftCost != null) { blueprintCraftCost.Repaint(new CurrencyDecorator()); } } blueprintCraftingProgress.Repaint(0f, 1f); SetBlueprintResults(blueprint); }
public CraftInfo(IEnumerator activeCraft, ICraftingActionValidator validator, AudioSource audioSource, CraftingCategory category, CraftingBlueprint blueprint) { this.activeCraft = activeCraft; this.validator = validator; this.audioSource = audioSource; this.category = category; this.blueprint = blueprint; this.craftAmount = 1; }
/// <summary> /// Crafts the item and triggers the coroutine method to handle the crafting itself. /// </summary> public virtual bool AddBlueprintToCraftingQueue(InventoryPlayer player, CraftingCategory category, CraftingBlueprint blueprint, int amount, ItemCollectionBase storeRewardsCollection, ItemCollectionBase removeItemsFromCollection) { var craftInfo = new CraftInfo(null, validator, audioSource, category, blueprint) { storeItemsInCollection = storeRewardsCollection, removeItemsFromCollection = removeItemsFromCollection, craftAmount = amount }; return(CraftItem(player, craftInfo)); }