States like EnemyIdleState and EnemyChaseState can easily be shared between the enemies. What you’ll need is a way to disambiguate which states a Melee, or ranged character would need to use… This could be as simple as adding some bools to the EnemyStateMachine, or as complicated as using a WeaponConfig like in the RPG course… Here’s sort of what I would do in the former case (I’m actually prototyping the latter case right now for a future tutorial on mixing the RPG course and this course).
In EnemyStateMachine
[field: SerializeField] public bool IsRanged {get; private set;}
[field: SerializeField] public bool CanParry {get; private set;}
[field: SerializeField] public bool CanLeapAttack {get; private set;}
The easiest example here is in the IsRanged case… in EnemyChaseState, if the target (player) is in range,
if(stateMachine.IsRanged)
{
stateMachine.SwitchState(new EnemyRangedAttack(stateMachine));
} else
{
stateMachine.SwitchState(new EnemyMeleeAttack(stateMachine));
}