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:
82
Assets/Scripts/HauntedPram.cs
Normal file
82
Assets/Scripts/HauntedPram.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class HauntedPram : MonoBehaviour
|
||||
{
|
||||
public AudioSource pramAudioSource, babyAudioSource;
|
||||
public AudioClip creakSound, babyCrySound;
|
||||
|
||||
private bool isCreaking = false, isCrying = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if(pramAudioSource == null) pramAudioSource = GetComponent<AudioSource>();
|
||||
pramAudioSource.loop = true; // Make sure the creaking loops!
|
||||
}
|
||||
|
||||
// Call this from the LightSwitch "OnFirstSwitchOff"
|
||||
public void StartCreaking()
|
||||
{
|
||||
if (!isCreaking && creakSound != null)
|
||||
{
|
||||
pramAudioSource.clip = creakSound;
|
||||
pramAudioSource.Play();
|
||||
isCreaking = true;
|
||||
Debug.Log("Pram started creaking...");
|
||||
}
|
||||
}
|
||||
|
||||
// Call this from the LightSwitch "OnFirstSwitchOn"
|
||||
public void StopCreaking()
|
||||
{
|
||||
if (isCreaking)
|
||||
{
|
||||
pramAudioSource.Stop();
|
||||
isCreaking = false;
|
||||
Debug.Log("Pram stopped creaking.");
|
||||
}
|
||||
}
|
||||
public void StartCrying()
|
||||
{
|
||||
if (!isCrying && babyCrySound != null)
|
||||
{
|
||||
pramAudioSource.clip = babyCrySound;
|
||||
pramAudioSource.Play();
|
||||
isCrying = true;
|
||||
Debug.Log("Pram baby started crying...");
|
||||
}
|
||||
}
|
||||
|
||||
public void StopCrying()
|
||||
{
|
||||
if (isCrying)
|
||||
{
|
||||
pramAudioSource.Stop();
|
||||
isCrying = false;
|
||||
Debug.Log("Pram baby stopped crying.");
|
||||
}
|
||||
}
|
||||
public void StartAllSounds()
|
||||
{
|
||||
if (!isCreaking && creakSound != null && !isCrying && babyCrySound != null)
|
||||
{
|
||||
pramAudioSource.clip = creakSound;
|
||||
babyAudioSource.clip = babyCrySound;
|
||||
pramAudioSource.Play();
|
||||
babyAudioSource.Play();
|
||||
isCreaking = true;
|
||||
isCrying = true;
|
||||
Debug.Log("Pram started creaking and crying...");
|
||||
}
|
||||
}
|
||||
public void StopAllSounds()
|
||||
{
|
||||
if (isCreaking || isCrying)
|
||||
{
|
||||
pramAudioSource.Stop();
|
||||
babyAudioSource.Stop();
|
||||
isCreaking = false;
|
||||
isCrying = false;
|
||||
Debug.Log("Pram stopped all sounds.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user