Beispiel #1
0
    private KeyValuePair <int, Dictionary <BubbleSystem.Emotion, float> > GetEmotions(string[] info, int i)
    {
        Dictionary <BubbleSystem.Emotion, float> dict = new Dictionary <BubbleSystem.Emotion, float>();

        while (i < info.Length)
        {
            BubbleSystem.Emotion emotion = new BubbleSystem.Emotion();
            object parsedEmotion;
            float  intensity;

            if (info[i].Equals("showEffects") || info[i].Equals("hideEffects"))
            {
                break;
            }
            if (!EnumUtils.TryParse(typeof(BubbleSystem.Emotion.EmotionEnum), info[i], out parsedEmotion) || !Single.TryParse(info[i + 1], out intensity))
            {
                i += 2;
                continue;
            }
            emotion.Set((BubbleSystem.Emotion.EmotionEnum)parsedEmotion);

            dict.Add(emotion, Mathf.Clamp01(intensity));
            i += 2;
        }

        return(new KeyValuePair <int, Dictionary <BubbleSystem.Emotion, float> >(i, dict));
    }
Beispiel #2
0
    public void UpdateOptions(string[] text, List <HookControl.IntFunc> callbacks = null, Dictionary <string, string> showEffects = null, Dictionary <string, string> hideEffects = null)
    {
        BubbleSystemData data = bsData[BubbleSystem.Tutor.TutorEnum.User.ToString()];

        data.Clear();
        data.balloonData.text = text.ToList();
        BubbleSystem.Emotion emotion = new BubbleSystem.Emotion();
        emotion.Set(BubbleSystem.Emotion.EmotionEnum.Neutral);
        data.tutor.Set(BubbleSystem.Tutor.TutorEnum.User);
        data.emotions.Add(emotion, 1.0f);
        data.balloonData.options = true;
        if (callbacks != null)
        {
            data.balloonData.callbacks = callbacks;
        }
        if (showEffects != null)
        {
            data.balloonData.effects.showEffects = getEffectsDictionary(showEffects);
        }
        if (hideEffects != null)
        {
            data.balloonData.effects.hideEffects = getEffectsDictionary(hideEffects);
        }
        bubbleSystem.UpdateScene(data);
    }
Beispiel #3
0
    /**********************************************************************************************************
    *                                            BUBBLE SYSTEM
    **********************************************************************************************************/

    public void UpdateBackground(Tutor tutor, Reason.ReasonEnum reason)
    {
        BubbleSystemData data = new BubbleSystemData();

        data.Clear();
        BubbleSystem.Emotion emotion = new BubbleSystem.Emotion();
        emotion.Set(tutor.Emotion.Name.ToString());
        data.tutor.Set(tutor.Name);
        data.emotions.Add(emotion, tutor.Emotion.Intensity);
        data.backgroundData.reason.Set(reason);
        bubbleSystem.UpdateScene(data);
    }
Beispiel #4
0
    public void Speak(Tutor tutor, string[] text, Dictionary <string, string> showEffects = null, Dictionary <string, string> hideEffects = null)
    {
        BubbleSystemData data = bsData[tutor.Name];

        data.Clear();
        BubbleSystem.Emotion emotion = new BubbleSystem.Emotion();
        emotion.Set(tutor.Emotion.Name.ToString());
        data.tutor.Set(tutor.Name);
        data.emotions.Add(emotion, tutor.Emotion.Intensity);
        data.balloonData.text = text.ToList();
        if (showEffects != null)
        {
            data.balloonData.effects.showEffects = getEffectsDictionary(showEffects);
        }
        if (hideEffects != null)
        {
            data.balloonData.effects.hideEffects = getEffectsDictionary(hideEffects);
        }
        bubbleSystem.UpdateScene(data);
    }
        public void SetSprites(Emotion emotion, BalloonsHooks hooks, SpriteData spriteData, float intensity, Color color, bool options)
        {
            if (!hooks || options)
            {
                return;
            }
            Image image = hooks.balloon.GetComponent <Image>();

            DefaultData.PositionData positionData = DefaultData.Instance.GetDefaultPositions(emotion.Get(), intensity, hooks.balloon.name);
            RectTransform            rect         = hooks.balloon.GetComponent <RectTransform>();

            image.sprite   = spriteData.sprite;
            image.color    = color;
            rect.anchorMin = positionData.anchorMin;
            rect.anchorMax = positionData.anchorMax;

            SetTails(emotion, hooks.tailTopLeft, spriteData.tail, intensity, color);
            SetTails(emotion, hooks.tailBotLeft, spriteData.tail, intensity, color);
            SetTails(emotion, hooks.tailTopRight, spriteData.tail, intensity, color);
            SetTails(emotion, hooks.tailBotRight, spriteData.tail, intensity, color);
        }
