Example #1
0
    public Salsa3D salsa; // Public reference to Salsa3D

    void Start()
    {
        string[] arguments = Environment.GetCommandLineArgs();
        Debug.Log(arguments);
        var www = new WWW("file://" + Application.dataPath.Substring(0, Application.dataPath.LastIndexOf("/")) + "/result.ogg");

        Debug.Log("file://" + Application.dataPath.Substring(0, Application.dataPath.LastIndexOf("/")) + "/result.wav");
        var       www2        = new WWW("C:/Users/Warren/Documents/Salsa/Assets/Crazy Minnow Studio/SALSA with RandomEyes/Examples/Audio/DemoScenes/MilitaryMan/mil.2thinkFunnyHuh.ogg");
        AudioClip myAudioClip = www.audioClip;

        // myAudioClip.Play();

        // Get reference to the Salsa3D component
        salsa = (Salsa3D)FindObjectOfType(typeof(Salsa3D));
        Debug.Log(myAudioClip);
        salsa.SetAudioClip(myAudioClip); // Set the SALSA audio clip

        salsa.Play();                    // Play the audio clip
        //salsa.Pause(); // Pause the audio clip
        //salsa.Stop(); // Stop the audio clip

        salsa.saySmallTrigger  = 0.001f;   // Adjust the small trigger value
        salsa.sayMediumTrigger = 0.002f;   // Adjust the medium trigger value
        salsa.sayLargeTrigger  = 0.004f;   // Adjust the large trigger value

        salsa.broadcast = true;            // Set broadcasting to true
        salsa.broadcastReceiversCount = 1; // Setup one receiver slot
        //salsa.broadcastReceivers[0] = SOMEGAMEOBJECT; // Bind some game obejct to the receiver
        salsa.propagateToChildren = true;  // Propagate broadcasts to SOMEGAMEOBJECT's children

        salsa.audioUpdateDelay = 0.08f;    // The duration between audio sample updates

        salsa.blendSpeed = 10;             // Shape key transition duration
        salsa.SetRangeOfMotion(85);        // The percentage of total range of motion allowed
    }
Example #2
0
 /// <summary>
 /// Get the Salsa3D component
 /// </summary>
 public void GetSalsa3D()
 {
     if (!salsa3D)
     {
         salsa3D = GetComponent <Salsa3D>();
     }
 }
Example #3
0
    void makeSalsa(string name)
    {
        www         = new WWW("file://" + clipDir + name);
        myAudioClip = www.audioClip;
        Debug.Log(myAudioClip.isReadyToPlay);
        while (!www.isDone)
        {
            ;
        }

        Debug.Log(myAudioClip.isReadyToPlay);
        // Salsa3D
        gameObject.AddComponent <Salsa3D>();    // Add a Salsa3D component
        salsa3D     = GetComponent <Salsa3D>(); // Get reference to the Salsa3D component
        mcs.salsa3D = salsa3D;


        salsa3D.saySmallIndex  = 0;         // Set saySmall BlendShape index
        salsa3D.sayMediumIndex = 1;         // Set sayMedium BlendShape index
        salsa3D.sayLargeIndex  = 2;         // Set sayLarge BlendShape index
        salsa3D.SetAudioClip(myAudioClip);  // Set AudioClip
                                            // Or set the AudioClip from a clip in any Resources folder
                                            //salsa3D.SetAudioClip((Resources.Load("EthanEcho0", typeof(AudioClip)) as AudioClip));
        salsa3D.saySmallTrigger  = 0.0005f; // Set the saySmall amplitude trigger
        salsa3D.sayMediumTrigger = 0.0001f; // Set the sayMedium amplitude trigger
        salsa3D.sayLargeTrigger  = 0.0012f; // Set the sayLarge amplitude trigger
        salsa3D.audioUpdateDelay = 0.05f;   // Set the amplitutde sample update delay
        salsa3D.blendSpeed       = 5f;      // Set the blend speed
        salsa3D.rangeOfMotion    = 100f;    // Set the range of motion
        making    = false;
        destroyed = false;
    }
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        // Stockage de la durée du clip
        audioClipLength = audioclip.length + pauseDelay;



        dialogueIndex       = 0;
        dialogueDisplayTime = 0;

        npcDialogueManager = animator.gameObject.GetComponent <DialogueManager>();
        npcDialogueManager.subtitlesParent.SetActive(true);

        for (int i = 0; i < npcDialogueManager.NPC_DialogueText.Length; i++)
        {
            npcDialogueManager.NPC_DialogueText[i].transform.parent.gameObject.SetActive(false);
        }

        npcDialogueText = npcDialogueManager.NPC_DialogueText[npc_Index];
        npcDialogueText.gameObject.transform.parent.gameObject.SetActive(true);


        salsaCompo  = npcDialogueManager.salsaComponent[npc_Index];
        audiosource = salsaCompo.GetComponent <AudioSource>();

        salsaCompo.audioClip = audioclip;
        audiosource.clip     = audioclip;

        salsaCompo.Play();
        audiosource.Play();
    }
    public void Start()
    {
        GameObject actor = GameObject.Find("female_missionary");

        audioSource = actor.GetComponent <AudioSource>();
        salsa       = actor.GetComponent <Salsa3D>();
    }
