using UnityEngine; public class HauntedTV : MonoBehaviour { public AudioSource tvAudioSource, tvLaughAudioSource, watcherAudioSource; public AudioClip tvLaughSound, tvSound, watcherLaughSound; public Light tvLight; private bool isOn = false; void Start() { if(tvAudioSource == null) tvAudioSource = GetComponent(); tvAudioSource.loop = true; // Make sure the static loops! if(watcherAudioSource == null) watcherAudioSource = GetComponent(); watcherAudioSource.loop = true; // Make sure the laugh loops! if (tvLight != null) tvLight.enabled = false; } // Call this from the LightSwitch "OnFirstSwitchOff" public void StartEvent() { if (!isOn && tvSound != null && watcherLaughSound != null && tvLaughSound != null) { tvAudioSource.clip = tvSound; tvLaughAudioSource.clip = tvLaughSound; watcherAudioSource.clip = watcherLaughSound; tvAudioSource.Play(); tvLaughAudioSource.Play(); watcherAudioSource.Play(); isOn = true; if (tvLight != null) tvLight.enabled = true; Debug.Log("TV started static..."); } } // Call this from the LightSwitch "OnFirstSwitchOn" public void StopEvent() { if (isOn) { tvAudioSource.Stop(); watcherAudioSource.Stop(); tvLaughAudioSource.Stop(); isOn = false; if (tvLight != null) tvLight.enabled = false; Debug.Log("TV stopped static."); } } }