private IEnumerator DelayRestart() { var player = GameObject.Find("Player"); if (player != null) { player.GetComponent <CharacterDefinition>().DisableControl(); } if (Text != null) { GetComponent <AudioSource>().PlayOneShot(YouDiedClip); var typewriter = new TypeWriter("You died!", 50f); while (!typewriter.Done) { if (_skipRequested) { typewriter.SkipToEnd(); Text.text = typewriter.CurrentText; break; } if (typewriter.Update()) { Text.text = typewriter.CurrentText; } yield return(new WaitForEndOfFrame()); } } yield return(new WaitForSeconds(2)); Application.LoadLevel(Application.loadedLevelName); }
private IEnumerator Intro() { Text.text = ""; yield return(new WaitForSeconds(0.5f)); foreach (var textSequence in Texts) { var typeWriter = new TypeWriter(textSequence.Text, 80f); if (!_skipRequested) { PlaySound(BoatHornClip); } _skipRequested = false; while (!typeWriter.Done) { if (_skipRequested) { typeWriter.SkipToEnd(); break; } if (typeWriter.Update()) { Text.text = typeWriter.CurrentText; } yield return(new WaitForEndOfFrame()); } yield return(new WaitForSeconds(0.5f)); } Text.text = ""; // TODO: goto next scene if (!string.IsNullOrEmpty(GoToLevel)) { Application.LoadLevel(GoToLevel); } }