public IState Create(Type type) { if (type == typeof(PlayerIdleState)) { return(_idleFactory.Create()); } if (type == typeof(PlayerMovingState)) { return(_movingFactory.Create()); } throw new ArgumentOutOfRangeException(nameof(type), type, null); }
public IState CreateState(StatesEnum state) { switch (state) { case StatesEnum.Idle: { return(_idleFactory.Create()); } case StatesEnum.Attack: { return(_attackFactory.Create()); } case StatesEnum.Dead: { return(_deadFactory.Create()); } default: throw new Exception("Неизвестное состояние"); } }