using UnityEngine;
using System.Collections;

[RequireComponent(typeof(BoxCollider))]
[RequireComponent(typeof(Rigidbody))]
public class Trick_TV : MonoBehaviour {

	public GameObject particles;
	public bool isSmashed = false;

	void Start()
	{
		transform.rotation = Random.rotation;
	}

	void OnCollisionEnter(Collision collision)
	{
		if (isSmashed)
			return;
		if (collision.gameObject.CompareTag("TV Smasher")) 
		{
			isSmashed = true;
			collision.collider.SendMessage ("TVSmash", SendMessageOptions.DontRequireReceiver);
			if (particles)
			{
				GameObject go = (GameObject)GameObject.Instantiate (particles, transform.position, transform.rotation);
				go.transform.parent = transform;
			}
		}
	}
}
