Exemplo n.º 1
0
        void CreateItemTemplates()
        {
            item1 = new CraftableItem("Stone axe");
            item1.AddIngredient(Ingredient.Wood, Ingredient.Stone);

            item2 = new CraftableItem("Metal shovel");
            item2.AddIngredient(Ingredient.Wood, Ingredient.Stone, Ingredient.Metal);
        }
Exemplo n.º 2
0
        // Worker methods ------

        public bool HasIngredientsFor(CraftableItem item)
        {
            foreach (var ingredient in item.ingredients)
            {
                var found = inventory.ingredients.Find((i) => i.kind == ingredient);

                if (found == null)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 3
0
        public GameObject CraftItem(CraftableItem item)
        {
            foreach (var ingredient in item.ingredients)
            {
                inventory.TakeItem(ingredient);
                Debug.Log("Used:" + ingredient);
            }

            // Item, normally would
            // return some item asset
            var craftedItem = new GameObject(item.name);

            Debug.Log("Successfully crafted: " + craftedItem.name);

            return(craftedItem);
        }