using UnityEngine;
using System.Collections;

public class Lich : MonoBehaviour
{

	private Animator animator;

	private bool idle=true;

	void Start () 
	{
		animator = GetComponent<Animator>();
	}

	public void doActionOne()
	{
		idle = false;
		animator.SetTrigger("evo1");
		StartCoroutine(checkCurrent());
	}

	public void doActionTwo()
	{
		idle = false;
		animator.SetTrigger("evo2");
		StartCoroutine(checkCurrent());
	}

	public void doActionThree()
	{
		idle = false;
		animator.SetTrigger("evo1");
		StartCoroutine(checkCurrent());
	}

	public void doActionFour()
	{
		idle = false;
		animator.SetTrigger("evo2");
		StartCoroutine(checkCurrent());
	}

	public void doActionFive()
	{
		idle = false;
		animator.SetTrigger("evo1");
		StartCoroutine(checkCurrent());
	}
		
	public IEnumerator checkCurrent()
	{
		while(!idle)
		{
			if (animator.GetCurrentAnimatorStateInfo(0).IsName("lichEvo1")||
				animator.GetCurrentAnimatorStateInfo(0).IsName("lichEvo2"))
			{
				if(animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1)
				{
					animator.SetTrigger("idle");
					idle = true;
				}
			}
			yield return null;
		}
	}
}
