Ejemplo n.º 1
0
        /// <summary>
        /// Sets the emotion to a given expression using the Emotions enumeration as input.
        /// </summary>
        /// <param name="emotion">An Emotions enumeration value representing the desired emotion.</param>
        public void SetEmotion(Emotions emotion)
        {
            for (var row = 0; row < 8; row++)
            {
                leftEye.SetRowState(row, expressions[emotion][row]);
                rightEye.SetRowState(row, expressions[emotion][row + 8]);
            }
            currentExpression = emotion;

            // if the emotion is set to any other emotion than neutral, sleep or blink, switch back to neutral after the emotion fallback timespan has elapsed
            if (emotion != Emotions.Neutral && emotion != Emotions.Sleep && emotion != Emotions.Blink)
            {
                Task.Run(async delegate
                {
                    await Task.Delay(TimeSpan.FromMilliseconds(EmotionFallbackTimespan));
                    SetEmotion(Emotions.Neutral);
                });
            }
        }