using UnityEngine;
using System.Collections;

public class touch : MonoBehaviour {
	public Transform tank;
	public bool chkdown;
	public bool chkdonwD;
	public bool chkdonwR;
	public bool chkdonwL;
	public GameObject bullet;
	public Transform posbullet;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {

		//UP
	if (chkdown == true) {
			tank.rotation=Quaternion.Euler(new Vector3(tank.rotation.x,tank.rotation.y,180));
			tank.position=new Vector2(tank.position.x,tank.position.y+0.05f);
		}

		//DONW

		if (chkdonwD == true) {

			tank.rotation=Quaternion.Euler(new Vector3(tank.rotation.x,tank.rotation.y,0));
			tank.position=new Vector2(tank.position.x,tank.position.y-0.05f);

		}

	//	RIGHT
		if (chkdonwR == true) {

			tank.rotation=Quaternion.Euler(new Vector3(tank.rotation.x,tank.rotation.y,90));
			tank.position=new Vector2(tank.position.x+0.05f,tank.position.y);

		}

	//LAFT
		if(chkdonwL==true){

			tank.rotation=Quaternion.Euler(new Vector3(tank.rotation.x,tank.rotation.y,-90));
			tank.position=new Vector2(tank.position.x-0.05f,tank.position.y);

		}
	}


	//up
	public void donw(){

		if (chkdonwD == false && chkdonwR == false && chkdonwL == false) {
			chkdown = true;
		}
	}
	public void up(){


		chkdown = false;
	}


	// DONW
	public void DonwD(){
		if (chkdown == false && chkdonwR == false && chkdonwL == false) {
			chkdonwD = true;
		}

	}
	public void UPD(){
		
		chkdonwD = false;
	}

	//Right
	public void DonwR(){
		if (chkdown == false && chkdonwD == false && chkdonwL == false) {
			chkdonwR = true;
		}
		
	}
	public void UPR(){
		
		chkdonwR = false;
	}

	//LAFt

	public void DonwL(){
		if (chkdown == false && chkdonwD == false && chkdonwR == false) {
			chkdonwL = true;
		}
		
	}
	public void UPL(){
		
		chkdonwL = false;
	}
	public void Fire(){
		Instantiate (bullet, posbullet.position, posbullet.rotation);

	}

}