Example #6
0
 //
 void Start()
 {
     _salsaComponent       = GetComponent <Salsa3D>();
     _defaultSmallTrigger  = _salsaComponent.saySmallTrigger;
     _defaultMediumTrigger = _salsaComponent.sayMediumTrigger;
     _defaultLargeTrigger  = _salsaComponent.sayLargeTrigger;
 }
Example #7
0
 void makeSalsa(string name)
 {
     Debug.Log("make");
     www         = new WWW("file://" + clipDir + name);
     myAudioClip = www.audioClip;
     //Debug.Log(myAudioClip.isReadyToPlay);
     while (!www.isDone)
     {
         ;
     }
     debugAC.GetComponent <AudioSource>().clip = myAudioClip;
     Debug.Log(myAudioClip.isReadyToPlay);
     // Salsa3D
     gameObject.AddComponent <Salsa3D>();                                                                         // Add a Salsa3D component
     salsa3D = GetComponent <Salsa3D>();                                                                          // Get reference to the Salsa3D component
     salsa3D.skinnedMeshRenderer = GameObject.Find("Ethan/char_ethan_body").GetComponent <SkinnedMeshRenderer>(); // Link the SkinnedMeshRenderer
     salsa3D.saySmallIndex       = 0;                                                                             // Set saySmall BlendShape index
     salsa3D.sayMediumIndex      = 1;                                                                             // Set sayMedium BlendShape index
     salsa3D.sayLargeIndex       = 2;                                                                             // Set sayLarge BlendShape index
     salsa3D.SetAudioClip(myAudioClip);                                                                           // Set AudioClip
                                                                                                                  // Or set the AudioClip from a clip in any Resources folder
                                                                                                                  //salsa3D.SetAudioClip((Resources.Load("EthanEcho0", typeof(AudioClip)) as AudioClip));
     salsa3D.saySmallTrigger  = 0.001f;                                                                           // Set the saySmall amplitude trigger
     salsa3D.sayMediumTrigger = 0.002f;                                                                           // Set the sayMedium amplitude trigger
     salsa3D.sayLargeTrigger  = 0.004f;                                                                           // Set the sayLarge amplitude trigger
     salsa3D.audioUpdateDelay = 0.05f;                                                                            // Set the amplitutde sample update delay
     salsa3D.blendSpeed       = 10f;                                                                              // Set the blend speed
     salsa3D.rangeOfMotion    = 100f;                                                                             // Set the range of motion
     making    = false;
     destroyed = false;
     waiting   = true;
 }
        void Update()
        {
            // Add the components when checked and not already loaded
            if (loadSalsaAndRandomEyes && !salsa3D && !re3D)
            {
                // Salsa3D
                gameObject.AddComponent <Salsa3D>();                                // Add a Salsa3D component
                salsa3D = GetComponent <Salsa3D>();                                 // Get reference to the Salsa3D component
                salsa3D.skinnedMeshRenderer = GetComponent <SkinnedMeshRenderer>(); // Link the SkinnedMeshRenderer
                salsa3D.saySmallIndex       = 0;                                    // Set saySmall BlendShape index
                salsa3D.sayMediumIndex      = 1;                                    // Set sayMedium BlendShape index
                salsa3D.sayLargeIndex       = 2;                                    // Set sayLarge BlendShape index
                salsa3D.SetAudioClip(audioClip);                                    // Set AudioClip
                // Or set the AudioClip from a clip in any Resources folder
                //salsa3D.SetAudioClip((Resources.Load("EthanEcho0", typeof(AudioClip)) as AudioClip));
                salsa3D.saySmallTrigger  = 0.002f;                 // Set the saySmall amplitude trigger
                salsa3D.sayMediumTrigger = 0.004f;                 // Set the sayMedium amplitude trigger
                salsa3D.sayLargeTrigger  = 0.006f;                 // Set the sayLarge amplitude trigger
                salsa3D.audioUpdateDelay = 0.08f;                  // Set the amplitutde sample update delay
                salsa3D.blendSpeed       = 10f;                    // Set the blend speed
                salsa3D.rangeOfMotion    = 100f;                   // Set the range of motion

                salsa3D.broadcast             = true;              // Enable talk event broadcasts
                salsa3D.broadcastReceivers    = new GameObject[1]; // Creat a new array of broadcast receivers
                salsa3D.broadcastReceivers[0] = broadcastReciever; // Link to a GameObject setup to listen for SALSA talk events
                salsa3D.expandBroadcast       = true;              // Expand the broadcast recievers array in the inspector

                salsa3D.Play();                                    // Begin lip sync


                // RandomEyes3D
                gameObject.AddComponent <RandomEyes3D>();                        // Add a RandomEyes3D component
                re3D = GetComponent <RandomEyes3D>();                            // Get reference to the RandomEyes3D component
                re3D.skinnedMeshRenderer = GetComponent <SkinnedMeshRenderer>(); // Link the SkinnedMeshRenderer
                re3D.lookUpIndex         = 3;                                    // Set the lookUp BlendShape index
                re3D.lookDownIndex       = 4;                                    // Set the lookDown BlendShape index
                re3D.lookLeftIndex       = 5;                                    // Set the lookLeft BlendShape index
                re3D.lookRightIndex      = 6;                                    // Set the lookRight BlendShape index
                re3D.blinkIndex          = 7;                                    // Set the blink BlendShape index
                re3D.rangeOfMotion       = 100f;                                 // Set the eyes range of motion
                re3D.blendSpeed          = 10f;                                  // Set the eyes blend speed
                re3D.blinkDuration       = 0.05f;                                // Set the blink duration
                re3D.blinkSpeed          = 20f;                                  // Set the blink speed
                re3D.SetOpenMax(0f);                                             // Set the max eye open position, 0=max
                re3D.SetCloseMax(100f);                                          // Set the max eye close position, 100=max
                re3D.SetRandomEyes(true);                                        // Enable random eye movement
                re3D.SetBlink(true);                                             // Enable random blink

                re3D.AutoLinkCustomShapes(true, salsa3D);                        // Automatically link all available BlendShapes while excluding eye and mouth shapes
                re3D.expandCustomShapes = true;                                  // Expand the custom shapes array in the inspector

                re3D.broadcastCS             = true;                             // Enable cust shape event broadcasts
                re3D.broadcastCSReceivers    = new GameObject[1];                // Creat a new array of broadcast receivers
                re3D.broadcastCSReceivers[0] = GameObject.Find("Broadcasts");    // Link to a GameObject setup to listen for RandomEyes custom shape events
                re3D.expandBroadcastCS       = true;                             // Expand the broadcast recievers array in the inspector
            }
        }
