using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class testMain2 : MonoBehaviour {

	public Text myText;
    public GameObject myWave1;
    public GameObject myWave2;
    private float gameTime = 12f;
    public Text myTime;
    //private Vector3 pos= new Vector3(0, -1.7f, 0); 
    private Vector3 targetPosition;
	//public GameObject mySprite;

    void start()
    {
		
    }


	void showSprite(GameObject g)
	{
		/*
		float f = g.GetComponent<SpriteRenderer>().sprite.bounds.size.x; 
		g.transform.position = new Vector3 (0,-3f, 0);
		Debug.Log(g.transform.position.y+(f/3));
		*/
	}

	/// <summary>
    /// 
    /// </summary>
    void Update() {
        //distination1.position = targetPosition;
        gameTime -= Time.deltaTime;
        if (myTime.text != "0")
            myTime.text = ((int)gameTime).ToString();
        //if (Input.GetKey (KeyCode.A) == true)
        //showSprite (mySprite);

        if (gameTime <= 9f && gameTime >= 7f)
        {
            //myWave1.SetActive(true);
            //if (myWave1.transform.position.y >= -3.1f)
            if (myWave1.transform.position.y >= -1.1f)
            {
                //pos.y = pos.y - .05f;
                //myWave1.transform.position = pos;
                myWave1.transform.Translate(Vector3.down * Time.deltaTime);
            }
        }
        if (gameTime <= 6f && gameTime >= 4f)
        {
            //myWave1.SetActive(true);
            if (myWave1.transform.position.y <= 0)
            {
                myWave1.transform.Translate(Vector3.up * Time.deltaTime);
            }
        }
        if (gameTime <= 4f && gameTime >= 2f)
        {
            //myWave1.SetActive(true);
            if (myWave1.transform.position.y >= -1.75f)
            {
                myWave1.transform.Translate(Vector3.down * Time.deltaTime*2);
            }

        }
        if ((int)gameTime <= 2 && (int)gameTime >= 0)
        {
            //myWave1.SetActive(true);
            if (myWave1.transform.position.y <= 0)
            {
                myWave1.transform.Translate(Vector3.up * Time.deltaTime*2);
            }

        }
        
        myText.text = ((int)(gameTime)).ToString()+" "+ myWave1.transform.position.y.ToString();
        //transform.Translate(Vector3.forward * Time.deltaTime);
        if (gameTime <= 0f && (int)gameTime >= -2)
        {
            //gameTime = 10f;
            if (myWave1.transform.position.y >= -2.75f)
                myWave1.transform.Translate(Vector3.down * Time.deltaTime * 4);


        }
        if (gameTime <= -2f)
            gameTime = 12f;

    }
}
