/// <summary> /// NPC dialog text and player dialog response text GUI /// </summary> void OnGUI() { int yPos = 0; int yStart = 20; int yIncrement = 40; // No end dialog flags are set if (!endDialogNpc || !endDialogPlayer) { if (showNPCDialog && !endDialogPlayer) { GUI.Label(new Rect(20, yStart, 300, 35), npcDialog[npcDialogIndexTracker].npcText); } } if (showPlayerResponses) { yPos = yStart; // Loop through all player responses to the current NPC dialog for (int i = 0; i < npcDialog[npcDialogIndexTracker].playerResponse.Length; i++) { // Show response dialog text buttons if (GUI.Button(new Rect(Screen.width - 320, yPos, 300, 35), npcDialog[npcDialogIndexTracker].playerResponse[i].playerText)) { // If this button was selected, get the Salsa type and GameObject this.salsaTypObj = GetSalsaType(npcDialog[npcDialogIndexTracker].playerResponse[i].player); // If Salsa3D if (this.salsaTypObj.salsaType == CM_SalsaTypeAndObject.SalsaTypeOf.Salsa3D) { salsa3D = this.salsaTypObj.salsaGameObject.GetComponent <Salsa3D>(); salsa3D.SetAudioClip(npcDialog[npcDialogIndexTracker].playerResponse[i].playerAudio); salsa3D.Play(); } // If Salsa2D if (this.salsaTypObj.salsaType == CM_SalsaTypeAndObject.SalsaTypeOf.Salsa2D) { salsa2D = this.salsaTypObj.salsaGameObject.GetComponent <Salsa2D>(); salsa2D.SetAudioClip(npcDialog[npcDialogIndexTracker].playerResponse[i].playerAudio); salsa2D.Play(); } // Check/Set the player end dialog flag endDialogPlayer = npcDialog[npcDialogIndexTracker].playerResponse[i].endDialog; // Set the next NPC dialog index npcDialogIndexTracker = npcDialog[npcDialogIndexTracker].playerResponse[i].npcDialogIndex; showNPCDialog = false; // Hide the NPC dialog showPlayerResponses = false; // Hide the player responses } yPos += yIncrement; } } }
private int yHeight = 30; // Button and label height /// <summary> /// On start, try to get a local reference to Salsa2D /// </summary> void Start() { if (!salsa2D) // salsa2D is null { salsa2D = (Salsa2D)FindObjectOfType(typeof(Salsa2D)); // Try to get a local reference to Salsa2D } if (audioClips.Length > 0) { salsa2D.SetAudioClip(audioClips[clipIndex]); } }
/// <summary> /// Set the SALSA type 2D or 3D, and find the corresponding component /// </summary> /// <param name="salsaType"></param> public void SetSalsaType(SalsaType salsaType) { switch (salsaType) { case SalsaType.Salsa2D: salsa3D = null; if (!salsa2D) salsa2D = GetComponent<Salsa2D>(); break; case SalsaType.Salsa3D: salsa2D = null; if (!salsa3D) salsa3D = GetComponent<Salsa3D>(); break; } }
private CM_SalsaTypeAndObject salsaTypObj; // See comments for the CM_SalsaTypeAndObject class listed above /// <summary> /// Determines if the NPC is using Salsa2D or Salsa3D, gets reference to /// the component, sets the first NPC audio clip, and plays the audio clip /// </summary> void Start() { this.salsaTypObj = GetSalsaType(npcDialog[npcDialogIndexTracker].npc); if (this.salsaTypObj.salsaType == CM_SalsaTypeAndObject.SalsaTypeOf.Salsa3D) { salsa3D = this.salsaTypObj.salsaGameObject.GetComponent <Salsa3D>(); salsa3D.SetAudioClip(npcDialog[npcDialogIndexTracker].npcAudio); salsa3D.Play(); } if (this.salsaTypObj.salsaType == CM_SalsaTypeAndObject.SalsaTypeOf.Salsa2D) { salsa2D = this.salsaTypObj.salsaGameObject.GetComponent <Salsa2D>(); salsa2D.SetAudioClip(npcDialog[npcDialogIndexTracker].npcAudio); salsa2D.Play(); } }
private void Start() { // Populate our eye renderes using child objects (so we don't have to drag them in via the editors) var animators = GetComponentsInChildren <Animator>(); foreach (var animator in animators) { if (animator.gameObject.name == "EyeLeft") { EyeLeft = animator; } if (animator.gameObject.name == "EyeRight") { EyeRight = animator; } } Mouth = GetComponentInChildren <Salsa2D>(); }
private bool showPlayerResponses = false; // Tracks the visible status of the player dialog text #endregion Fields #region Methods /// <summary> /// Reset the dialog system at runtime /// </summary> public void ResetDialog() { npcDialogIndexTracker = 0; endDialogNpc = false; endDialogPlayer = false; showNPCDialog = true; showPlayerResponses = false; this.salsaTypObj = GetSalsaType(npcDialog[npcDialogIndexTracker].npc); if (this.salsaTypObj.salsaType == CM_SalsaTypeAndObject.SalsaTypeOf.Salsa3D) { salsa3D = this.salsaTypObj.salsaGameObject.GetComponent<Salsa3D>(); salsa3D.Stop(); } if (this.salsaTypObj.salsaType == CM_SalsaTypeAndObject.SalsaTypeOf.Salsa2D) { salsa2D = this.salsaTypObj.salsaGameObject.GetComponent<Salsa2D>(); salsa2D.Stop(); } if (npcDialog[npcDialogIndexTracker].playerResponse.Length > 0) { this.salsaTypObj = GetSalsaType(npcDialog[npcDialogIndexTracker].playerResponse[0].player); if (this.salsaTypObj.salsaType == CM_SalsaTypeAndObject.SalsaTypeOf.Salsa3D) { salsa3D = this.salsaTypObj.salsaGameObject.GetComponent<Salsa3D>(); salsa3D.Stop(); } if (this.salsaTypObj.salsaType == CM_SalsaTypeAndObject.SalsaTypeOf.Salsa2D) { salsa2D = this.salsaTypObj.salsaGameObject.GetComponent<Salsa2D>(); salsa2D.Stop(); } } Start(); showNPCDialog = true; }
/// <summary> /// Reset the dialog system at runtime /// </summary> public void ResetDialog() { npcDialogIndexTracker = 0; endDialogNpc = false; endDialogPlayer = false; showNPCDialog = true; showPlayerResponses = false; this.salsaTypObj = GetSalsaType(npcDialog[npcDialogIndexTracker].npc); if (this.salsaTypObj.salsaType == CM_SalsaTypeAndObject.SalsaTypeOf.Salsa3D) { salsa3D = this.salsaTypObj.salsaGameObject.GetComponent <Salsa3D>(); salsa3D.Stop(); } if (this.salsaTypObj.salsaType == CM_SalsaTypeAndObject.SalsaTypeOf.Salsa2D) { salsa2D = this.salsaTypObj.salsaGameObject.GetComponent <Salsa2D>(); salsa2D.Stop(); } if (npcDialog[npcDialogIndexTracker].playerResponse.Length > 0) { this.salsaTypObj = GetSalsaType(npcDialog[npcDialogIndexTracker].playerResponse[0].player); if (this.salsaTypObj.salsaType == CM_SalsaTypeAndObject.SalsaTypeOf.Salsa3D) { salsa3D = this.salsaTypObj.salsaGameObject.GetComponent <Salsa3D>(); salsa3D.Stop(); } if (this.salsaTypObj.salsaType == CM_SalsaTypeAndObject.SalsaTypeOf.Salsa2D) { salsa2D = this.salsaTypObj.salsaGameObject.GetComponent <Salsa2D>(); salsa2D.Stop(); } } Start(); showNPCDialog = true; }
public void Start() { clip = Resources.Load(GetParameter(0)) as AudioClip; var subject = GetSubject(1, Sequencer.Speaker); nowait = string.Equals(GetParameter(2), "nowait", System.StringComparison.OrdinalIgnoreCase); salsa2d = (subject != null) ? subject.GetComponent <Salsa2D>() : null; salsa3d = (subject != null) ? subject.GetComponent <Salsa3D>() : null; if (!HasSalsaComponent()) { if (DialogueDebug.LogWarnings) { Debug.LogWarning(string.Format("{0}: Sequencer: SALSA({1},{2},{3}) command: No Salsa2D/3D component found on {2}.", new System.Object[] { DialogueDebug.Prefix, GetParameter(0), (subject != null) ? subject.name : GetParameter(1), GetParameter(2) })); } Stop(); } else if (clip == null) { if (DialogueDebug.LogWarnings) { Debug.LogWarning(string.Format("{0}: Sequencer: SALSA({1},{2},{3}) command: Audio clip not found. Is it in a Resources folder?", new System.Object[] { DialogueDebug.Prefix, GetParameter(0), subject.name, GetParameter(2) }), subject); } Stop(); } else { if (DialogueDebug.LogInfo) { Debug.Log(string.Format("{0}: Sequencer: SALSA({1},{2},{3}) command: Playing audio clip.", new System.Object[] { DialogueDebug.Prefix, GetParameter(0), subject.name, GetParameter(2) }), subject); } //--- SALSA //--- Was: PlaySalsa(); //--- Was if (nowait) Stop(); startDelayRemaining = SalsaFixDelay; } }
public void StartLipSync(List<LipSyncShape> _lipSyncShapes) { #if SalsaIsPresent if (KickStarter.speechManager.lipSyncMode == LipSyncMode.Salsa2D) { salsa2D = GetComponent <Salsa2D>(); if (salsa2D == null) { Debug.LogWarning ("To perform Salsa 2D lipsyncing, Character GameObjects must have the 'Salsa2D' component attached."); } } else { salsa2D = null; } #endif lipSyncShapes = _lipSyncShapes; isLipSyncing = true; }
/// <summary> /// Determines if the NPC is using Salsa2D or Salsa3D, gets reference to /// the component, sets the first NPC audio clip, and plays the audio clip /// </summary> void Start() { this.salsaTypObj = GetSalsaType(npcDialog[npcDialogIndexTracker].npc); if (this.salsaTypObj.salsaType == CM_SalsaTypeAndObject.SalsaTypeOf.Salsa3D) { salsa3D = this.salsaTypObj.salsaGameObject.GetComponent<Salsa3D>(); salsa3D.SetAudioClip(npcDialog[npcDialogIndexTracker].npcAudio); salsa3D.Play(); } if (this.salsaTypObj.salsaType == CM_SalsaTypeAndObject.SalsaTypeOf.Salsa2D) { salsa2D = this.salsaTypObj.salsaGameObject.GetComponent<Salsa2D>(); salsa2D.SetAudioClip(npcDialog[npcDialogIndexTracker].npcAudio); salsa2D.Play(); } }
/// <summary> /// NPC dialog text and player dialog response text GUI /// </summary> void OnGUI() { int yPos = 0; int yStart = 20; int yIncrement = 40; // No end dialog flags are set if (!endDialogNpc || !endDialogPlayer) { if (showNPCDialog && !endDialogPlayer) { GUI.Label(new Rect(20, yStart, 300, 35), npcDialog[npcDialogIndexTracker].npcText); } } if (showPlayerResponses) { yPos = yStart; // Loop through all player responses to the current NPC dialog for (int i = 0; i < npcDialog[npcDialogIndexTracker].playerResponse.Length; i++) { // Show response dialog text buttons if (GUI.Button(new Rect(Screen.width - 320, yPos, 300, 35), npcDialog[npcDialogIndexTracker].playerResponse[i].playerText)) { // If this button was selected, get the Salsa type and GameObject this.salsaTypObj = GetSalsaType(npcDialog[npcDialogIndexTracker].playerResponse[i].player); // If Salsa3D if (this.salsaTypObj.salsaType == CM_SalsaTypeAndObject.SalsaTypeOf.Salsa3D) { salsa3D = this.salsaTypObj.salsaGameObject.GetComponent<Salsa3D>(); salsa3D.SetAudioClip(npcDialog[npcDialogIndexTracker].playerResponse[i].playerAudio); salsa3D.Play(); } // If Salsa2D if (this.salsaTypObj.salsaType == CM_SalsaTypeAndObject.SalsaTypeOf.Salsa2D) { salsa2D = this.salsaTypObj.salsaGameObject.GetComponent<Salsa2D>(); salsa2D.SetAudioClip(npcDialog[npcDialogIndexTracker].playerResponse[i].playerAudio); salsa2D.Play(); } // Check/Set the player end dialog flag endDialogPlayer = npcDialog[npcDialogIndexTracker].playerResponse[i].endDialog; // Set the next NPC dialog index npcDialogIndexTracker = npcDialog[npcDialogIndexTracker].playerResponse[i].npcDialogIndex; showNPCDialog = false; // Hide the NPC dialog showPlayerResponses = false; // Hide the player responses } yPos += yIncrement; } } }
/// <summary> /// On start, try to get a local reference to Salsa2D /// </summary> void Start() { if (!salsa2D) // salsa2D is null { salsa2D = (Salsa2D)FindObjectOfType(typeof(Salsa2D)); // Try to get a local reference to Salsa2D } if (audioClips.Length > 0) { salsa2D.SetAudioClip(audioClips[clipIndex]); } }