Hello,
I am trying to implement an RPG style inventory, and I found a patter I really like, using ScriptableObjects.
The problem comes when I am trying to add a Instance class, so that I can make two different instances of the object have different values.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
[CreateAssetMenu(menuName = "Item")]
public class Item : ScriptableObject
{
public enum Type { misc, head, neck, ring, weapon, armor, light_source }
public enum Slot { general, head, neck, finger, hand, torso, leg, foot }
public string itm_Name, itm_Desc, itm_FullName, itm_Lore;
public bool itm_Magical;
public Type itm_Type;
public Slot itm_Slot;
public float itm_Value;
public int itm_Quality, itm_AttackBonus, itm_MinDamage, itm_MaxDamage, itm_DefenseBonus, itm_MaxCharges, itm_MaxFuel, itm_CurrentFuel, itm_Icon;
public int itm_ID_Quality, itm_ID_AttackBonus, itm_ID_Damage, itm_ID_Defense, itm_ID_Charges; //these are the modifiers for how the item changes if it is IDd
[System.Serializable]
public class ItemInstance
{
public Item item;
public bool itm_ID, itm_Active;
public int itm_CurrentCharges, itm_CurrentFuel;
public ItemInstance(Item _item, bool _ID, bool _Active, int _CurrentCharges, int _CurrentFuel)
{
this.item = _item;
this.itm_ID = _ID;
this.itm_Active = _Active;
this.itm_CurrentCharges = _CurrentCharges;
this.itm_CurrentFuel = _CurrentFuel;
}
}
public void GetDamage()
{
int _result = 0;
_result = Random.Range(this.itm_MinDamage, this.itm_MaxDamage);
if (instance.itm_ID) _result += this.itm_ID_Damage;
}
}
The problem comes that when I try to implement that GetDamage() method: if (instance.itm_ID)
I cannot access the itm_ID variable to check if an item is identified. Any suggestions?