Пример #1
0
 public override void InstantiateThis(EnumResourceType materialType)
 {
     if (matDict.ContainsKey(materialType.ToString()))
     {
         gameObject.GetComponent <MeshRenderer>().material = matDict[materialType.ToString()];
     }
 }
Пример #2
0
    /// <summary>
    /// Every Craftable Item is created through this function
    /// </summary>
    /// <param name="Item">This is one of many types of Enums (ClothingItems, EquipableItem, TrinketItem, ConsumableItem, ContainerItem)</param>
    /// <param name="resourceType"></param>
    /// <param name="itemDictionary"></param>
    /// <returns></returns>
    private GameObject CreateCraftableItem(object Item, EnumResourceType resourceType, Dictionary <string, GameObject> itemDictionary)
    {
        GameObject item = null;

        if (itemDictionary.ContainsKey(Item.ToString() + "Prefab"))
        {
            print("The prefab was found ");
            item = GameObject.Instantiate(itemDictionary[Item.ToString() + "Prefab"]);
            item.GetComponent <BasePrefabInterface>().constructor(Item);
            print(item.ToString());

            //Extract the prefab info to ensure right resourceType.
            if (item.GetComponent <BasePrefabInterface>().matDict.ContainsKey(resourceType.ToString()))
            {
                item.GetComponent <BasePrefabInterface>().InstantiateThis(resourceType);
            }
            else
            {
                print("Material does not match");
                Destroy(item);
            }
        }
        return(item);
    }