Example #1
0
    IEnumerator EmotionScript()
    {
        while (true)
        {
            if (timer >= nextEmotion.time)
            {
                if (previousEmotion.emotionDef.emotionName == EmotionName.neutral && nextEmotion.emotionDef.emotionName != EmotionName.neutral)
                {
                    parentScript.AddAlertBox($"{participantName} has become {nextEmotion.emotionDef.emotionName}.\n{suggestions[nextEmotion.emotionDef.emotionName]}");
                }
                previousEmotion = nextEmotion;
                emotionGraph.addToStream(previousEmotion);
                //emotionalMarker.color = nextEmotion.colour;
                //emotionalState.transform.localScale = new Vector3(xScale, yScale * nextEmotion.magnitude);

                emotionTrackIndex++;
                if (emotionTrackIndex < emotionTrack.Count)
                {
                    nextEmotion = emotionTrack[emotionTrackIndex];
                }
                else
                {
                    nextEmotion = new Emotion(nextEmotion.emotionDef.emotionName, nextEmotion.magnitude, timer);
                }
                //emotionTrackIndex++;
                //if(emotionTrackIndex < emotionTrack.Count)
                //    nextEmotion = emotionTrack[++emotionTrackIndex];
            }
            else if (previousEmotion.Equals(nextEmotion))
            {
                float lerpMagnitude = Emotion.MagLerp(timer, previousEmotion, nextEmotion);
                emotionGraph.addToStream(new Emotion(nextEmotion.emotionDef.emotionName, lerpMagnitude, timer));
                //emotionalState.transform.localScale = new Vector3(xScale, yScale * lerpMagnitude);
            }

            timer += Time.deltaTime;
            //Debug.Log(timer);
            yield return(null);
        }
    }