protected IEnumerator SayDTSOverTime() { //spawn an effect over the characters' head Motile motile = worlditem.Get <Motile> (); FXManager.Get.SpawnFX(motile.Body.Transforms.HeadTop.gameObject, "SpeakEffect", Vector3.zero); mSayingDTS = true; mLastDTSPage = -1; string pageText = string.Empty; float pageDuration = 0.0f; bool continueDTS = true; if (!string.IsNullOrEmpty(mDTS.OnFinishCommand)) { mSpeechBubble = CreateSpeechBubble(mDTS, null, worlditem.tr); } yield return(null); while (continueDTS) { continueDTS = mDTS.GetPage(ref pageText, ref pageDuration, ref mLastDTSPage, true); if (continueDTS) { NGUIScreenDialog.AddSpeech(pageText, worlditem.DisplayName, pageDuration); double waitUntil = Frontiers.WorldClock.AdjustedRealTime + pageDuration; while (Frontiers.WorldClock.AdjustedRealTime < waitUntil) { yield return(null); } } } if (mSpeechBubble != null) { mSpeechBubble.FinishSpeech(); } if (!string.IsNullOrEmpty(mDTS.OnFinishMissionActivate)) { if (!string.IsNullOrEmpty(mDTS.OnFinishObjectiveActivate)) { Missions.Get.ActivateObjective(mDTS.OnFinishMissionActivate, mDTS.OnFinishObjectiveActivate, MissionOriginType.Character, worlditem.FileName); } else { Missions.Get.ActivateMission(mDTS.OnFinishMissionActivate, MissionOriginType.Character, worlditem.FileName); } } mDTS = null; mSayingDTS = false; yield break; }
protected IEnumerator GiveSpeechesOverTime() { mGivingSpeeches = true; while (mNewSpeeches.Count > 0 || mSpeech != null) //if we already have a speech and it's not finished { if (mSpeech == null) { mSpeech = mNewSpeeches.Dequeue(); yield return(StartCoroutine(StartSpeech(mSpeech))); } if (mSpeech.speech == null) { Debug.Log("Dispatched speech was null"); yield break; } //give this speech State.GivingSpeech = true; State.LastSpeechPage = -1; string pageText = string.Empty; float pageDuration = 0.0f; while (State.GivingSpeech) { if (mInterruptionRequest) { if (mSpeech.speech.CanBeInterrupted) //interrupt this speech and clear the rest //speeches will all stop after the next loop { yield return(StartCoroutine(InterruptSpeech(mSpeech))); mNewSpeeches.Clear(); } mInterruptionRequest = false; } else //getting next page of speech { bool isFinished = mSpeech.speech.GetPage(ref pageText, ref pageDuration, ref State.LastSpeechPage, true); if (State.LastSpeechPage >= 0) { //Debug.Log ("Putting speech on page"); if (Player.Local.Surroundings.IsSoundAudible(worlditem.tr.position, mSpeech.speech.AudibleRange)) { //player can hear speech, put it on screen //Debug.Log ("Speech is audible"); Motile motile = worlditem.Get <Motile> (); FXManager.Get.SpawnFX(motile.Body.Transforms.HeadTop.gameObject, "SpeakEffect", Vector3.zero); NGUIScreenDialog.AddSpeech(pageText, worlditem.DisplayName, pageDuration); } //TEMP - implement listener target on pages mSpeechBubble.NextPage("[Random]"); double waitUntil = Frontiers.WorldClock.AdjustedRealTime + pageDuration; while (Frontiers.WorldClock.AdjustedRealTime < waitUntil) { yield return(null); } } if (isFinished) { //Debug.Log ("Finished"); var finishSpeech = FinishSpeech(mSpeech); while (finishSpeech.MoveNext()) { yield return(finishSpeech.Current); } mSpeech = null; State.GivingSpeech = false; } } //we're done giving the speech } } mGivingSpeeches = false; yield break; }