Hello, i have inventory system. My InventorySlots contains InventoryItem which initializes ItemSO scriptable object. ItemSO script have enum called Damage. How do i calculate summ of InventorySlots which contains InventoryItem and calculate this damage from enum.
public class InventoryItem : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
public ItemSO item;
public int index;
[Header("UI")]
public TMP_Text countText;
public Image image;
[HideInInspector] public Transform parentAfterDrag;
[HideInInspector] public int count = 1;
public void InitialiseItem(ItemSO newItem)
{
if (newItem != null)
{
item = newItem;
image.sprite = newItem.image;
RefreshCount();
}
}
public void RemoveItem(ItemSO newItem)
{
if (newItem != null)
{
item = null;
image.sprite = null;
}
}
public void RefreshCount()
{
countText.text = count.ToString();
bool textActive = count > 1;
countText.gameObject.SetActive(textActive);
}
public void OnBeginDrag(PointerEventData eventData)
{
image.raycastTarget = false;
parentAfterDrag = transform.parent;
transform.SetParent(transform.root);
}
public void OnDrag(PointerEventData eventData)
{
transform.position = Input.mousePosition;
}
public void OnEndDrag(PointerEventData eventData)
{
image.raycastTarget = true;
transform.SetParent(parentAfterDrag);
}
}
public enum Damage
{
LG1 = 50,
LG2 = 100,
LG3 = 150
}