コード例 #1
0
 public static void TweenColorAlpha(IHasColor hasColor, float from, float to, int duration,
                                    Easing.Equation easing,
                                    int delay = 0, ITweener tweener = null)
 {
     CoroutineManager.StartCoroutine(
         TweenColorAlphaRoutine(hasColor, from, to, duration, easing, delay, tweener), null);
 }
コード例 #2
0
        static IEnumerator TweenColorAlphaRoutine(IHasColor hasColor, float from, float to, int duration,
                                                  Easing.Equation easing,
                                                  int delay = 0, ITweener tweener = null)
        {
            if (delay > 0)
            {
                yield return(new WaitForMilliSeconds(delay));
            }

            float durationF = duration * 0.001f;
            float time      = 0;

            hasColor.Alpha = from;
            var childs = hasColor.children;

            for (int i = 0; i < childs.Count; i++)
            {
                if (childs[i] is IHasColor)
                {
                    ((IHasColor)childs[i]).Alpha = from;
                }
            }

            while (time < durationF)
            {
                hasColor.Alpha = Easing.Ease(easing, time, from, to, durationF);

                for (int i = 0; i < childs.Count; i++)
                {
                    if (childs[i] is IHasColor)
                    {
                        ((IHasColor)childs[i]).Alpha = Easing.Ease(easing, time, from, to, durationF);
                    }
                }

                time += Time.deltaTime * 0.001f;

                yield return(null);
            }

            hasColor.Alpha = to;
            for (int i = 0; i < childs.Count; i++)
            {
                if (childs[i] is IHasColor)
                {
                    ((IHasColor)childs[i]).Alpha = to;
                }
            }

            if (tweener != null)
            {
                tweener.OnTweenEnd(hasColor);
            }
        }
コード例 #3
0
ファイル: ProxyTests.cs プロジェクト: petebacondarwin/Elf
 public IColoredShape CreateColoredShapeMixin(IHasShape shape, IHasColor color)
 {
     var options = new ProxyGenerationOptions();
     options.AddMixinInstance(shape);
     options.AddMixinInstance(color);
     var generator = new ProxyGenerator();
     var proxy = generator.CreateClassProxy(typeof(object), new[] { typeof(IColoredShape) }, options) as IColoredShape;
     return proxy;
 }
コード例 #4
0
 public static void TweenColorAlpha(IHasColor hasColor, float from, float to, int duration, ITweener tweener)
 {
     TweenColorAlpha(hasColor, from, to, duration, Easing.Equation.Linear, 0, tweener);
 }
コード例 #5
0
 public static void TweenColorAlpha(IHasColor hasColor, float from, float to, int duration,
                                    OnFinished onFinished)
 {
     TweenColorAlpha(hasColor, from, to, duration, Easing.Equation.Linear, 0, onFinished);
 }