Exemple #1
0
    void Update()
    {
        if (Input.GetMouseButtonUp(1))
        {
            Slot[] slots = finger.SelectedSlots.ToArray();

            Dictionary <int, int> itemsToCraft = new Dictionary <int, int>();

            foreach (Slot slot in slots)
            {
                if (slot.item != null)
                {
                    if (itemsToCraft.ContainsKey(slot.item.ID))
                    {
                        itemsToCraft[slot.item.ID] += slot.Quantity;
                    }
                    else
                    {
                        itemsToCraft.Add(slot.item.ID, slot.Quantity);
                    }
                }
            }

            if (itemsToCraft.Count == 0)
            {
                Debug.Log("No items");
                return;
            }

            foreach (Blueprint blueprint in blueprints)
            {
                if (blueprint.TryToCraft(itemsToCraft).Key != -1)
                {
                    crafter.CraftItem(blueprint, slots);
                    break;
                }
            }
        }
    }
Exemple #2
0
 void CraftButtonPressed()
 {
     thisCrafter.CraftItem(selectedItem);
     UpdateCraftingMenu(selectedItem);
 }