// Activates speech audio, speech animation, and action triggers for the prompt public void RunActionsAndSpeechForLine(Prompt line) { if (line.hasAudio) { AnimationAudio voiceLine = line.animatedSpeechLine; speechController.PlayClipAndStartAnimatingFace(voiceLine); } if (line.lookAtFriend) { if (line.lookAtCurrentFriend && currentFriend != null) { LookAtPerson(line.lookDuration, currentFriend.face, line.matchLookDurationToSpeechTime); } else { bool foundFriendName = false; foreach (ConversationStarter speechLine in speechController.friendLines) { if (speechLine.friendName == line.nameOfFriendToLookAt && !foundFriendName) { LookAtPerson(line.lookDuration, GameObject.Find(line.nameOfFriendToLookAt).transform, line.matchLookDurationToSpeechTime); } } } } }
public void CommsNPCInitiate() { bool friendLineFound = false; foreach (ConversationStarter starterLine in speechController.friendLines) { if ((starterLine.friendName == currentFriend.transform.name) && !friendLineFound) { currentFriend.currentFriend = this; AnimationAudio line = starterLine.friendLine.animatedSpeechLine; currentSpeechLine = starterLine.friendLine; //speechController.PlayClipAndStartAnimatingFace(line.audioLine, line.startDelayInSec, line.animationCues, // line.mouthPoseOverrideTimeInterval, line.emotionCues, line.feelingOverrideTimeInterval, // line.triggerStringForEndingEmotion); //if (currentSpeechLine.triggersActions) { // if (currentSpeechLine.acts.Length > 0) { // for (int i = 0; i < currentSpeechLine.acts.Length; i++) { // actCoord.TriggerAction(currentSpeechLine.acts[i]); // } // } //} RunActionsAndSpeechForLine(currentSpeechLine); currentLineDuration = line.clipLength; currentSpeechLineRefTime = Time.time; speakingAndWaitingToCueOtherNPC = true; currentFriend.contactedByFriend = true; friendLineFound = true; conversationStarted = false; NPCState = StateOfBeing.Conversing; } } }
// The extra parameter allows for duplication of speech through the Stardater chat public void PlayClipAndStartAnimatingFace(AnimationAudio speechLine, bool broadcastOnStardaterChat) { AudioClip clip = speechLine.audioLine; float delay = speechLine.startDelayInSec; string animationKey = speechLine.animationCues; float mouthShapeIntervalOverride = speechLine.mouthPoseOverrideTimeInterval; string emotionKey = speechLine.emotionCues; float emotionIntervalOverride = speechLine.feelingOverrideTimeInterval; string endingEmote = speechLine.triggerStringForEndingEmotion; faceIsAnimating = false; mouthShapeCode.Clear(); emotionCode.Clear(); char[] tempAnimationCode = animationKey.ToCharArray(); foreach (char ch in tempAnimationCode) { mouthShapeCode.Add(ch); } char[] tempEmotionCode = emotionKey.ToCharArray(); foreach (char ch in tempEmotionCode) { emotionCode.Add(ch); } faceAnimationStartDelay = delay; if (endingEmote != "") { endingEmotion = endingEmote; } if (mouthShapeIntervalOverride > 0) { mouthShapeTimeIntervalActual = mouthShapeIntervalOverride; } else { mouthShapeTimeIntervalActual = mouthShapeDefaultTimeInterval; } if (emotionIntervalOverride > 0) { emotionTimeIntervalActual = emotionIntervalOverride; } else { emotionTimeIntervalActual = emotionDefaultTimeInterval; } faceAnimationStartRefTime = Time.time; currentMouthShapeCharIndex = 0; currentEmotionCharIndex = 0; faceIsAnimating = true; currentClip = clip; speechAudio.Stop(); readyToPlayAudio = true; currentLineIsBroadcastedOnStardaterChat = broadcastOnStardaterChat; }
public void SpeechLineCued(Prompt response) { bool friendLineFound = false; foreach (Prompt convoLine in speechController.textLines) { if (response == convoLine) { AnimationAudio line = convoLine.animatedSpeechLine; if (!friendLineFound) { //currentSpeechLine = convoLine; //speechController.PlayClipAndStartAnimatingFace(line.audioLine, line.startDelayInSec, line.animationCues, // line.mouthPoseOverrideTimeInterval, line.emotionCues, line.feelingOverrideTimeInterval, // line.triggerStringForEndingEmotion); //if (currentSpeechLine.triggersActions) { // if (currentSpeechLine.acts.Length > 0) { // for (int i = 0; i < currentSpeechLine.acts.Length; i++) { // actCoord.TriggerAction(currentSpeechLine.acts[i]); // } // } //} currentSpeechLine = convoLine; RunActionsAndSpeechForLine(currentSpeechLine); currentLineDuration = line.clipLength; currentSpeechLineRefTime = Time.time; NPCState = StateOfBeing.Conversing; speakingAndWaitingToCueOtherNPC = true; friendLineFound = true; } } } }