using UnityEngine;
using System.Collections;

public class SimpleEffect : MonoBehaviour
{

    [SerializeField] ParticleSystem particleSystem;

    public float duration;

    public void Create(Vector3 position, float scale = 1f)
    {
        var instance = Instantiate(this, position, Quaternion.identity) as SimpleEffect;
        instance.transform.localScale = transform.localScale * scale;
        instance.transform.rotation = Math2D.AngleToRotation(Random.value * 360f);
        if (duration == 0)
            duration = particleSystem.duration;
        Destroy(instance.gameObject, duration);
    }
}