Example #9
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;
                }
            }
        }
Example #10
0
        private int yHeight = 35;     // Button and label height

        /// <summary>
        /// On start, try to get a local reference to Salsa3D
        /// </summary>
        void Start()
        {
            if (!salsa3D)                                             // salsa3D is null
            {
                salsa3D = (Salsa3D)FindObjectOfType(typeof(Salsa3D)); // Try to get a local reference to Salsa3D
            }

            if (audioClips.Length > 0)
            {
                salsa3D.SetAudioClip(audioClips[clipIndex]);
            }
        }
Example #11
0
		/// <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;
			}
		}
Example #12
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();
            }
        }
Example #13
0
    void configSalsa()
    {
        // Salsa3D
        //gameObject.AddComponent<Salsa3D>(); // Add a Salsa3D component
        salsa3D = GetComponent <Salsa3D>();        // Get reference to the Salsa3D component
        //mcs.salsa3D = salsa3D;

        salsa3D.saySmallIndex    = 0;       // Set saySmall BlendShape index
        salsa3D.sayMediumIndex   = 1;       // Set sayMedium BlendShape index
        salsa3D.sayLargeIndex    = 2;       // Set sayLarge BlendShape index
        salsa3D.saySmallTrigger  = 0.0005f; // Set the saySmall amplitude trigger
        salsa3D.sayMediumTrigger = 0.0001f; // Set the sayMedium amplitude trigger
        salsa3D.sayLargeTrigger  = 0.0012f; // Set the sayLarge amplitude trigger
        salsa3D.audioUpdateDelay = 0.05f;   // Set the amplitutde sample update delay
        salsa3D.blendSpeed       = 5f;      // Set the blend speed
        salsa3D.rangeOfMotion    = 100f;    // Set the range of motion
        //salsa3D.SetAudioClip(myAudioClip); // Set AudioClip
    }
Example #14
0
        /// <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;
        }
Example #15
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;
        }
Example #16
0
        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;
            }
        }
Example #17
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;
                }
            }
        }
 private void Awake()
 {
     salsa = GetComponent <Salsa3D> ();
 }
