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)); } }
private void SetBackground() { EffectsData <AbstractImageEffect.ImageEffectEnum> effects = new EffectsData <AbstractImageEffect.ImageEffectEnum>(); Dictionary <float, EffectsData <AbstractImageEffect.ImageEffectEnum> > dict = new Dictionary <float, EffectsData <AbstractImageEffect.ImageEffectEnum> >(); effects = new EffectsData <AbstractImageEffect.ImageEffectEnum>(); effects.showEffects = new Dictionary <AbstractImageEffect.ImageEffectEnum, AnimationCurve>(); effects.hideEffects = new Dictionary <AbstractImageEffect.ImageEffectEnum, AnimationCurve>(); effects.colorEffects = new Dictionary <AbstractImageEffect.ImageEffectEnum, AnimationCurve>(); effects.showEffects.Add(AbstractImageEffect.ImageEffectEnum.FadeTexture, curves["linearCurve"]); effects.hideEffects.Add(AbstractImageEffect.ImageEffectEnum.FadeTexture, curves["linearCurve"]); effects.colorEffects.Add(AbstractImageEffect.ImageEffectEnum.FadeColor, curves["linearCurve"]); dict.Add(1f, effects); defaultBackgroundAnimationData.Add(Emotion.EmotionEnum.Neutral, dict); defaultBackgroundAnimationData.Add(Emotion.EmotionEnum.Happiness, dict); defaultBackgroundAnimationData.Add(Emotion.EmotionEnum.Sadness, dict); defaultBackgroundAnimationData.Add(Emotion.EmotionEnum.Anger, dict); defaultBackgroundAnimationData.Add(Emotion.EmotionEnum.Fear, dict); defaultBackgroundAnimationData.Add(Emotion.EmotionEnum.Disgust, dict); defaultBackgroundAnimationData.Add(Emotion.EmotionEnum.Surprise, dict); }