// Update is called once per frame
    void Update()
    {
        // Disable the sword collider if an attack animation is not running.
        if (m_Player.Animator.GetCurrentAnimatorStateInfo(0).IsName("Idle"))
        {
            DisableSwordCollider();
        }
        else // Otherwise enable it
        {
            EnableSwordCollider();
        }

        if (!m_InCombatMode)
        {
            m_CrosshairCanvas.SetActive(false);
        }
        else
        {
            m_CrosshairCanvas.SetActive(true);
        }



        // If the player is pressing the attack button
        if (Services.InputManager.GetAction(InputAction.Attack))
        {
            //if (m_Player.Animator.GetCurrentAnimatorStateInfo(0).IsName("Idle"))
            //{
            // Disable camera input
            m_Player.CameraController.SetInputEnabled(false);

            // Set the current attack to null
            CurrentAttackDirection = AttackDirection.Null;

            // We are now in combat mode
            m_InCombatMode = true;
            //}
        }
        else // The player released the attack button
        {
            //MouseAngle = 0;
            // If the player is in combat mode and has a target direction
            if (m_InCombatMode && TargetAttackDirection != AttackDirection.Null)
            {
                if (m_Player.Animator.GetCurrentAnimatorStateInfo(0).IsName("Idle"))
                {
                    // Set the animator to play the animation
                    m_Player.Animator.SetTrigger(TargetAttackDirection.ToString());

                    // Set the current attack to the target attack
                    CurrentAttackDirection = TargetAttackDirection;

                    // Use some stamina
                    //m_Player.m_CurrentStamina -= m_Player.SizeOfStaminaChunks;

                    // Multiple sword swing sfx functionality
                    m_SwordSwingCount++;

                    if (m_SwordSwingCount == 1)
                    {
                        Services.AudioManager.PlayPlayerSFX(PlayerSFX.Sword_Slash_1);
                    }
                    if (m_SwordSwingCount == 2)
                    {
                        Services.AudioManager.PlayPlayerSFX(PlayerSFX.Sword_Slash_2);
                    }
                    if (m_SwordSwingCount == 3)
                    {
                        Services.AudioManager.PlayPlayerSFX(PlayerSFX.Sword_Slash_3);
                        m_SwordSwingCount = 0;
                    }
                }
            }

            // Enable camera input
            m_Player.CameraController.SetInputEnabled(true);

            // No longer in combat mode
            m_InCombatMode = false;

            // Reset taret direction to null
            TargetAttackDirection = AttackDirection.Null;
        }


        // Reset all the crosshair images' color and scale
        ResetCrosshairImages();

        Vector2 lookInput = Services.InputManager.GetLookInput();

        if (Services.InputManager.CurrentInputType == InputType.Keyboard)
        {
            if (lookInput.sqrMagnitude < 0.5f)
            {
                lookInput = Vector2.zero;
            }
            else
            {
                lookInput.Normalize();
            }
        }

        HandleLookInput(lookInput);

        // Set the currently selected direction's crosshair to show as selected
        if (TargetAttackDirection != AttackDirection.Null)
        {
            m_CrosshairImages[(int)TargetAttackDirection].color = Color.blue;
            m_CrosshairImages[(int)TargetAttackDirection].transform.localScale = new Vector3(1.5f, 1.5f, 1.0f);
        }
    }
    void Update()
    {
        // Disable the sword collider if an attack animation is not running.
        if (PlayerReference.Animator.GetCurrentAnimatorStateInfo(0).IsName("Idle") ||
            PlayerReference.Animator.GetCurrentAnimatorStateInfo(0).IsName("Heal") ||
            PlayerReference.Animator.GetCurrentAnimatorStateInfo(0).IsName("Hold") ||
            PlayerReference.Animator.GetCurrentAnimatorStateInfo(0).IsName("Walking"))
        {
            DisableSwordCollider();
        }
        else // Otherwise enable it
        {
            EnableSwordCollider();
        }

        if (!InCombatMode)
        {
            CrosshairCanvas.SetActive(false);
            SlashIndicator.SetActive(false);
        }
        else
        {
            CrosshairCanvas.SetActive(true);
            SlashIndicator.SetActive(true);
        }

        // If the player is pressing the attack button
        if (Services.InputManager.GetAction(InputAction.Attack))
        {
            if (PlayerReference.Animator.GetCurrentAnimatorStateInfo(0).IsName("Idle") ||
                PlayerReference.Animator.GetCurrentAnimatorStateInfo(0).IsName("Walking"))
            {
                // Disable camera input
                PlayerReference.CameraController.SetInputEnabled(false);

                // Set the current attack to null
                CurrentAttackDirection = AttackDirection.Null;

                if (!InCombatMode)
                {
                    PlayerReference.Animator.SetBool("ShouldHold", true);
                }
                // We are now in combat mode
                InCombatMode = true;
            }

            Vector2 lookInput = Services.InputManager.GetLookInput();
            if (Services.InputManager.CurrentInputType == InputType.Keyboard)
            {
                if (lookInput.sqrMagnitude < 0.5f)
                {
                    lookInput = Vector2.zero;
                }
                else
                {
                    lookInput.Normalize();
                }
            }
            HandleLookInput(lookInput);
        }
        else // The player released the attack button
        {
            // If the player is in combat mode and has a target direction
            if (InCombatMode && TargetAttackDirection != AttackDirection.Null)
            {
                // Set the animator to play the animation
                PlayerReference.Animator.SetTrigger(TargetAttackDirection.ToString());

                // Set the current attack to the target attack
                CurrentAttackDirection = TargetAttackDirection;

                // Multiple sword swing sfx functionality
                SwordSwingCount++;
                switch (SwordSwingCount)
                {
                case 1:
                    Services.AudioManager.PlayPlayerSFX(PlayerSFX.Sword_Slash_1);
                    break;

                case 2:
                    Services.AudioManager.PlayPlayerSFX(PlayerSFX.Sword_Slash_2);
                    break;

                case 3:
                    Services.AudioManager.PlayPlayerSFX(PlayerSFX.Sword_Slash_3);
                    SwordSwingCount = 0;
                    break;
                }
            }

            // Enable camera input
            PlayerReference.CameraController.SetInputEnabled(true);
            //Get out of the sword hold animation
            PlayerReference.Animator.SetBool("ShouldHold", false);

            // No longer in combat mode
            InCombatMode = false;

            // Reset taret direction to null
            TargetAttackDirection = AttackDirection.Null;
        }
        // Reset all the crosshair images' color and scale
        ResetCrosshairImages();

        // Set the currently selected direction's crosshair to show as selected
        if (TargetAttackDirection != AttackDirection.Null)
        {
            CrosshairImages[(int)TargetAttackDirection].sprite = SwordUISprite;
            CrosshairImages[(int)TargetAttackDirection].color  = SelectedColor;
            CrosshairImages[(int)TargetAttackDirection].transform.localScale = SelectedScale;
        }
    }