using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class LifeController : MonoBehaviour {

	public Slider slider;
    

	public static LifeController instance;

	void Awake()
	{
		instance = this;
	}

	public void MoveSuccedded()
	{
		slider.value += 0.04f;
	}

	public void MoveFailed()
	{
		slider.value -= 0.2f;

	    if (slider.value <= 0.01f)
        {
            ScoreController.instance.UpdateTotalScore();
			FindObjectOfType<SequenceGenerator> ().StopAllCoroutines ();
			StartCoroutine (CoWaitAndEnd ());
	      
	    }
	}

	IEnumerator CoWaitAndEnd()
	{
		CharacterAnimationController.instance.PlayAnimation (CharacterAnimationController.AnimationType.Sad);
		yield return new WaitForSeconds (3f);

		SceneManager.LoadScene("end_game_scene");
	}


}
