Ejemplo n.º 1
0
        public void SetEyeGesture(CharacterBrain.EyeGestures eyeGesture)
        {
            if (anPupils != null && anPupils.isActiveAndEnabled)
            {
                anPupils.SetInteger("state", (int)eyeGesture);
            }

            if (elroyBrain != null && anPupils != null)
            {
                CharacterHead partner = elroyBrain.conversationPartner;
                if (partner != null)
                {
                    float dy = partner.transform.position.y - anPupils.transform.position.y;

                    if (partner is PlayerHead)
                    {
                        if ((partner as PlayerHead).anPupils != null)
                        {
                            dy = (partner as PlayerHead).anPupils.transform.position.y - anPupils.transform.position.y;
                        }
                    }

                    dy /= 1.5f;

                    if (dy > 1)
                    {
                        dy = 1;
                    }
                    if (dy < -1)
                    {
                        dy = -1;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected void ShowText(string line, CharacterHead head, int textCharactersInLine = 32)
        {
            string[] lines = StringSplit(line, textCharactersInLine).ToArray();

            if (lines.Length < 1)
            {
                //Global.characterDialogText.SetText("");
                return;
            }

            // string line1 = lines[0];
            string line2 = lines.Length > 1 ? lines[1] : "";

            if (lines.Length > 2)
            {
                for (int i = 2; i < lines.Length; i++)
                {
                    line2 += lines[i];
                }
            }
        }
Ejemplo n.º 3
0
        public IEnumerator PlayVoiceFake(VoiceClip clip, ShowPhoneme showPhonemeFunction, ChangeMood changeMoodFunction, ChangeMode changeModeFunction, CharacterHead head, int textCharactersInLine = 32, float volume = 1)
        {
            //		Debug.Log ("PlayVoice " + textCharactersInLine);

            string text = clip.text;

            float pause = 1f / 24f;

            //		Debug.Log ("Talk: " + name);

            string[] textLines = StringSplit(text, textCharactersInLine * 2).ToArray();

            CharacterHead.Moods currentMood;
            string currentMode;

            currentMood = clip.mood;
            if (changeMoodFunction != null)
            {
                changeMoodFunction(currentMood);
                Debug.Log("PlayVoiceFake Mood Change: " + currentMood);
            }
            float startTime = Time.time;

            if (textLines.Length > 0)
            {
                float textLineCount = textLines.Length;

                int currentTextLine = 0;

                ShowText(textLines[0], head, textCharactersInLine);

                currentMood = clip.mood;
                currentMode = clip.mode;

                clip.audioSource.Play();

                currentVoicePlaying = clip.audioSource;

                //clip.audioSource.volume = !(isMutedSound || Global.muteSpeech) ? volume : 0;

                while ((Time.time - startTime) < clip.duration)
                {
                    float time = (Time.time - startTime);// clip.audioSource.time;

                    float textLine = textLineCount * (time / clip.duration);

                    int c = (int)Mathf.Floor(textLine);

                    if (c != currentTextLine && c < textLines.Length)
                    {
                        currentTextLine = c;
                        ShowText(textLines[currentTextLine], head, textCharactersInLine);
                    }

                    bool change = false;

                    clip.phonemes.GetMode(time + pause, ref currentMode, ref change);

                    if (change)
                    {
                        changeModeFunction(currentMode);
                    }

                    change = false;

                    clip.phonemes.GetMood(time + pause, ref currentMood, ref change);

                    if (change)
                    {
                        changeMoodFunction(currentMood);
                    }

                    string ph = clip.phonemes.GetPhoneme(time + pause).Trim();
                    showPhonemeFunction(ph);

                    /*
                     *                  if(ph == "O" || ph == "U") // HACK: FOR O and U, hold the phoneme longer
                     *                  {
                     *                          yield return new WaitForSeconds(pause*4);
                     *                  }
                     *                  else
                     */
                    if (clip.interruptFlag)
                    {
                        Debug.Log("interrupt flag " + clip.interruptFlag);
                        clip.audioSource.Stop();

                        break;
                    }

                    yield return(new WaitForSeconds(pause));
                }

                showPhonemeFunction("MBP");
                changeMoodFunction(CharacterHead.Moods.Neutral);

                currentVoicePlaying = null;
                //Global.characterDialogText.SetText("");
            }

            //Global.player.ChangeMood(CharacterHead.Moods.Neutral);

            yield return(null);
        }