Esempio n. 1
0
        /// <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;
                }
            }
        }
Esempio n. 2
0
 private void PlaySalsa()
 {
     if (salsa2d != null)
     {
         salsa2d.SetAudioClip(clip);
         salsa2d.Play();
     }
     else
     {
         salsa3d.SetAudioClip(clip);
         salsa3d.Play();
     }
 }
Esempio n. 3
0
        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>
        /// Draw the GUI buttons
        /// </summary>
        void OnGUI()
        {
            yPos = 0;             // Reset the button Y position

            #region Salsa2D Play, Pause, and Stop controls
            yPos += yGap;
            if (GUI.Button(new Rect(20, yPos, xWidth, yHeight), "Play"))
            {
                salsa2D.Play();                 // Salsa3D Play method
            }

            yPos += (yGap + yHeight);
            if (GUI.Button(new Rect(20, yPos, xWidth, yHeight), "Pause"))
            {
                salsa2D.Pause();                 // Salsa3D Pause method
            }

            yPos += (yGap + yHeight);
            if (GUI.Button(new Rect(20, yPos, xWidth, yHeight), "Stop"))
            {
                salsa2D.Stop();                 // Salsa3D Stop method
            }
            #endregion

            #region Toggle which audio clip is set on Salsa2D
            yPos += (yGap + yHeight);
            if (GUI.Button(new Rect(20, yPos, xWidth, yHeight), "Set audio clip"))
            {
                if (clipIndex < audioClips.Length - 1)
                {
                    clipIndex++;
                    salsa2D.SetAudioClip(audioClips[clipIndex]);
                }
                else
                {
                    clipIndex = 0;
                    salsa2D.SetAudioClip(audioClips[clipIndex]);
                }
            }
            #endregion
            #region Display the currently selected audio clip
            GUI.Label(new Rect(30 + xWidth, yPos, xWidth, yHeight), "Clip " + audioClips[clipIndex].name);
            #endregion
        }
Esempio n. 5
0
        /// <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();
            }
        }
Esempio n. 6
0
        /// <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;
                }
            }
        }