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

public class NoiseManager : Singleton<NoiseManager>
{
    #region Fields
    [SerializeField] private CinemachineVirtualCamera _vcam;
    #endregion Fields
	
    #region Methods
    public void PlayNoise(float amplitude, float frequency, float duration)
    {
        StopAllCoroutines();
        StartCoroutine(Noise(amplitude, frequency, duration));
    }

    IEnumerator Noise(float amplitude, float frequency, float duration)
    {
        _vcam.GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>().m_AmplitudeGain = amplitude;
        _vcam.GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>().m_FrequencyGain = frequency;
        yield return new WaitForSeconds(duration);
        _vcam.GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>().m_AmplitudeGain = 0;
        _vcam.GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>().m_FrequencyGain = 0;
    }
    #endregion Methods
}
