2025-12-03 17:23:18 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class HauntedPhone : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public AudioSource phoneAudioSource;
|
|
|
|
|
public AudioClip ringSound;
|
2025-12-04 10:53:21 +00:00
|
|
|
|
2025-12-03 17:23:18 +00:00
|
|
|
private bool isRinging = false;
|
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
2025-12-04 10:53:21 +00:00
|
|
|
if (phoneAudioSource == null) phoneAudioSource = GetComponent<AudioSource>();
|
2025-12-03 17:23:18 +00:00
|
|
|
phoneAudioSource.loop = true; // Make sure the ringing loops!
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Call this from the LightSwitch "OnFirstSwitchOff"
|
|
|
|
|
public void StartRinging()
|
|
|
|
|
{
|
|
|
|
|
if (!isRinging && ringSound != null)
|
|
|
|
|
{
|
|
|
|
|
phoneAudioSource.clip = ringSound;
|
|
|
|
|
phoneAudioSource.Play();
|
|
|
|
|
isRinging = true;
|
|
|
|
|
Debug.Log("Phone started ringing...");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Call this from the LightSwitch "OnFirstSwitchOn"
|
|
|
|
|
public void StopRinging()
|
|
|
|
|
{
|
|
|
|
|
if (isRinging)
|
|
|
|
|
{
|
|
|
|
|
phoneAudioSource.Stop();
|
|
|
|
|
isRinging = false;
|
|
|
|
|
Debug.Log("Phone stopped.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Call this from "OnRandomEvent" for a quick scare
|
|
|
|
|
public void PlayCreepyWhisper()
|
|
|
|
|
{
|
|
|
|
|
// Logic for a one-shot scare sound
|
|
|
|
|
Debug.Log("Creepy whisper played from phone...");
|
|
|
|
|
}
|
|
|
|
|
}
|