public void SpeakThroughIntermediary(IConversationIntermediary intermediary) { Debug.Log("Speaking through intermeidiary in " + name); if (character.IsDead || character.IsStunned || character.IsSleeping) { return; } if (!mInitiatingConversation) { mInitiatingConversation = true; StartCoroutine(InitiateConversation(intermediary)); } }
public virtual bool End() { if (LastChosenExchange != null) { LastChosenExchange.OnConcludeExchange(); } if (State.LeaveOnEnd || DespawnCharacterAfterConversation) { SpeakingCharacter.Leave(); //reset this so the next convo doesn't do the same thing DespawnCharacterAfterConversation = false; } Talkative talkative = null; if (SpeakingCharacter.worlditem.Is <Talkative> (out talkative)) { talkative.EndConversation(); } if (Intermediary != null) { Intermediary.FinishConversation(); } Intermediary = null; LastChosenExchange = null; //save state Save(); //broadcast conclusion Player.Get.AvatarActions.ReceiveAction(AvatarAction.NpcConverseEnd, WorldClock.AdjustedRealTime); //destroy this a little bit mConcluded = true; SpeakingCharacter = null; GameObject.Destroy(this, 0.25f); ConversationInProgress = false; //if we've been asked to play a cutscene do it now if (!string.IsNullOrEmpty(gCutsceneOnFinishName)) { Cutscene.CurrentCutsceneAnchor = gCutsceneOnFinishAnchor; Application.LoadLevelAdditive(gCutsceneOnFinishName); } //then reset gCutsceneOnFinishName = string.Empty; gCutsceneOnFinishAnchor = null; return(true); }
public void Initiate(Character speakingCharacter, Talkative talkative, IConversationIntermediary intermediary) { Debug.Log("Initiating conversation " + ConversationName + " with " + speakingCharacter.FullName); if (speakingCharacter.Template.TemplateType != CharacterTemplateType.Generic) { Profile.Get.CurrentGame.Character.CharactersSpokenTo.SafeAdd(speakingCharacter.Template.Name); } Intermediary = intermediary; SpeakingCharacter = speakingCharacter; SpeakingCharacterTalkative = talkative; if (SpeakingCharacter.State.Emotion == EmotionalState.Angry) { GUI.GUIManager.PostInfo(SpeakingCharacter.State.Name.FirstName + " doesn't want to speak to you."); return; } else { mInitiating = true; StartCoroutine(InitiateoverTime()); } }
public IEnumerator InitiateConversation(IConversationIntermediary intermediary) { mInitiatingConversation = true; if (intermediary == null && !worlditem.HasPlayerAttention) { #if UNITY_EDITOR Debug.Log("We don't have player's attention"); #endif mInitiatingConversation = false; yield break; } Motile m = null; if (worlditem.Is <Motile> (out m) && !m.IsImmobilized) { //if the character isn't already immobile //make the character stand still Character character = null; if (worlditem.Is <Character> (out character)) { mTalkMotileAction = character.LookAtPlayer(); } var waitToStart = mTalkMotileAction.WaitForActionToStart(0.01f); while (waitToStart.MoveNext()) { #if UNITY_EDITOR Debug.Log("Waiting for motile action to start"); #endif yield return(waitToStart.Current); } if (mTalkMotileAction.IsFinished) { #if UNITY_EDITOR Debug.Log("Talk motile action got finished for some reason, quitting"); #endif mInitiatingConversation = false; yield break; } } if (State.DefaultToDTS) { Speech speech = null; mInitiatingConversation = false; if (Mods.Get.Runtime.LoadMod(ref speech, "Speech", State.DTSSpeechName)) { SayDTS(speech); } #if UNITY_EDITOR Debug.Log("Defaulting to DTS"); #endif mInitiatingConversation = false; yield break; } yield return(null); Conversation conversation = null; string DTSOverride = string.Empty; if (Conversations.Get.ConversationByName(State.ConversationName, worlditem.FileName, out conversation, out DTSOverride)) { //wuhoo we got the conversation State.ConversationName = conversation.Props.Name; conversation.Initiate(character, this, intermediary); while (conversation.Initiating) { yield return(null); } //this will load the conversation without hitches //now we may just have a dts - in which case the conversation won't be in progress if (!Conversation.ConversationInProgress) { #if UNITY_EDITOR Debug.Log("Conversation not in progress, must have defaulted to DTS"); #endif mInitiatingConversation = false; yield break; } } else if (!string.IsNullOrEmpty(DTSOverride)) { #if UNITY_EDITOR Debug.Log("We have a dts override: " + DTSOverride); #endif //whoa we have a DTS override State.DTSSpeechName = DTSOverride; mInitiatingConversation = false; Speech speech = null; if (Mods.Get.Runtime.LoadMod(ref speech, "Speech", State.DTSSpeechName)) { SayDTS(speech); } mInitiatingConversation = false; yield break; } else { #if UNITY_EDITOR Debug.Log("Couldn't get the conversation, canceling"); #endif //aw shit we never got the conversation mInitiatingConversation = false; yield break; } Character c = worlditem.Get <Character> (); AnimatorUpdateMode updateMode = c.Body.Animator.animator.updateMode; if (c.Ghost) { c.Body.Animator.animator.updateMode = AnimatorUpdateMode.UnscaledTime; } yield return(null); while (conversation.IsActive) { //wait for the player to end the conversation yield return(null); } if (c.Ghost) { c.Body.Animator.animator.updateMode = updateMode; } mInitiatingConversation = false; yield break; }