using UnityEngine;
using System.Collections;
/*fazer copia*/
public class JogadorAzul : MonoBehaviour {

    public float velocidade;
    public Transform player;
    private Animator animator;
    public  Pilha p1 = new Pilha();
    


    void Start () {
        animator = player.GetComponent<Animator>();
        p1 = p1.GetComponent<Pilha>();

        p1.Gerar_pilha_aleatoria(); 
        p1.Gerar_pilha_auxiliar();
        //p1.Gerar_pilha_popula();
        p1.Plota_mystack();
    }
	
	// Update is called once per frame
	void Update () {
        Movimentacao();
    }

    void Movimentacao()
    {

        if (Input.GetAxisRaw("HorizontalSeta") > 0)
        {
            transform.Translate(Vector2.right * velocidade * Time.deltaTime);
        }

        if (Input.GetAxisRaw("HorizontalSeta") < 0)
        {
            transform.Translate(-Vector2.right * velocidade * Time.deltaTime);
        }

        if (Input.GetAxisRaw("VerticalSeta") > 0)
        {
            transform.Translate(Vector2.up * velocidade * Time.deltaTime);
        }

        if (Input.GetAxisRaw("VerticalSeta") < 0)
        {
            transform.Translate(-Vector2.up * velocidade * Time.deltaTime);
        }

        animator.SetFloat("Horizontal", Input.GetAxisRaw("HorizontalSeta"));
        animator.SetFloat("Vertical", Input.GetAxisRaw("VerticalSeta"));

    }


    void OnTriggerEnter2D(Collider2D co)
    {
        Debug.Log("Peak: "+p1.Peek_auxiliar().ToString());
        Debug.Log("Cod: " + co.gameObject.tag + " (UnityEngine.GameObject)");
        //Debug.Log("Proximo " + p1.Peek_mystakc().ToString());

        if (co.gameObject.tag+ " (UnityEngine.GameObject)" == (p1.Peek_auxiliar().ToString()))
        {
            Debug.Log("entrei");
            p1.Push_mystack();
            //p1.Plota_myStack_Vazia();
            p1.Plota_mystack();
            //p1.Plota_auxstack();
        }

    }
}

