using System; using UnityEngine; [System.Serializable] public abstract class ItemData : ModelData { [SerializeField] public string description; [SerializeField] public int level; [SerializeField] public int value; [SerializeField] public int price; [SerializeField] public string imageName; protected override string SPRITE_LOCALIZATION => "Sprites/Object Sprites/"; protected override string MODEL_LOCALIZATION => "Items/"; public ItemData(Item item) : base(item.id, item.name, item.itemModel.name) { description = item.description; level = item.level; value = item.value; price = item.price; imageName = item.image.name; } public override Item MapDataToObject(string prefarbAssetName) { Debug.Log(MODEL_LOCALIZATION + prefarbAssetName + ".asset"); return TryFindResource(prefarbAssetName); /// // DONT OVERWRITE PROPERTIES BECOUSE ITS EDIT MAIN OBJECT IN ASSET/ /// // equippableItem.StrengthBonus = strengthBonus; // equippableItem.AgilityBonus = agilityBonus; // equippableItem.InteligenceBonus = inteligenceBonus; // equippableItem.VitalityBonus = vitalityBonus; // equippableItem.isStackable = isStackable; // equippableItem.EquipmentTypeEnum = equipmentType; // Item item = base.MapDataToItem(prefarbAssetName); // equippableItem.Name = item.Name; // equippableItem.Description = item.Description; // equippableItem.Level = item.Level; // equippableItem.ItemModel = item.ItemModel; // equippableItem.Image = item.Image; } public override Item MapDataToObject() { return TryFindResource(modelName); } protected override Item TryFindResource(string modelName) { var resource = Resources.Load(MODEL_LOCALIZATION + modelName); if (!resource) throw new System.Exception($"Resource {modelName} not found!!"); return resource; } }