So I was able to FINALLY get the answer I was looking for:
Power = techList[0].Power;
That worked, but of course its only temporary as this sets Power to be whatever Element zero is and of course enemies and party members will have more than 1 skill. Dont have to deal with it yet but how would I go about making it more global?
DamageFormula is not working because it is not finding Power variable for any Skills stored in a List of scriptableObjects. If I make a public reference to BaseTech and drag skill into it, formula follows through. How to access variables stored in a list?
Base Creature.
[CreateAssetMenu(fileName = "New Creature", menuName = "RPG/Creature")]
public class BaseCreature : ScriptableObject
{
public string Name;
public int MaxHP;
public int HP;
public int Strength;
public int Defense;
public List<BaseTech>List;
}
BaseTech.
[CreateAssetMenu(fileName ="New Technique", menuName ="RPG/Tech")]
public class BaseTech : ScriptableObject
{
public string Name;
public int Power;
}
Creature
public class Creature : MonoBehaviour
{
public BaseCreature baseCreature;
public BaseTech baseTech;
private Technique technique;
public string Name;
public int MaxHP;
public int HP;
public int Strength;
public int Defense;
public int Damage;
public int Power;
public List<BaseTech>techList;
private void Awake()
{
Name = baseCreature.Name;
MaxHP = baseCreature.MaxHP;
HP = baseCreature.HP;
Strength = baseCreature.Strength;
Defense = baseCreature.Defense;
techList = baseCreature.List;
Power = baseTech.Power;
}
private void Start()
{
DamageFormula(Damage);
}
// Equivalent to Hurt//
public void DamageFormula(int amount)
{
Damage = Mathf.RoundToInt(Strength + Power - Defense * Random.Range(1.00f, 1.125f));
HP = Mathf.Max(HP - Damage, 0);
if ( HP == 0)
{
Die();
}
}
public void Die()
{
Destroy(this.gameObject);
Debug.LogFormat("{0} has died!", Name);
}
}
Technique.
public class Technique : MonoBehaviour
{
BaseTech baseTech;
public string Name;
public int Power;
private Vector3 targetPosition;
private void Start()
{
Name = baseTech.Name;
Power = baseTech.Power;
}
//Equivalent to Cast//
public void Attack(Creature target)
{
targetPosition = target.transform.position;
Debug.Log(Name + " was cast on " + target.name + "!");
}
}