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

	public class Move2 : MonoBehaviour {

	public float speed;
	public static bool veriColl2;
	public GameObject worm1;
	public GameObject worm2;

	public float speed1;
	public float speed2;
	public float speed3;
	public float speed4;

	public static bool pFinal2;

	//public GameObject players;
	void OnCollisionEnter2D(Collision2D coll){
		if (coll.gameObject.tag == "Obstaculo") {
			veriColl2 = false;
			//speed = 0;
		}
		if (coll.gameObject.tag == "Player") {
			Destroy (worm1);
			Destroy (worm2);
			speed = 0;
		}
			
		if (coll.gameObject.tag == "Chegada") {
			pFinal2 = true;
		}
	}
		// Use this for initialization
		void Start () {
		veriColl2 = true;
		pFinal2 = true;
		}

		// Update is called once per frame
		void Update () {
			if (Move.veriColl1 == false) {
				speed = 0;
			}else{
			// Verificar se o jogo está ativo
			if (Input.GetKey (KeyCode.D)) {
				if (veriColl2 == false) {
					speed1 = 0;	
				}
				speed1 = 0.1f;	
				transform.Translate (Vector2.right * (-speed1));
			}
			veriColl2 = true;
			if (Input.GetKey(KeyCode.A))
			{
				if (veriColl2 == false) {
					speed2 = 0;	
				}
				speed2 = 0.1f;
				transform.Translate (-Vector2.right * (-speed2));
			}
			veriColl2 = true;
			if (Input.GetKey(KeyCode.W))
			{if (veriColl2 == false) {
					speed3 = 0;	
				}
				speed1 = 0.1f;
				transform.Translate (Vector2.up * (-speed3));
			}
			veriColl2 = true;
			if (Input.GetKey(KeyCode.S))
			{
				if (veriColl2 == false) {
					speed4 = 0;	
				}
				speed4 = 0.1f;
				transform.Translate (-Vector2.up * (-speed4));
			}
			veriColl2 = true;
		}
	}
}