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

namespace BR.BattleRoyale.Spells
{
    public class SpellFX : MonoBehaviour
    {
        [Tooltip("A list containing all prompted effects")]
        [SerializeField] ParticleSystem[] m_promptedParticles;

        [Tooltip("A list containing all looping effects")]
        [SerializeField] ParticleSystem[] m_loopedParticles;
        
        public void PlayBurst()
        {
            foreach (ParticleSystem _system in m_promptedParticles)
            {
                if (_system.main.loop)
                {
                    ParticleSystem.MainModule _main = _system.main;
                    _main.loop = false;
                }

                if (_system.isPlaying)
                    _system.Stop();

                _system.Play();
            }
        }
	
	    public void PlayAll()
        {
            foreach (ParticleSystem _system in m_promptedParticles)
            {
                if (_system.main.loop)
                {
                    ParticleSystem.MainModule _main = _system.main;
                    _main.loop = false;
                }

                if (_system.isPlaying)
                    _system.Stop();

                _system.Play();
            }

            foreach (ParticleSystem _system in m_loopedParticles)
            {
                if (!_system.main.loop)
                {
                    ParticleSystem.MainModule _main = _system.main;
                    _main.loop = true;
                }

                if (!_system.isPlaying)
                    _system.Play();
            }
        }

        public void StopAll()
        {
            foreach (ParticleSystem _system in m_promptedParticles)
                if (_system.isPlaying)
                    _system.Stop();

            foreach (ParticleSystem _system in m_loopedParticles)
                if (_system.isPlaying)
                    _system.Stop();
        }
    }
}
