// Update is called once per frame void Update() { // // bool bTextSet = false; // // First we ensure there is a gameobject selected GameObject selected = EventSystem.current.currentSelectedGameObject; if (null != selected) { // // We ensure the selected gameobject has an inventory blueprint InventoryBlueprint inventoryBlueprint = selected.GetComponentInChildren <InventoryBlueprint>(); if (null != inventoryBlueprint) { // // We can retrieve the blueprint ScriptableObjects.Blueprint selectedBlueprint = inventoryBlueprint.m_blueprint; // // If the blueprint is not null we can set its description if (null != selectedBlueprint) { // // update the description text depending on the current selected blueprint // If the blueprint is not unlocked, we simply display "???", otherwise we display the description // of the blueprint (which in fact is the description of the produced item) if (selectedBlueprint.StartLocked && !PartyInventory.Instance.IsBlueprintUnlocked(selectedBlueprint)) { m_descriptionText.text = "???"; bTextSet = true; } else { m_descriptionText.text = EventSystem.current.currentSelectedGameObject .GetComponentInChildren <InventoryBlueprint>().m_blueprint.Description; bTextSet = true; } } } } // // Set the text to null in case there is a problem and we don't set the text if (!bTextSet) { // // If we are in debug we display an error, otherwise we display nothing if (Debug.isDebugBuild) { m_descriptionText.text = "THERE IS A PROBLEM IN THE CRAFT INVENTORY"; // In debug we indicate there is an error } else { m_descriptionText.text = ""; //< Not in debug we put nothing } } }
/// <summary> /// Return true if the given blueprint is unlocked /// WARNING : A blueprint that starts unlocked will never be unlocked according to this method. It has to be used only /// for blueprints that are locked at the beginning of the game /// </summary> /// <param name="blueprint">The blueprint we want to check if it is unlocked (must be a blueprint that is locked at the beginning of the game)</param> /// <returns>True if this blueprint is unlocked or not</returns> public bool IsBlueprintUnlocked(ScriptableObjects.Blueprint blueprint) { // // We check in the unlocked blueprints if our blueprint is unlocked if (m_unlockedBlueprints.Contains(blueprint.name)) { return(true); } else { return(false); } }
public bool CanCraft(ScriptableObjects.Blueprint _blueprint) { // // Iterate over all the recipe elements foreach (var recipeItem in _blueprint.RecipeItems) { // // If we don't have enough resources, then we can't craft this blueprint if (!HasEnoughResources(recipeItem.m_item, recipeItem.m_quantity)) { return(false); } } // // We have enough fo all the neededd resources, we can craft the blueprint return(true); }