using System.Collections; using System.Collections.Generic; using UnityEngine; /// <summary> /// Handles primarily dialogue sound clips /// </summary> public class DialogueManager : MonoBehaviour { public static DialogueManager Instance { get; private set; } // Instance container for the singleton pattern of the dialogue manager private static AudioSource audioSource; // The audiosource component attached to this component /// <summary> /// Retrieval system for the audio source attached to the Dialogue Manager /// </summary> /// <returns>The Audio Source attached</returns> public AudioSource GetAudioSource() => audioSource; /// <summary> /// Singleton pattern of the DialogueManager is created /// </summary> private void Awake() { Instance = this; audioSource = GetComponent<AudioSource>(); } /// <summary> /// Sets the clip to the audio source and then plays the clip /// </summary> /// <param name="clip">The dialogue clip to play</param> public void PlayDialogueClip(AudioClip clip) { audioSource.clip = clip; audioSource.Play(); } /// <summary> /// Retrieval check for the dialogue audio source playing a clip /// </summary> /// <returns>State of the audio source playing a clip</returns> public bool CheckDialogueStatus() => audioSource.isPlaying; }