public override AbstractState HandleUpdate(EnemyStateMachine stateMachine, Animator animator, CharacterMovementController playerController)
        {
            AbstractState baseState = base.HandleUpdate(stateMachine, animator, playerController);

            if (baseState != null)
            {
                return(baseState);
            }

            float directionX = 0;

            if (stateMachine.currentDetection.distance < 0)
            {
                // Kein Gegner gefunden

                if (stateMachine.waypointController.HasWaypoints())
                {
                    // run towards waypoint
                    directionX = stateMachine.waypointController.GetDirectionXnextWaypoint(stateMachine.transform.position);
                }
                else
                {
                    return(stateMachine.idleState);
                }
            }
            else
            {
                // Gegen gefunden

                if (stateMachine.InAttackPosition())
                {
                    return(stateMachine.attackIdleState);
                }
                else
                {
                    // run towards player
                    directionX = (stateMachine.currentDetection.right ? 1 : -1);
                }
            }


            MoveX(stateMachine, playerController, directionX);

            return(null);
        }
        public override AbstractState HandleUpdate(EnemyStateMachine stateMachine, Animator animator, CharacterMovementController playerController)
        {
            AbstractState baseState = base.HandleUpdate(stateMachine, animator, playerController);

            if (baseState != null)
            {
                return(baseState);
            }

            if (!stateMachine.InAttackPosition())
            {
                //  Player out of reach
                return(stateMachine.runningState);
            }

            if (IsTimeToAttack(stateMachine))
            {
                return(stateMachine.attackingState);
            }

            return(null);
        }