Reference a Subclass Dynamically

Looking for some advice on the best way to do something. I have a superclass (GridState), and subclasses from that class (GridStateFighter, GridStateArcher, etc.).

I want to have different gameobject units hold their own versions of GridState somehow. Then when the manager of GridState needs to change the subclass to use, it could reference that gameobject and instantiate that subclass. Wrote a quick example below. I could be totally off base on this, but I’d like something that doesn’t involve a massive if/else or similar as the subclasses grow. Any suggestions would be greatly appreciated.

class abstract GridState{}

public GridStateFighter :GridState{}

public GridStateArcher :GridState()

public abstract class Grid
     public GridState _gridstate;

     public OnFighter()
         _gridState = new GridStateFighter ();

     public OnArcher()
         //Could just have one method if I am able to reference the subclass 
           somehow dynamically. 
        _gridState = new GridStateArcher ();

I’m not entirely sure what you are trying to believe implementation-wise, but at a guess I would say generics are probably a better fit for this;

public void SetState<T>() where T : GridState
    _gridState = new T ();

You can constrain the type ‘T’ to be a derivative of GridState, then call the function passing in the required type;

public Grid m_Grid;


// Set the grid to a fighter state