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> /// 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 void PlaySalsa() { if (salsa2d != null) { salsa2d.SetAudioClip(clip); salsa2d.Play(); } else { salsa3d.SetAudioClip(clip); salsa3d.Play(); } }
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(); } }
/// <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; } } }