Beispiel #6
0
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.B))
            {
                data.Peek().Clear();
                Emotion first = emotion.Dequeue();
                first.Set(emotionEnum.ToString());
                data.Peek().emotions.Add(first, intensity);
                data.Peek().tutor.Set(_tutor.ToString());
                data.Peek().backgroundData.reason.Set(reason.ToString());
                UpdateScene();
                emotion.Enqueue(first);
            }

            if (Input.GetKeyDown(KeyCode.S))
            {
                data.Peek().Clear();
                Emotion first = emotion.Dequeue();
                first.Set(emotionEnum.ToString());
                data.Peek().emotions.Add(first, intensity);
                data.Peek().tutor.Set(_tutor.ToString());
                if (data.Peek().tutor.GetString().Equals("User"))
                {
                    data.Peek().balloonData.options = true;
                }
                data.Peek().balloonData.text.Add("Hello world!");
                UpdateScene();
                emotion.Enqueue(first);
            }

            if (Input.GetKeyDown(KeyCode.P))
            {
                data.Peek().Clear();
                Emotion first = emotion.Dequeue();
                first.Set(emotionEnum.ToString());
                data.Peek().emotions.Add(first, intensity);
                data.Peek().tutor.Set(_tutor.ToString());
                if (data.Peek().tutor.GetString().Equals("User"))
                {
                    data.Peek().balloonData.options = true;
                }
                data.Peek().balloonData.show = false;
                UpdateScene();
                emotion.Enqueue(first);
            }

            if (Input.GetKeyDown(KeyCode.Z))
            {
                _tutor = Tutor.TutorEnum.Joao;
            }
            if (Input.GetKeyDown(KeyCode.X))
            {
                _tutor = Tutor.TutorEnum.Maria;
            }
            if (Input.GetKeyDown(KeyCode.C))
            {
                _tutor = Tutor.TutorEnum.User;
            }
            if (Input.GetKeyDown(KeyCode.Q))
            {
                emotionEnum = Emotion.EmotionEnum.Happiness;
            }
            if (Input.GetKeyDown(KeyCode.W))
            {
                emotionEnum = Emotion.EmotionEnum.Sadness;
            }
            if (Input.GetKeyDown(KeyCode.E))
            {
                emotionEnum = Emotion.EmotionEnum.Surprise;
            }
            if (Input.GetKeyDown(KeyCode.R))
            {
                emotionEnum = Emotion.EmotionEnum.Fear;
            }
            if (Input.GetKeyDown(KeyCode.T))
            {
                emotionEnum = Emotion.EmotionEnum.Anger;
            }
            if (Input.GetKeyDown(KeyCode.Y))
            {
                emotionEnum = Emotion.EmotionEnum.Disgust;
            }
            if (Input.GetKeyDown(KeyCode.U))
            {
                emotionEnum = Emotion.EmotionEnum.Neutral;
            }
            if (Input.GetKeyDown(KeyCode.Alpha1))
            {
                reason = Reason.ReasonEnum.None;
            }
            if (Input.GetKeyDown(KeyCode.Alpha2))
            {
                reason = Reason.ReasonEnum.Challenge;
            }
            if (Input.GetKeyDown(KeyCode.Alpha3))
            {
                reason = Reason.ReasonEnum.Effort;
            }
            if (Input.GetKeyDown(KeyCode.Alpha4))
            {
                reason = Reason.ReasonEnum.Engagement;
            }
            if (Input.GetKeyDown(KeyCode.Alpha5))
            {
                reason = Reason.ReasonEnum.Enjoyment;
            }
            if (Input.GetKeyDown(KeyCode.Alpha6))
            {
                reason = Reason.ReasonEnum.Importance;
            }
            if (Input.GetKeyDown(KeyCode.Alpha7))
            {
                reason = Reason.ReasonEnum.Performance;
            }
            if (Input.GetKeyDown(KeyCode.KeypadPlus))
            {
                Mathf.Clamp01(intensity += 0.1f);
            }
            if (Input.GetKeyDown(KeyCode.KeypadMinus))
            {
                Mathf.Clamp01(intensity -= 0.1f);
            }

            if (Input.GetKeyDown(KeyCode.D))
            {
                bridge.Handle(new string[] { "OverrideTextEffects", "Happiness", "0.5", "showEffects", "FadeIn", "linearCurve", "hideEffects", "FadeOut", "linearCurve" });
            }

            if (Input.GetKeyDown(KeyCode.F))
            {
                bridge.UpdateOptions(new string[] { "hi", "asd", "sadf", "ge3r" });
            }

            if (Input.GetKeyDown(KeyCode.G))
            {
                mix = (mix + 1) % 2;
                Debug.Log(Convert.ToBoolean(mix));
                bridge.Handle(new string[] { "SetMixColors", mix.ToString() });
            }

            if (Input.GetKeyDown(KeyCode.H))
            {
                bridge.Handle(new string[] { "OverrideBlushColor", "#00FF00FF" });
            }

            if (Input.GetKeyDown(KeyCode.J))
            {
                bridge.Handle(new string[] { "OverrideEmotionColor", "Happiness", "#00FF00FF" });
            }

            if (Input.GetKeyDown(KeyCode.K))
            {
                bridge.Handle(new string[] { "AddAnimationCurve", "abc", "0", "0", "smooth", "1", "1", "1" });
            }

            if (Input.GetKeyDown(KeyCode.L))
            {
                forceText = (forceText + 1) % 2;
                bridge.Handle(new string[] { "SetForceTextUpdate", forceText.ToString() });
            }

            if (Input.GetKeyDown(KeyCode.V))
            {
                balloonAnimation = (balloonAnimation + 1) % 2;
                Debug.Log(Convert.ToBoolean(balloonAnimation));
                bridge.Handle(new string[] { "SetBalloonAnimationBlending", balloonAnimation.ToString() });
            }

            if (Input.GetKeyDown(KeyCode.A))
            {
                bridge.Handle(new string[] { "SetBalloonDuration", 2f.ToString() });
            }

            if (Input.GetKeyDown(KeyCode.N))
            {
                bridge.Handle(new string[] { "SetBackgroundDuration", 2f.ToString() });
            }

            if (Input.GetKeyDown(KeyCode.M))
            {
                bridge.Handle(new string[] { "SetOptionsDuration", 2f.ToString() });
            }

            if (Input.GetKeyDown(KeyCode.Alpha8))
            {
                bridge.HideBalloon("User");
            }

            if (Input.GetKeyDown(KeyCode.Alpha9))
            {
                bridge.Handle(new string[] { "UpdateBackground", Tutor.TutorEnum.Maria.ToString(), "Fear", "1", "None" });
            }

            if (Input.GetKeyDown(KeyCode.Alpha0))
            {
                bridge.HideBalloon(BubbleSystem.Tutor.TutorEnum.User.ToString());
            }
        }