public class Skeleton : Monster
{
private MonsterBaseState state;
private void Awake()
{
state = new PatrolState<Skeleton>(this);
}
public void GetMonsterInfo()
{
dosomething;
}
}
pubilc class ManyMonster:Monster
{
private MonsterBaseState state;
private void Awake()
{
state = new PatrolState<Skeleton>(this);
}
}
//and more monster Class
public interface MonsterBaseState
{
void BehaviorForUpdate();
}
public class PatrolState<T> : MonsterBaseState
{
private T cluster;
public PatrolState(T curCluster)
{
cluster = curCluster;
cluster.GetMonsterInfo();//wrong here
}
public void BehaviorForUpdate()
{
}
}
I can't use the GetMonsterinfo method in the PatrolState Class
I want to pass the skeleton or other monster , so I don't have to write a lot of status code