using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Generate : MonoBehaviour {

    public float time;
    private int count = 0;
    public AcceptState accpt;
    private Animator anim;

    void Start(){
        anim = GetComponent<Animator>();
    }
    //public float[] starttime = new float[] {0.088f ,1.072f,2.057f,3.041f,4.025f,5.009f,5.9f,6.8f,7f,7.9f,8.9f,9.9f,10.9f,11.8f,12.8f,13.8f,14.8f,15.8f,16.5f,16.5f,17.29f,17.77f,18.53f,18.74f,19.26f,19.7f,20.5f,21.9f,22.21f,21.7f,22.2f,23.2f,24.0f,24.6f,25.1f,26f};
    //public string[] inputkey = new string[] { "s", "Down", "s", "Down", "s", "Down", "s", "Down","s", "Down","s", "Down","Right","Right","Right","s", "Down","s", "Down","s", "Down","s", "Down","s", "Down","s", "Down","s", "Down","Right","Right","Right","s", "Down","a","a","a","left","a","a","a","left","a","a","a","left","Right","Right","Right","d","d","a","a","a","left","a","a","a","left","Right","Right","Right","Left","a","d","a","d","a","a","d","Down","Right","s","a","s","s","d","Down","Right","s","Down","Right","s"};


	// Use this for initialization
	/*void Start()
	{
            InvokeRepeating("CreateObstacle", 1f, 1.2f);
	}

	void CreateObstacle()
	{
		int v1 = Random.Range (1,6);
		if (v1  < 4) {
            GameObject gb1 = (GameObject)Instantiate(Resources.Load("Left"),new Vector3(8,2f,0),Quaternion.identity);	
        }else if (v1 == 4){
            GameObject gb2 = (GameObject)Instantiate(Resources.Load("Down"),new Vector3(8,2f,0),Quaternion.identity);	
		}else if (v1 > 4){
            GameObject gb3 = (GameObject)Instantiate(Resources.Load("Right"),new Vector3(8,2f,0),Quaternion.identity);	
		}

	}*/
    public float[] starttime = new float[] {0.088f, 0.582f,1.072f,1.565f,2.057f,2.549f,3.041f,3.533f,4.025f,4.517f,5.009f,5.501f,5.5f,6.2f,6.5f,7f,7.4f,7.9f,8.4f,8.9f,9.4f,9.9f,10.4f,10.9f,11.4f,11.8f,12.38f,12.8f,13.3f,13.8f,14.1f,14.4f,14.8f,15.3f,15.8f,16.2f,16.5f,16.5f,16.82f,17.29f,17.77f,18.16f,18.53f,18.74f,19.26f,19.7f,20.13f,20.5f,20.76f,21.24f,21.73f,21.9f,22.21f,22.71f,23.2f,23.6f,24.0f,24.4f,24.6f,25.1f,25.6f,26f,26.6f,27.1f,27.6f,28f,28.3f,29.1f,30.0f,30.3f,30.5f,30.8f,31.0f,31.29f};
    public string[] inputkey = new string[] { "s", "Down", "s", "Down", "s", "Down", "s", "Down","s", "Down","s", "Down","Right","Right","Right","s", "Down","s", "Down","s", "Down","s", "Down","s", "Down","s", "Down","s", "Down","Right","Right","Right","s", "Down","a","a","a","left","a","a","a","left","a","a","a","left","Right","Right","Right","d","d","a","a","a","left","a","a","a","left","Right","Right","Right","Left","a","d","a","d"};

    public bool damage;
    public bool green;

    void Update(){
        damage = accpt.angry;
        green = accpt.green;

        if (green)
        {
            anim.SetBool("Okay", true);
        }
        else
        {
            anim.SetBool("Okay", false);
        }

        if(damage){
            anim.SetBool("Angry", true);
        }else{
            anim.SetBool("Angry", false);
        }
    }

    void FixedUpdate(){
        time = Time.time;

        if (count < 73 && time >= starttime[count])
        {
            Instantiate(Resources.Load(inputkey[count]), new Vector3(8, 4f, 0), Quaternion.identity);
            count++;
        }
    }
}