using UnityEngine;
using System.Collections;

public class Mg_ParticleSystem : Singleton<Mg_ParticleSystem> {

    protected bool letPlay = false;

    public void Start()
    {
        gameObject.particleSystem.Stop();
    }

    public void PlayExplosion(Vector3 pos, Color color)
    {
        gameObject.transform.position = pos;
        gameObject.particleSystem.startColor = color;
        letPlay = true;
    }

    public void Update()
    {
        if (letPlay)
        {
            if (!gameObject.particleSystem.isPlaying)
            {
                gameObject.particleSystem.Play();
            }
            else
            {
                if (gameObject.particleSystem.isPlaying)
                {
                    gameObject.particleSystem.Stop();
                    gameObject.particleSystem.Play();
                }
            }  

            letPlay = false;
        }
    }
}
