using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using CorgiLabs.Utility;

public class EventSounds : MonoBehaviour
{
    [SerializeField] private SoundEffect m_FailSfx;
    [SerializeField] private SoundEffect m_GameOverSfx;
    [SerializeField] private SoundEffect m_LevelUpSfx;

    private Transform m_Transform;

    private void Awake()
    {
        m_Transform = transform;
    }

    private void OnEnable()
    {
        EventManager.StartListening<GhostEventSource>(EventID.GhostEventFail, OnFail);
        EventManager.StartListening(EventID.LevelUp, OnLevelUp);
        EventManager.StartListening(EventID.GameOver, OnGameOver);
    }

    private void OnFail(GhostEventSource source)
    {
        m_FailSfx.Play(m_Transform.position);
    }

    private void OnLevelUp()
    {
        m_LevelUpSfx.Play(m_Transform.position);
    }

    private void OnGameOver()
    {
        m_GameOverSfx.Play(m_Transform.position);
    }
}
