Introduction
This component handles both crafting menu types – The Blueprint Queue menu and the Blueprint Select Menu. It also keeps all the Blueprints available in the game.
Setting up
There is a prefab Crafting_UI located in /prefabs/UI.
Setting up without the prefab requires a few more components to be assigned for the Blueprint Menu’s including the menu panels, the Buttons, Blueprint Select Slots and Blueprint Queue Slots. There are also prefabs for these located in /prefabs/UI and then BlueprintSelectMenu and CrafterQueueMenu.
Note – If your game is using the Crafting Queue menu for Crafters, both the required menus will be needed. As when clicking in the Crafting Queue Slot, it will then bring up the Blueprint Select menu to choose a Blueprint for that Queue slot.
There is null checking throughout, so use what you need for your game.
This component should be placed under a Canvas.
Settings
Blueprints
Add all of your games Blueprints into this list.
Blueprint Select Slots
Assign all of the Blueprint Select Slots – These each hold a Blueprint, that can then be refreshed in the slot showing its result, materials and craft time.
Blueprints Panel
Assign the Blueprints menu gameobject that will open and close when triggered depending on the Crafter Click Method.
Close Button
Assign the Button to close the Blueprints menu.
Clear Button
Assign the Button to clear the Blueprint selection and return null to the Crafter. This is often in the Blueprint Select Slot list.
Crafting Queue Panel
Assign the Crafting Queue menu gameobject that will open and close when triggered depending on the Crafter Click Method.
Current Craft Icon
Assign an Image component to display the Blueprint result Icon which is currently being crafted.
Craft Name Text
Assign a TextMeshProUGUI component to display the Blueprint result name which is currently being crafted.
Blueprint Queue Slots
Assign all of the Blueprint Queue Slots – These each hold a Blueprint, that can then be refreshed in the slot showing its Icon.
Crafter Queue Close Button
Assign a Button component to close the Crafter Queue menu.
Event
OnBlueprintUnlockEvent
Triggers when a Blueprint is unlocked – you can unlock the next Blueprint with UnlockNextBlueprint
Scripting
//Action
//Triggers when a Blueprint is unlocked with UnlockNextBlueprint
public Action<Blueprint> OnBlueprintUnlockAction;
//Example
public void Start()
{
CraftingManager.Instance.OnBlueprintUnlockAction += (blueprint) => DoSomething(blueprint);
}
/// <summary>
/// Get a Blueprint by its id
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public Blueprint GetBlueprintByID(int id)
/// <summary>
/// Close the crafting queue menu
/// </summary>
public void CloseCrafterQueueMenu()
/// <summary>
/// This will assign all blueprints to each BlueprintSelectSlot. You may want to call this if unlocking a new Blueprint not through the UnlockNextBlueprint function
/// </summary>
public void AssignBlueprints()
/// <summary>
/// This will assign all blueprints to each BlueprintSelectSlot based on the given BlueprintGroup. You may want to call this if unlocking a new Blueprint not through the UnlockNextBlueprint function
/// <param name="blueprintGroup">The blueprintGroup to populate the blueprints menu with</param>
/// </summary>
public void AssignBlueprints(BlueprintGroup blueprintGroup)
/// <summary>
/// Unlock the next blueprint in the order assigned in the list of blueprints that is not currently unlocked
/// </summary>
public void UnlockNextBlueprint()
/// <summary>
/// Unlock the next blueprint in the order assigned in the BlueprintGroup that is not currently unlocked
/// <param name="blueprintGroup">The blueprintGroup order to use for the next unlock</param>
/// </summary>
public void UnlockNextBlueprint(BlueprintGroup blueprintGroup)
/// <summary>
/// Opens or closes the blueprints panel depending on the bool given
/// </summary>
/// <param name="visible"></param>
public void SetBlueprintPanelVisible(bool visible)
/// <summary>
/// Is the blueprints panel open?
/// </summary>
/// <returns></returns>
public bool IsBlueprintsPanelOpen()
/// <summary>
/// Is the crafting queue panel open?
/// </summary>
/// <returns></returns>
public bool IsCraftingQueuePanelOpen()
/// <summary>
/// Returns a Blueprint to the given Crafter that asked for it. Returns null if selection was cancelled or cleared
/// </summary>
/// <param name="crafter">The crafter that is asking for a Blueprint</param>
/// <param name="onResult">The Action that returns the Blueprint and whether the selection was cleared</param>
/// <returns></returns>
public IEnumerator GetBlueprint(Crafter crafter, System.Action<Blueprint, bool> onResult)
/// <summary>
/// Manually choose a blueprint once the blueprint select menu is open
/// </summary>
/// <param name="blueprint"></param>
public void ChooseBlueprint(Blueprint blueprint)
/// <summary>
/// Pause the current timer on the crafter queue menu
/// </summary>
private void PauseCurrentTimer()
/// <summary>
/// Resume the current timer on the crafter queue menu
/// </summary>
private void ResumeCurrentTimer()
/// <summary>
/// Set up the Crafting Queue menu with a given Crafter
/// </summary>
/// <param name="crafter"></param>
public void InitialiseCrafterMenu(Crafter crafter)
/// <summary>
/// Use this refresh the crafter queue
/// </summary>
public void RefreshBlueprintsQueue()
/// <summary>
/// Removes a blueprint from the queue from the BlueprintQueueSlot that is given
/// </summary>
/// <param name="blueprintQueueSlot"></param>
public void ClearBlueprintFromQueue(BlueprintQueueSlot blueprintQueueSlot)