diff --git a/Assets/PantoScripts/RailPolyline.cs b/Assets/PantoScripts/RailPolyline.cs index d466b6b..05c253b 100644 --- a/Assets/PantoScripts/RailPolyline.cs +++ b/Assets/PantoScripts/RailPolyline.cs @@ -1,3 +1,5 @@ +using System; +using System.Threading.Tasks; using DualPantoFramework; namespace UnityEngine { @@ -58,15 +60,46 @@ private void Start() audioSource.volume = 0; } - private void OnTriggerEnter(Collider other) + async private void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) { + Debug.Log("fade target"); + PantoManager pantoManager = GameObject.Find("PantoManager").GetComponent(); + if (!pantoManager.hasEncounteredRail){ + await IntroduceRailAsync(pantoManager); + } //audioSource.Play(); fadeTarget = 1; } } + private async System.Threading.Tasks.Task IntroduceRailAsync(PantoManager pantoManager) + { + pantoManager.SetPaused(true); + pantoManager.upper.Freeze(); + pantoManager.lower.Freeze(); + + Debug.Log("introducing rail"); + pantoManager.hasEncounteredRail = true; + AudioSource railAudio = gameObject.AddComponent(); + railAudio.clip = Resources.Load("Sounds/Speech/Rails"); + + AudioSource dingAudioSource = gameObject.AddComponent(); + dingAudioSource.clip = Resources.Load("Sounds/IntroSound2"); + dingAudioSource.PlayOneShot(dingAudioSource.clip); + await Task.Delay((int)dingAudioSource.clip.length * 1000); + railAudio.Play(); + while(railAudio.isPlaying){ + await Task.Delay(10); + } + + dingAudioSource.PlayOneShot(dingAudioSource.clip); + await Task.Delay((int)dingAudioSource.clip.length * 1000); + pantoManager.SetPaused(false); + + } + private void OnTriggerExit(Collider other) { if (other.CompareTag("Player")) diff --git a/Assets/SpeechIOForUnity b/Assets/SpeechIOForUnity index f11aa7f..2d85d32 160000 --- a/Assets/SpeechIOForUnity +++ b/Assets/SpeechIOForUnity @@ -1 +1 @@ -Subproject commit f11aa7f91384e8bb14040c25dac4d4f3bceefc0c +Subproject commit 2d85d324b2980990d079b5c96a1cad86e046ebcd