/// <summary>
        /// Use the enemy's sword attack.
        /// </summary>
        protected override void Attack()
        {
            // Get the enemy's movement component
            EnemyMovement movement = transform.parent.GetComponent <EnemyMovement>();

            // Handle movement and animations
            movement.StopWalk();
            movement.Action(animationName);

            // Damage the player
            StartCoroutine("DamageEntity");

            // Reset attack status
            cooldown  = maxCooldown;
            attacking = true;
        }
        /// <summary>
        /// Load attack resources.
        /// </summary>
        private void Awake()
        {
            // Get the enemy movement component
            enemyMovement = GetComponent <EnemyMovement>();

            // Load all attacks for this enemy's attack group
            attackResources = Resources.LoadAll <EnemyAttack>("Attacks/" + attackGroup);
            attacks         = new EnemyAttack[attackResources.Length];

            // Spawn all attacks
            for (int i = 0; i < attackResources.Length; i++)
            {
                GameObject attackGameObject = Instantiate(attackResources[i].gameObject, transform);
                attacks[i] = attackGameObject.GetComponent <EnemyAttack>();
            }
        }
        /// <summary>
        /// Damage the player if there is one.
        /// </summary>
        protected override IEnumerator DamageEntity()
        {
            // Get the player's movement component
            EnemyMovement movement = transform.parent.GetComponent <EnemyMovement>();

            // Wait for the attack duration to end
            float attackTime = duration;

            while (attackTime > 0)
            {
                attackTime -= Time.deltaTime;

                // Attack the player
                if (attackTime <= 0)
                {
                    // Make sure the enemy is still playing the attack animation
                    if (movement.IsAction(animationName))
                    {
                        // Check if attack hit an player
                        RaycastHit hit;
                        if (RaycastTarget("PlayerRaycast", transform.parent.position,
                                          transform.parent.TransformDirection(Vector3.forward),
                                          out hit))
                        {
                            // Damage the player
                            Health playerHealth = hit.transform.parent.GetComponent <Health>();
                            if (playerHealth != null)
                            {
                                playerHealth.TakeDamage(damage);
                            }
                        }
                    }
                }

                // Return nothing to the coroutine
                yield return(null);
            }
        }