public virtual void LaunchActions() { switch (state) { case State.Looking: unit.LookForPlayer(() => state = State.Chasing); break; case State.Chasing: unit.ChaseThePlayer(enemyProfile.rangeToAttack, () => state = State.Attacking); break; case State.Attacking: if (unit.GetDistanceFromPlayer() <= enemyProfile.rangeToAttack) { if (!unit.attacking) { unit.Attack(2f, () => { state = State.Chasing; }); attackAnimation?.Invoke(); //enemyProfile.attackWEvent?.Post(gameObject); } } else { state = State.Chasing; } break; } }