Пример #1
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));
            }
        }
Пример #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++;
            }
        }