Exemplo n.º 1
0
        IEnumerator Clean(BalloonsHooks hooks, float duration, BubbleSystemData data)
        {
            yield return(new WaitForSeconds(duration));

            if (hooks)
            {
                if (hooks.Content != null)
                {
                    hooks.Hide();

                    var   animationClips = hooks.GetComponent <Animator>().runtimeAnimatorController.animationClips;
                    float length         = balloonData.GetClipsDuration(hooks) * 2; //times 2, to give it a little more time
                    KeyValuePair <Emotion, float> emotionPair = BubbleSystemUtility.GetHighestEmotion(data.emotions);
                    float    sum = BubbleSystemUtility.GetEmotionsSum(data.emotions);
                    TextData textData;
                    if (balloonData.options)
                    {
                        textData = DefaultData.Instance.GetDefaultTextData(data.tutor.GetString(), emotionPair.Value);
                    }
                    else
                    {
                        textData = DefaultData.Instance.GetDefaultTextData(emotionPair.Key.GetString(), emotionPair.Value);
                    }
                    Dictionary <AbstractTextEffect.TextEffectEnum, AnimationCurve> hideEffects = data.balloonData.effects.hideEffects.Count != 0 ? data.balloonData.effects.hideEffects : textData.hideEffect;

                    foreach (AbstractTextEffect.TextEffectEnum effect in hideEffects.Keys)
                    {
                        SetTextEffects(hooks, hideEffects[effect], sum, length, false);
                        coroutines.Add(balloonData.SetEffects(effect, textEffectsData));
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static Color32 GetColor(KeyValuePair <Emotion, float> emotionPair, Dictionary <Emotion, float> emotions)
        {
            Color32 color;

            if (emotionPair.Value.Equals(0.0f) || emotionPair.Key.Equals(Emotion.EmotionEnum.Neutral))
            {
                color = DefaultData.Instance.GetColor(Emotion.EmotionEnum.Neutral);
            }
            else
            {
                color = DefaultData.Instance.mixColors ? BubbleSystemUtility.MixColors(emotions) : DefaultData.Instance.GetColor(emotionPair.Key.Get());
            }

            return(color);
        }
Exemplo n.º 3
0
        public void SetTextEffects(string emotion, float intensity, Dictionary <AbstractTextEffect.TextEffectEnum, AnimationCurve> showEffects, Dictionary <AbstractTextEffect.TextEffectEnum, AnimationCurve> hideEffects)
        {
            Dictionary <float, TextData> dict = defaultTextData[emotion];
            TextData textData = dict.Where(key => intensity <= key.Key).OrderBy(key => key.Key).FirstOrDefault().Value;

            if (showEffects != null)
            {
                textData.showEffect = showEffects;
            }
            if (hideEffects != null)
            {
                textData.hideEffect = hideEffects;
            }

            BubbleSystemUtility.AddToDictionary(ref defaultTextData, emotion, intensity, textData);
        }
Exemplo n.º 4
0
        private IEnumerator ChangeImage(BubbleSystemData data)
        {
            KeyValuePair <Emotion, float> emotionPair = BubbleSystemUtility.GetHighestEmotion(data.emotions);

            bgData.textureData = DefaultData.Instance.GetDefaultBackgroundDataDictionary(emotionPair.Key.Get(), emotionPair.Value, data.backgroundData.reason);
            float duration = DefaultData.Instance.GetBackgroundDuration();

            bgData.renderer = GetComponent <Renderer>();
            EffectsData <AbstractImageEffect.ImageEffectEnum> effects = data.backgroundData.effects.IsCleared() ? DefaultData.Instance.GetDefaultBackgroundAnimationData(emotionPair.Key.Get(), emotionPair.Value) : data.backgroundData.effects;

            bgData.duration = duration / 2;

            if (!bgData.textureData.name.Equals(bgData.renderer.materials[1].mainTexture.name))
            {
                foreach (AbstractImageEffect.ImageEffectEnum fx in effects.hideEffects.Keys)
                {
                    bgData.curve = effects.hideEffects[fx];
                    coroutines.Add(EffectsManager.Instance.Play(fx, bgData));
                }

                yield return(new WaitForSeconds(bgData.duration));

                bgData.renderer.materials[bgData.renderer.materials.Length - 1].mainTexture          = bgData.textureData;
                bgData.renderer.materials[bgData.renderer.materials.Length - 1].mainTexture.wrapMode = GetWrapMode(data.backgroundData.reason);
            }
            else
            {
                bgData.duration = duration;
            }

            bgData.colorToLerpTo = BubbleSystemUtility.GetColor(emotionPair, data.emotions);

            if (!bgData.renderer.material.color.Equals(bgData.colorToLerpTo))
            {
                foreach (AbstractImageEffect.ImageEffectEnum fx in effects.colorEffects.Keys)
                {
                    bgData.curve = effects.colorEffects[fx];
                    coroutines.Add(EffectsManager.Instance.Play(fx, bgData));
                }

                yield return(new WaitForSeconds(bgData.duration));
            }
        }
Exemplo n.º 5
0
        public void ReverseTutorsBalloons(string tutor)
        {
            int index   = Array.FindIndex(balloons, balloon => balloon.balloonData._name == tutor);
            int options = Array.FindIndex(balloons, balloon => balloon.balloonData.options == true);

            if (balloons[index].balloonData.dontSwitch || balloons[index].balloonData.options)
            {
                return;
            }

            int element = BubbleSystemUtility.RandomExcludingNumbers(new int[] { index, options }, balloons.Length);

            Control first  = balloons[index].control;
            Control second = balloons[element].control;

            balloons[index].control   = second;
            balloons[element].control = first;

            foreach (Balloon balloon in balloons)
            {
                balloon.balloonData.isTailLeft = !balloon.balloonData._name.Equals(tutor);
                balloon.SetTails();
            }
        }
Exemplo n.º 6
0
 public void AddCurve(string name, AnimationCurve curve)
 {
     BubbleSystemUtility.AddToDictionary(ref curves, name, curve);
 }
Exemplo n.º 7
0
        private void ShowBalloon(BubbleSystemData data)
        {
            if (control.Show() == ShowResult.FAIL)
            {
                return;
            }
            int i = 0;

            BalloonsHooks[] balloonHooks = control.Instance.GetComponentsInChildren <BalloonsHooks>();

            foreach (BalloonsHooks hooks in balloonHooks)
            {
                if (hooks == null)
                {
                    return;
                }

                KeyValuePair <Emotion, float> emotionPair = BubbleSystemUtility.GetHighestEmotion(data.emotions);
                float      sum          = BubbleSystemUtility.GetEmotionsSum(data.emotions);
                SpriteData spriteData   = DefaultData.Instance.GetDefaultBalloonData(emotionPair.Key.Get(), emotionPair.Value);
                Color      color        = BubbleSystemUtility.GetColor(emotionPair, data.emotions);
                float      realDuration = balloonData.options ? DefaultData.Instance.GetOptionsDuration() : DefaultData.Instance.GetBalloonDuration();
                TextData   textData;
                Dictionary <AbstractTextEffect.TextEffectEnum, AnimationCurve> showEffects;
                Color textColor    = BubbleSystemUtility.GetTextColor(color);
                float textDuration = realDuration - durationThreshold; // so it finishes before hide

                balloonData.SetContent(hooks, data.balloonData.text.Count > i ? data.balloonData.text[i] : null);
                balloonData.SetSprites(emotionPair.Key, hooks, spriteData, emotionPair.Value, color, balloonData.options);

                if (i < data.balloonData.callbacks.Count)
                {
                    balloonData.SetCallback(hooks, data.balloonData.callbacks[i], i);
                }

                // Do not animate options
                if (!balloonData.options)
                {
                    if (DefaultData.Instance.blendBalloonAnimation)
                    {
                        balloonData.SetAnimators(hooks, data.emotions);
                    }
                    else
                    {
                        balloonData.SetAnimators(hooks, emotionPair.Key);
                    }

                    textData = DefaultData.Instance.GetDefaultTextData(emotionPair.Key.GetString(), emotionPair.Value);
                    balloonData.SetTexts(hooks, textData, textColor, emotionPair.Key);
                }
                else
                {
                    textData = DefaultData.Instance.GetDefaultTextData(data.tutor.GetString(), emotionPair.Value);
                }

                showEffects = data.balloonData.effects.showEffects.Count != 0 ? data.balloonData.effects.showEffects : textData.showEffect;

                foreach (AbstractTextEffect.TextEffectEnum effect in showEffects.Keys)
                {
                    SetTextEffects(hooks, showEffects[effect], sum, textDuration, true);
                    coroutines.Add(balloonData.SetEffects(effect, textEffectsData));
                }

                hooks.Show();
                if (realDuration != -1)
                {
                    AddCoroutine(Clean(hooks, realDuration, data));
                }
                i++;
            }
        }