2022-11-24 03:03:30 +01:00
|
|
|
using System;
|
2022-06-17 22:22:19 +02:00
|
|
|
using UnityEngine;
|
2022-11-19 17:02:31 +01:00
|
|
|
|
2022-06-17 22:22:19 +02:00
|
|
|
|
|
|
|
[System.Serializable]
|
2022-11-19 17:02:31 +01:00
|
|
|
public abstract class ItemData : ModelData<Item, Item>
|
2022-06-17 22:22:19 +02:00
|
|
|
{
|
2022-11-19 17:02:31 +01:00
|
|
|
[SerializeField]
|
2022-06-17 22:22:19 +02:00
|
|
|
public string description;
|
|
|
|
|
2022-11-19 17:02:31 +01:00
|
|
|
[SerializeField]
|
2022-06-17 22:22:19 +02:00
|
|
|
public int level;
|
|
|
|
|
2022-12-19 03:34:45 +01:00
|
|
|
[SerializeField]
|
|
|
|
public int value;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
public int price;
|
|
|
|
|
2022-11-19 17:02:31 +01:00
|
|
|
[SerializeField]
|
2022-06-17 22:22:19 +02:00
|
|
|
public string imageName;
|
|
|
|
|
2022-11-19 17:02:31 +01:00
|
|
|
protected override string SPRITE_LOCALIZATION => "Sprites/Object Sprites/";
|
|
|
|
protected override string MODEL_LOCALIZATION => "Items/";
|
2022-06-17 22:22:19 +02:00
|
|
|
|
2022-11-19 17:02:31 +01:00
|
|
|
public ItemData(Item item) : base(item.id, item.name, item.itemModel.name)
|
2022-06-17 22:22:19 +02:00
|
|
|
{
|
|
|
|
description = item.description;
|
|
|
|
level = item.level;
|
2022-12-19 03:34:45 +01:00
|
|
|
value = item.value;
|
|
|
|
price = item.price;
|
2022-06-17 22:22:19 +02:00
|
|
|
imageName = item.image.name;
|
|
|
|
}
|
|
|
|
|
2022-11-19 17:02:31 +01:00
|
|
|
public override Item MapDataToObject(string prefarbAssetName)
|
2022-06-17 22:22:19 +02:00
|
|
|
{
|
2022-11-19 17:02:31 +01:00
|
|
|
Debug.Log(MODEL_LOCALIZATION + prefarbAssetName + ".asset");
|
|
|
|
|
|
|
|
return TryFindResource(prefarbAssetName);
|
2022-06-17 22:22:19 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
// DONT OVERWRITE PROPERTIES BECOUSE ITS EDIT MAIN OBJECT IN ASSET/
|
|
|
|
///
|
|
|
|
|
2022-11-19 17:02:31 +01:00
|
|
|
// equippableItem.StrengthBonus = strengthBonus;
|
|
|
|
// equippableItem.AgilityBonus = agilityBonus;
|
|
|
|
// equippableItem.InteligenceBonus = inteligenceBonus;
|
|
|
|
// equippableItem.VitalityBonus = vitalityBonus;
|
|
|
|
// equippableItem.isStackable = isStackable;
|
|
|
|
// equippableItem.EquipmentTypeEnum = equipmentType;
|
2022-06-17 22:22:19 +02:00
|
|
|
|
2022-11-19 17:02:31 +01:00
|
|
|
// 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;
|
|
|
|
}
|
2022-06-17 22:22:19 +02:00
|
|
|
|
2022-11-19 17:02:31 +01:00
|
|
|
public override Item MapDataToObject()
|
|
|
|
{
|
|
|
|
return TryFindResource(modelName);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override Item TryFindResource(string modelName)
|
|
|
|
{
|
|
|
|
var resource = Resources.Load<Item>(MODEL_LOCALIZATION + modelName);
|
2022-11-24 03:03:30 +01:00
|
|
|
|
2022-11-19 17:02:31 +01:00
|
|
|
if (!resource)
|
|
|
|
throw new System.Exception($"Resource {modelName} not found!!");
|
2022-06-17 22:22:19 +02:00
|
|
|
|
2022-11-19 17:02:31 +01:00
|
|
|
return resource;
|
2022-06-17 22:22:19 +02:00
|
|
|
}
|
2022-11-19 17:02:31 +01:00
|
|
|
}
|