2022-11-24 03:03:30 +01:00
|
|
|
using System;
|
2023-01-06 03:44:07 +01:00
|
|
|
using System.Linq;
|
2022-06-17 22:22:19 +02:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
[System.Serializable]
|
|
|
|
public class EquippableItemData : ItemData
|
|
|
|
{
|
2022-11-19 17:02:31 +01:00
|
|
|
[SerializeField]
|
2022-06-17 22:22:19 +02:00
|
|
|
public int strengthBonus;
|
|
|
|
|
2022-11-19 17:02:31 +01:00
|
|
|
[SerializeField]
|
2022-12-29 00:58:03 +01:00
|
|
|
public int enduranceBonus;
|
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 int inteligenceBonus;
|
|
|
|
|
2022-11-19 17:02:31 +01:00
|
|
|
[SerializeField]
|
2022-06-17 22:22:19 +02:00
|
|
|
public int vitalityBonus;
|
|
|
|
|
2022-12-29 00:58:03 +01:00
|
|
|
[SerializeField]
|
|
|
|
public int speedBonus;
|
|
|
|
|
2022-11-19 17:02:31 +01:00
|
|
|
[SerializeField]
|
2022-06-17 22:22:19 +02:00
|
|
|
public bool isStackable;
|
|
|
|
|
2022-11-19 17:02:31 +01:00
|
|
|
[SerializeField]
|
2022-11-06 21:34:17 +01:00
|
|
|
public EquipmentTypeEnum equipmentType;
|
2022-06-17 22:22:19 +02:00
|
|
|
|
|
|
|
public EquippableItemData(EquippableItem equippableItem) : base(equippableItem)
|
|
|
|
{
|
|
|
|
strengthBonus = equippableItem.StrengthBonus;
|
2022-12-29 00:58:03 +01:00
|
|
|
enduranceBonus = equippableItem.EnduranceBonus;
|
2022-06-17 22:22:19 +02:00
|
|
|
inteligenceBonus = equippableItem.InteligenceBonus;
|
|
|
|
vitalityBonus = equippableItem.VitalityBonus;
|
2022-12-29 00:58:03 +01:00
|
|
|
speedBonus = equippableItem.SpeedBonus;
|
2022-06-17 22:22:19 +02:00
|
|
|
|
|
|
|
isStackable = equippableItem.isStackable;
|
|
|
|
equipmentType = equippableItem.EquipmentType;
|
|
|
|
}
|
|
|
|
|
2022-11-19 17:02:31 +01:00
|
|
|
public EquippableItemData(Item item) : base(item)
|
2022-06-17 22:22:19 +02:00
|
|
|
{
|
2022-11-19 17:02:31 +01:00
|
|
|
strengthBonus = 0;
|
2022-12-29 00:58:03 +01:00
|
|
|
enduranceBonus = 0;
|
2022-11-19 17:02:31 +01:00
|
|
|
inteligenceBonus = 0;
|
|
|
|
vitalityBonus = 0;
|
2022-12-29 00:58:03 +01:00
|
|
|
speedBonus = 0;
|
2022-11-19 17:02:31 +01:00
|
|
|
|
|
|
|
isStackable = true;
|
|
|
|
equipmentType = EquipmentTypeEnum.Other;
|
2022-06-17 22:22:19 +02:00
|
|
|
}
|
2023-01-06 03:44:07 +01:00
|
|
|
|
|
|
|
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.EnduranceBonus = enduranceBonus;
|
|
|
|
// 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)
|
2023-01-06 14:50:12 +01:00
|
|
|
{
|
|
|
|
/* Debug.Log(MODEL_LOCALIZATION + modelName);
|
|
|
|
*/
|
|
|
|
|
|
|
|
Item resource = Resources.Load<EquippableItem>(MODEL_LOCALIZATION + modelName);
|
|
|
|
|
|
|
|
var modelNameWithoutWhitespace = String.Concat(modelName.Where(c => !Char.IsWhiteSpace(c)));
|
2023-01-06 03:44:07 +01:00
|
|
|
|
|
|
|
if (resource == null)
|
|
|
|
{
|
2023-01-06 14:50:12 +01:00
|
|
|
resource = Resources.Load<EquippableItem>(MODEL_LOCALIZATION + modelNameWithoutWhitespace);
|
2023-01-06 03:44:07 +01:00
|
|
|
|
2023-01-06 14:50:12 +01:00
|
|
|
if (resource == null)
|
|
|
|
{
|
|
|
|
resource = Resources.Load<Item>(MODEL_LOCALIZATION + modelName);
|
2023-01-06 03:44:07 +01:00
|
|
|
|
2023-01-06 14:50:12 +01:00
|
|
|
if (resource == null)
|
|
|
|
{
|
|
|
|
resource = Resources.Load<Item>(MODEL_LOCALIZATION + modelNameWithoutWhitespace);
|
|
|
|
}
|
|
|
|
}
|
2023-01-06 03:44:07 +01:00
|
|
|
}
|
|
|
|
|
2023-01-06 14:50:12 +01:00
|
|
|
if (resource == null)
|
|
|
|
throw new System.Exception($"Resource {modelName} not found!!");
|
|
|
|
|
2023-01-06 03:44:07 +01:00
|
|
|
return resource;
|
|
|
|
}
|
2022-06-17 22:22:19 +02:00
|
|
|
}
|