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

public class BloodSpawner : MonoBehaviour {
    public ParticleSystem particles;

    public short amount = 10;

    Vector3 squirtdir;

	// Use this for initialization
	void Start () {
        ParticleSystemRenderer r = particles.GetComponent<ParticleSystemRenderer>();
        r.sortingOrder -= (int)(transform.position.z * 10);
        StartCoroutine(Kill());

        //ParticleSystem.EmissionModule em = particles.emission;

        //em.enabled = true;

        //ParticleSystem.Burst[] bursts = new ParticleSystem.Burst[] {
        //    new ParticleSystem.Burst(0.5f, (short)(amount - 10), amount),
        //    new ParticleSystem.Burst(1f, (short)(amount - 10), amount),
        //    new ParticleSystem.Burst(1.5f, (short)(amount - 10), amount),
        //};
        //em.SetBursts(bursts);

        //particles.Play();
	}

    public void SetAmount(int amount)
    {
        this.amount = (short)Mathf.Clamp(amount, 10, 50);
    }
	
	// Update is called once per frame
	void Update () {

	}

    IEnumerator Kill()
    {
        yield return new WaitForSeconds(3f);
        Destroy(gameObject);
    }
}
