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

public class CuerdaController : MonoBehaviour {

	public Animator anim;
	public AudioClip rompe;

	void Start () {
		anim = GetComponent<Animator> ();
	}

	void Update () {
		if (this.anim.GetCurrentAnimatorStateInfo(0).IsName("Candelabro_fall"))
		{
			GameObject box = GameObject.FindGameObjectWithTag ("BigFuckingBox");
			Destroy(box);
		}
	}


	void OnTriggerEnter2D(Collider2D other){
		if (other.gameObject.tag == "Flecha") {
			StartCoroutine(WaitFor (1f));
			anim.SetBool ("cayendo", true);
			Destroy (gameObject,1f);
		}
	}

	private IEnumerator WaitFor(float seconds){
		yield return new WaitForSeconds (seconds);
		AudioSource audi = new AudioSource ();
		audi.clip = rompe;
		audi.Play ();
	}

}
