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
        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++;
            }
        }