using UnityEngine;
using System.Collections;

public class Stealth : MonoBehaviour {
private SpriteRenderer stealthy;
private bool Canhide;
	// Use this for initialization
	void Start () {
		stealthy = GetComponent<SpriteRenderer> ();
	}
	
	// Update is called once per frame
	void Update () {

		if (Input.GetKeyDown(KeyCode.UpArrow)&& Canhide == true) {
			stealthy.sortingOrder = -1;
			gameObject.layer = 11;
		}
		if (Input.GetKeyUp (KeyCode.UpArrow)) {
			stealthy.sortingOrder = 0;
			gameObject.layer = 8;
			Canhide = false;
		}
		//if (Canhide == false) {
		//	stealthy.sortingOrder = 0;
		//	gameObject.layer = 8;
		//}
	
	}

	void OnTriggerEnter2D (Collider2D other){
		if (other.gameObject.tag == "Column") {
			Canhide = true;
			Debug.Log ("You can now hide.");
		} 
//		//else { 
//		//	Canhide = false;
//		//	Debug.Log("You're exposed! Quick, get to cover.");
//		//}
}
//
//	void OnTriggerExit2D (Collider2D other){
//		if (other.gameObject.tag == "Column") {
//			Canhide = false;
//			Debug.Log("You're exposed! Quick, get to cover.");
//		}
//	}
}