using UnityEngine;
using System.Collections;

public class ParticlesMuthaFucka : MonoBehaviour {

	public GameObject ParticleYo;
	public Vector3 Pos;
	//

	// Use this for initialization
	void Start () {
		for (var i = 0; i < 100; ++i){
			Invoke("Spawn", i % 10 * 0.05f);
		}
	}
	
	/*// Update is called once per frame
	void Update () {
		Timer -= Time.deltaTime;
		if (Timer < 0){
			Debug.Log("Remove");
			Destroy (this.gameObject);
		}
	}*/

	void Spawn (){
		var P = Instantiate(ParticleYo, Pos, Quaternion.identity);
		var tmpVelocity = new Vector3((Random.value * 30 - 15), (Random.value * 20), (Random.value * 30 - 15)) * 5;
		var tmpPos = new Vector3(Random.value * 4 - 2, Random.value * 4, Random.value * 4 - 2);
		(P as GameObject).transform.position = Pos + tmpPos;
		(P as GameObject).GetComponent<Rigidbody>().velocity = tmpVelocity;
		(P as GameObject).GetComponent<Rigidbody>().maxAngularVelocity = 100;
		(P as GameObject).GetComponent<Rigidbody>().angularVelocity = new Vector3(Random.value * 100, Random.value * 100, Random.value * 100);
	}

	/*public void OnTriggerEnter(Collider other){

		if (other.gameObject.tag != "GoreParticle"){
			Debug.Log("HIT");
			Destroy (this.gameObject);
		}
	}*/
}
