IEnumerator ExecuteFinisher(FinisherAbstract FinisherToPerform)
    {
        PerformingFinisher = false;
        ExecutingFinisher  = true;

        PrimaryAttackPopUp.SetActive(false);
        RunicRinisherGuides.SetActive(false);
        InFinisherIcons.SetActive(false);

        finisherSlider.value = 0;
        CharAnim.Play("Finisher_End");
        if (PillarFinisherUsed)
        {
            PillarTutorial.PlayFinisherHit();
            FinisherToPerform.SetAsPiller();
        }
        else
        {
            if (enemyAnimator)
            {
                enemyAnimator.Play("Finisher_Start");
            }
        }
        yield return(new WaitForSecondsRealtime(1f));

        FinisherToPerform.startfinisher(this);
        FinisherToPerform.RestoreAsPiller();

        yield return(null); // do stuff to perform the finisher

        IncreaseGodModeMeter(PlayerDamageValues.Instance.ExecuteFinisherGMFill);
        StartCoroutine(LeavingFinisherMode(FinisherToPerform));
    }
    void Start()
    {
        FinisherCount             = FinisherTime;
        FinisherModeCooldownCount = FinisherModeCooldownTime;
        CurrentFinisherMode       = FinisherModes.Runic;
        inFinisherMode            = false;
        PerformingFinisher        = false;
        ExecutingFinisher         = false;

        FinisherFullImage.SetActive(false);
        FinisherIcon.gameObject.SetActive(true);
        FinisherIcon.SetActivated(false);
        InFinisherIcons.SetActive(false);
        PrimaryAttackPopUp.SetActive(false);
        //RunicSequence = new RunicInputHelper();
        RunicQue = new List <Direction>();
    }
    public void FailFinisherMode()
    {
        PerformingFinisher = false;

        PrimaryAttackPopUp.SetActive(false);
        RunicRinisherGuides.SetActive(false);
        InFinisherIcons.SetActive(false);
        didFail = true;

        if (PillarFinisherUsed)
        {
            switch (PillarTutorial.FinisherUnlock)
            {
            case Finishers.Siphoning:
                GetComponent <Siphoncut>().enabled = false;
                break;

            case Finishers.FlameSword:
                GetComponent <RunicFireSword>().enabled = false;
                break;

            case Finishers.Flamethrower:
                GetComponent <RunicFlamethrower>().enabled = false;
                break;

            case Finishers.FlameAOE:
                GetComponent <RunicFireCircle>().enabled = false;
                break;

            case Finishers.FrostAOE:
                GetComponent <RunicFrostCircle>().enabled = false;
                break;
            }
        }

        StartCoroutine(LeavingFinisherMode());
    }
    public IEnumerator EnterFinisherMode(bool usedSwordGrapple)
    {
        GameStatus.FinisherModeActive = true;
        Player.GetComponent <PlayerMovementController>().PreventMoving();
        Player.GetComponent <PlayerMovementController>().PreventTuring();
        inFinisherMode = true;
        print("Begin Finisher");
        swordController.PreventAttacking();

        //move enemy into place and lock controls.

        PlayerRotWrapper.LookAt(new Vector3(currentTarget.transform.position.x,
                                            PlayerRotWrapper.transform.position.y,
                                            currentTarget.transform.position.z));
        if (!PillarFinisherUsed)
        {
            if (currentTarget.tag != "TargetDummy")
            {
                currentTarget.GetComponent <EnemyMovementController>().StopMovement();
                currentTarget.GetComponent <EnemyAI>().BeingFinished();


                if (currentTarget.GetComponent <EnemyTypeController>().MyEnemyType == EnemyType.Boss)
                {
                    savedAnimController = currentTarget.GetComponent <EnemyAI>().anim.runtimeAnimatorController;
                }

                if (enemyAnimator = currentTarget.GetComponent <EnemyAI>().anim)
                {
                    enemyAnimator.runtimeAnimatorController = enemyAnimatorController;
                    enemyAnimator.updateMode = AnimatorUpdateMode.UnscaledTime;
                    enemyAnimator.Play("Finisher_Start");
                }
                yield return(null);
            }
        }

        UIanim.Play("FinisherRunicIdleStance");

        Time.timeScale = slowMoModifier;

        if (usedSwordGrapple)
        {
            //moves camera
            cam.MoveToAimingLocation(true); //Mark make sure camera takes as long as the animation

            usedSwordGrapple = false;

            //move sword forward and back over a small period
            SwordThrowAnimObj.SetActive(true);
            var     savedSwordPos   = SwordThrowAnimObj.transform.localPosition;
            var     savedSwordRot   = SwordThrowAnimObj.transform.localRotation;
            var     currentSwordPos = SwordThrowAnimObj.transform.position;
            Vector3 FinalTarget     = EnemyFinisherPlacement.position;
            float   timeToMove      = .25f;
            var     t = 0f;
            while (t < 1)
            {
                t += Time.unscaledDeltaTime / timeToMove;
                SwordThrowAnimObj.transform.position = Vector3.Lerp(currentSwordPos, currentTarget.transform.position, t);
                yield return(null);
            }
            currentSwordPos = SwordThrowAnimObj.transform.position;
            var currentTargetPos = currentTarget.transform.position;
            t = 0f;
            while (t < 1)
            {
                t += Time.unscaledDeltaTime / timeToMove;
                SwordThrowAnimObj.transform.position = Vector3.Lerp(currentSwordPos, FinalTarget, t);
                currentTarget.transform.position     = Vector3.Lerp(currentTargetPos, FinalTarget, t);
                yield return(null);
            }
            SwordThrowAnimObj.transform.localPosition = savedSwordPos;
            SwordThrowAnimObj.transform.localRotation = savedSwordRot;
            SwordThrowAnimObj.SetActive(false);
            CharAnim.Play("Finisher_Start");
            yield return(null);
        }
        else
        {
            CharAnim.Play("Finisher_Start");
            yield return(null);
        }

        currentTarget.transform.position = EnemyFinisherPlacement.position;
        currentTarget.transform.rotation = EnemyFinisherPlacement.rotation;
        if (!PillarFinisherUsed)
        {
            currentTarget.transform.Rotate(new Vector3(0, -40, 0));
        }
        //currentTarget.transform.parent = EnemyFinisherPlacement;
        if (PillarFinisherUsed)
        {
            currentTarget.transform.position += Vector3.down;
            TutorialPopups.Instance.ShowTutorialPopup(PillarTutorial.FinisherUnlock);
        }

        //moves camera
        cam.MoveToFinisherModeLocation(); //Mark make sure camera takes as long as the animation
        if (PillarFinisherUsed)
        {
            PillarTutorial.PlayFirstHit();
        }
        while (cam.GetIsMoving())
        {
            CameraBase.rotation = Quaternion.Slerp(CameraBase.rotation, PlayerRotWrapper.rotation, .5f);
            yield return(null);
        }
        //waits till the camera and or animation is done
        CameraBase.rotation = PlayerRotWrapper.rotation;
        GetComponent <PlayerMovementController>().Aiming = false;



        PerformingFinisher = true;
        FinisherCount      = FinisherTime;

        FinisherIcon.SetActivated(false);
        InFinisherIcons.SetActive(true);
        if (!PillarFinisherUsed)
        {
            RunicRinisherGuides.SetActive(true);
        }

        //RunicSequence.RestartQue();
        RunicQue.Clear();
        InputList.Clear();
        //yield return null;
    }