Continued working on the lights, set up playable version and turn trap at the end of the stairs. Working on making stairs feel longer.
This commit is contained in:
45
Assets/Scripts/HauntedPhone.cs
Normal file
45
Assets/Scripts/HauntedPhone.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class HauntedPhone : MonoBehaviour
|
||||
{
|
||||
public AudioSource phoneAudioSource;
|
||||
public AudioClip ringSound;
|
||||
|
||||
private bool isRinging = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if(phoneAudioSource == null) phoneAudioSource = GetComponent<AudioSource>();
|
||||
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...");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user