using UnityEngine;
using System.Collections;

namespace UnityStandardAssets._2D
{
	public class Trasportar : MonoBehaviour {
		public Transform t;
		private bool mute;
		private float contador = 2.5f;
		private float contadorMemoria = 2.5f;
		private void FixedUpdate(){
			if (mute) {
				contador -= Time.deltaTime;
				if (contador <= 0) {
					contador = contadorMemoria;
					mute = false;
				}
			}
		}

		IEnumerator OnTriggerEnter2D(Collider2D other) {
			if (!mute) {
				mute = true;
				Debug.Log ("Funciona");
				Fader f = GameObject.FindGameObjectWithTag ("fader").GetComponent<Fader> ();
				yield return StartCoroutine (f.fadeToBlack ());
				other.gameObject.transform.position = t.position;
				Camera.current.GetComponent<CamaraMia> ().cambiarPos (t);
				yield return StartCoroutine (f.fadeToClear ());
			}
		}
	}
}
