using UnityEngine;
using System.Collections;

public class QuestionController : MonoBehaviour {

	Animator anim;
	public Collider[] buttonsC;
	public UILabel question;
	public bool isQ;

	Color alpha;
	int dir;
	
	// Use this for initialization
	void Start () {
		isQ=true;
		anim=GetComponent<Animator>();
		alpha=question.color;
		dir=1;
	}

	public void ResetQuestion(){
		anim.SetTrigger("reset");
		transform.localPosition=Vector3.zero;
		alpha.a=1;
		question.color=alpha;
		question.text="";
		dir=1;
	}

	public IEnumerator QAlpha(){
		while(true){
			alpha.a+=(Time.deltaTime*3.5f*dir);
			alpha.a=Mathf.Clamp01(alpha.a);
			question.color=alpha;
			yield return null;
			if(alpha.a>=1 || alpha.a<=0)
				yield break;
		}
	}

	public void WhatButton(){
		if(isQ){
			dir*=-1;
			StartCoroutine(QAlpha());
			anim.SetTrigger("what");
		}
		else{
			GameHandler.gameHandler.Continue();
		}

	}
	
	public void DEColliders(){
		buttonsC[0].enabled=!buttonsC[0].enabled;
		buttonsC[1].enabled=!buttonsC[1].enabled;
		buttonsC[2].enabled=!buttonsC[2].enabled;
	}
}
