Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
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;
                }
            }
        }
Exemplo n.º 3
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();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the game object of the character with Salsa3D or Salsa2D attached, 
        /// and returns an instance of the CM_SalsaTypeAndObject properties class 
        /// with the Salsa GameObject and SalsaType
        /// </summary>
        /// <returns>The salsa.</returns>
        /// <param name="character">Character.</param>
        private CM_SalsaTypeAndObject GetSalsaType(GameObject character)
        {
            CM_SalsaTypeAndObject salsaTypObj = new CM_SalsaTypeAndObject();

            if (character.GetComponent<Salsa2D>() != null)
            {
                salsaTypObj.salsaGameObject = character.GetComponent<Salsa2D>().gameObject;
                salsaTypObj.salsaType = CM_SalsaTypeAndObject.SalsaTypeOf.Salsa2D;
            }
            else if (character.GetComponent<Salsa3D>() != null)
            {
                salsaTypObj.salsaGameObject = character.GetComponent<Salsa3D>().gameObject;
                salsaTypObj.salsaType = CM_SalsaTypeAndObject.SalsaTypeOf.Salsa3D;
            }

            return salsaTypObj;
        }