Scriptum/Assets/Scripts/REFACTORING/Models/Item/ItemData.cs
2022-12-06 01:27:02 +01:00

67 lines
1.9 KiB
C#

using System;
using UnityEngine;
[System.Serializable]
public abstract class ItemData : ModelData<Item, Item>
{
[SerializeField]
public string description;
[SerializeField]
public int level;
[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;
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<Item>(MODEL_LOCALIZATION + modelName);
if (!resource)
throw new System.Exception($"Resource {modelName} not found!!");
return resource;
}
}