예제 #1
0
    private bool PutPart()
    {
        /*
         * Tries to put a part taken from inventory into the building. Returns true on success and false on failure.
         */

        Inventory inventory = Inventory.instance;

        foreach (var matN in matsNeeded)
        {
            BuildMaterial matL = BuildMaterial.GetByKey(matsLeft, matN.item);

            if (matL.count <= 0) // Check if this material has already been exhausted
            {
                continue;
            }

            if (inventory.Pull(matN.item))   // Takes the item from the inventory
            {
                matL.count--;
                return(true);
            }
        }

        return(false);
    }
예제 #2
0
    private bool IsFinished()
    {
        /*
         * Check if player has put every part into the building
         */

        foreach (var matN in matsNeeded)
        {
            BuildMaterial matL = BuildMaterial.GetByKey(matsLeft, matN.item);
            if (matL.count > 0)
            {
                return(false);
            }
        }

        return(true);
    }
예제 #3
0
    public void UpdateTooltip()
    {
        /*
         * Updates the tooltip displaying the amount of materials needed and already put
         */

        StringBuilder sb = new StringBuilder();

        foreach (var matN in matsNeeded)
        {
            sb.Append(matN.item.name + ": ");
            BuildMaterial matL   = BuildMaterial.GetByKey(matsLeft, matN.item);
            int           matPut = matN.count - matL.count;

            sb.Append(matPut + "/" + matN.count + "\n");
        }

        interactable._tooltipText = sb.ToString();
    }