Hi, I need a generic List to add all my Companion scripts (Archer, Knight, etc).
My Companions derive from a Base Class BaseCompanion( Archer : BaseCompanion).
Then this in code:
public List<BaseCompanion> comps = new List<BaseCompanion>();
public Archer archer = new Archer ();
comps.Add(archer); //does not work, why?
Do I need to typecast archer into BaseCompanion? If so, how? I tried implicit, explicit but I cant get it right.
Its important for me to have them in a List for sorting and then access their unique stats. Alternatively I thought about deleting my subclasses and just go with some BaseCompanion instances and set properties via index. Would like to go with first option though if possible.
Thx