Hi all, I did some searching and could not really find anything that helped me figure this out. I have a class called MoveDatabase that holds all of my moves inside a scriptable object. Moves are serialized in the inspector. Looks like this.
MoveDatabase
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "Moves", menuName = "Create Move Database/Add Database", order = 5)]
public class MoveDatabase : ScriptableObject
{
public List<Move> Moves;
//This is called when the object is created from menu
private void Awake()
{
Debug.Log("We are awake");
}
private void OnEnable()
{
//Debug.Log("We are enabled");
int addAmount = 0;
foreach (Move thisMove in Moves)
{
//Auto increament the move ID when a new move is created
thisMove.moveID = addAmount++;
}
}
}
[System.Serializable]
public class Move
{
public string moveName;
public int moveID;
public string moveDesc;
public MoveType moveType;
public AttackType attackType;
public float movePower;
public string bonusStat;
public float moveCharges;
public float currentMoveCharges;
public float accuracy;
public float statusEffectChance;
public enum MoveType
{
Light,
Dark,
Psychic,
Space,
Time,
Soul,
Gravity,
Fire,
Grass,
Water,
Electric,
Air,
Earth,
Ice,
Normal,
Metal,
Toxic,
None
}
public enum AttackType
{
PhysicalAttack,
SpecialAttack,
BoostMove
}
public Move(
string name,
int id,
string desc,
MoveType type,
AttackType atype,
float power,
string bonus,
float charges,
float currentCharges,
float accurate,
float effectChance
)
{
moveName = name;
moveID = id;
moveDesc = desc;
moveType = type;
attackType = atype;
movePower = power;
bonusStat = bonus;
moveCharges = charges;
currentMoveCharges = currentCharges;
accuracy = accurate;
statusEffectChance = effectChance;
}
public Move()
{
}
public Move(Move i)
{
this.moveName = i.moveName;
this.moveID = i.moveID;
this.moveDesc = i.moveDesc;
this.moveType = i.moveType;
this.attackType = i.attackType;
this.movePower = i.movePower;
this.bonusStat = i.bonusStat;
this.moveCharges = i.moveCharges;
this.currentMoveCharges = i.currentMoveCharges;
this.accuracy = i.accuracy;
this.statusEffectChance = i.statusEffectChance;
}
}
In the inspector it looks like this.
Now I have another class called Monster that’s setup the say way as the MoveDatabase. What im trying to do is add a dropdown of all the moves in the monster database that lets me pick the move I want for a specific monster in the same way a enum would allow me to. I know I can do this by making a enum inside the monster class that has all of the moves, but the problem is, if I add a move to the move database the enum in monster would need to be edited as well. Is there a way around this?
Example - MonsterMove lets me pick a move from move database