private static IState CreateStateInstance(ELifeState stateId, Ilife unit) { if (null == m_StateFactory) { StateDefine.RegisterState(); } IState result = null; Type type = null; if (m_StateFactory.TryGetValue(stateId, out type)) { result = Activator.CreateInstance(type, unit, stateId) as IState; } return(result); }