Skip to main content
added 47 characters in body
Source Link
Philipp
  • 123k
  • 28
  • 264
  • 344

Add a method public IEnemyState CreatePlayerReactState() to the Enemy class. For one enemy, have it return a DefenseState, for the other enemy, return an AttackState. You can implement that by creating two subclasses of Enemy with different implementations of that method, or by adding a private variable to Enemy which says how it reacts to the player.

Then, in your method which detects the player, do enemy.fsm.ChangeState(enemy.CreatePlayerReactState()).

Add a method public IEnemyState CreatePlayerReactState() to the Enemy class. For one enemy, have it return a DefenseState, for the other enemy, return an AttackState. You can implement that by creating two subclasses of Enemy or by adding a private variable to Enemy which says how it reacts to the player.

Then, in your method which detects the player, do enemy.fsm.ChangeState(enemy.CreatePlayerReactState()).

Add a method public IEnemyState CreatePlayerReactState() to the Enemy class. For one enemy, have it return a DefenseState, for the other enemy, return an AttackState. You can implement that by creating two subclasses of Enemy with different implementations of that method, or by adding a private variable to Enemy which says how it reacts to the player.

Then, in your method which detects the player, do enemy.fsm.ChangeState(enemy.CreatePlayerReactState()).

Source Link
Philipp
  • 123k
  • 28
  • 264
  • 344

Add a method public IEnemyState CreatePlayerReactState() to the Enemy class. For one enemy, have it return a DefenseState, for the other enemy, return an AttackState. You can implement that by creating two subclasses of Enemy or by adding a private variable to Enemy which says how it reacts to the player.

Then, in your method which detects the player, do enemy.fsm.ChangeState(enemy.CreatePlayerReactState()).