Example #19
0
        void Update()
        {
            // Add the components when checked and not already loaded
            if (loadSalsaAndRandomEyes && !salsa3D && !re3D)
            {
                // Salsa3D
                gameObject.AddComponent<Salsa3D>(); // Add a Salsa3D component
                salsa3D = GetComponent<Salsa3D>(); // Get reference to the Salsa3D component
                salsa3D.skinnedMeshRenderer = GetComponent<SkinnedMeshRenderer>(); // Link the SkinnedMeshRenderer
                salsa3D.saySmallIndex = 0; // Set saySmall BlendShape index
                salsa3D.sayMediumIndex = 1; // Set sayMedium BlendShape index
                salsa3D.sayLargeIndex = 2; // Set sayLarge BlendShape index
                salsa3D.SetAudioClip(audioClip); // Set AudioClip
                // Or set the AudioClip from a clip in any Resources folder
                //salsa3D.SetAudioClip((Resources.Load("EthanEcho0", typeof(AudioClip)) as AudioClip));
                salsa3D.saySmallTrigger = 0.002f; // Set the saySmall amplitude trigger
                salsa3D.sayMediumTrigger = 0.004f; // Set the sayMedium amplitude trigger
                salsa3D.sayLargeTrigger = 0.006f; // Set the sayLarge amplitude trigger
                salsa3D.audioUpdateDelay = 0.08f; // Set the amplitutde sample update delay
                salsa3D.blendSpeed = 10f; // Set the blend speed
                salsa3D.rangeOfMotion = 100f; // Set the range of motion

                salsa3D.broadcast = true; // Enable talk event broadcasts
                salsa3D.broadcastReceivers = new GameObject[1]; // Creat a new array of broadcast receivers
                salsa3D.broadcastReceivers[0] = broadcastReciever; // Link to a GameObject setup to listen for SALSA talk events
                salsa3D.expandBroadcast = true; // Expand the broadcast recievers array in the inspector

                salsa3D.Play(); // Begin lip sync

                // RandomEyes3D
                gameObject.AddComponent<RandomEyes3D>(); // Add a RandomEyes3D component
                re3D = GetComponent<RandomEyes3D>(); // Get reference to the RandomEyes3D component
                re3D.skinnedMeshRenderer = GetComponent<SkinnedMeshRenderer>(); // Link the SkinnedMeshRenderer
                re3D.lookUpIndex = 3; // Set the lookUp BlendShape index
                re3D.lookDownIndex = 4; // Set the lookDown BlendShape index
                re3D.lookLeftIndex = 5; // Set the lookLeft BlendShape index
                re3D.lookRightIndex = 6; // Set the lookRight BlendShape index
                re3D.blinkIndex = 7; // Set the blink BlendShape index
                re3D.rangeOfMotion = 100f; // Set the eyes range of motion
                re3D.blendSpeed = 10f; // Set the eyes blend speed
                re3D.blinkDuration = 0.05f; // Set the blink duration
                re3D.blinkSpeed = 20f; // Set the blink speed
                re3D.SetOpenMax(0f); // Set the max eye open position, 0=max
                re3D.SetCloseMax(100f); // Set the max eye close position, 100=max
                re3D.SetRandomEyes(true); // Enable random eye movement
                re3D.SetBlink(true); // Enable random blink

                re3D.broadcast = true; // Enable eye movement event broadcasts
                re3D.broadcastReceivers = new GameObject[1]; // Creat a new array of broadcast receivers
                re3D.broadcastReceivers[0] = GameObject.Find("Broadcasts"); // Link to a GameObject setup to listen for RandomEyes look events
                re3D.expandBroadcast = true; // Expand the broadcast recievers array in the inspector

                re3D.AutoLinkCustomShapes(true, salsa3D); // Automatically link all available BlendShapes while excluding eye and mouth shapes
                re3D.expandCustomShapes = true; // Expand the custom shapes array in the inspector

                re3D.broadcastCS = true; // Enable cust shape event broadcasts
                re3D.broadcastCSReceivers = new GameObject[1]; // Creat a new array of broadcast receivers
                re3D.broadcastCSReceivers[0] = GameObject.Find("Broadcasts"); // Link to a GameObject setup to listen for RandomEyes custom shape events
                re3D.expandBroadcastCS = true; // Expand the broadcast recievers array in the inspector
            }
        }
Example #20
0
        /// <summary>
        /// On start, try to get a local reference to Salsa3D
        /// </summary>
        void Start()
        {
            if (!salsa3D) // salsa3D is null
            {
                salsa3D = (Salsa3D)FindObjectOfType(typeof(Salsa3D)); // Try to get a local reference to Salsa3D
            }

            if (audioClips.Length > 0)
            {
                salsa3D.SetAudioClip(audioClips[clipIndex]);
            }
        }
Example #21
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();
            }
        }