Ejemplo n.º 1
0
 /// <summary>
 /// Fade the incoming scene in and the outgoing scene out
 /// </summary>
 /// <returns></returns>
 public static Transition CrossFade() =>
 new Transition(
     Animation.Fade(0.0f, 1.0f),
     Animation.Fade(1.0f, 0.0f),
     true);
Ejemplo n.º 2
0
        public Animation Instantiate()
        {
            if (null == _tweens)
            {
                return(null);
            }

            Animation tween = IsSequence ? Animation.Sequence() : Animation.Group();

            for (int i = 0; i < _tweens.Length; i++)
            {
                Animation child = null;

                switch (_tweens[i].Type)
                {
                case TweenType.Move: child = Animation.Move(_tweens[i].From, _tweens[i].To); break;

                case TweenType.Fade:
                    child = Animation.Fade(_tweens[i].From.x, _tweens[i].To.x);
                    break;

                case TweenType.Color:
                    child = Animation.Color(
                        new Color(_tweens[i].From.x, _tweens[i].From.y, _tweens[i].From.z),
                        new Color(_tweens[i].To.x, _tweens[i].To.y, _tweens[i].To.z)
                        );
                    break;

                case TweenType.Scale:
                    child = Animation.Scale(_tweens[i].From.x, _tweens[i].To.x);
                    break;

                case TweenType.ShakePosition:
                    child = Animation.ShakePosition(_tweens[i].From);
                    break;

                case TweenType.ShakeRotation:
                    child = Animation.ShakeRotation(_tweens[i].From);
                    break;

                case TweenType.Play:
                    child = Animation.Play(_tweens[i].Object as AudioClip, _tweens[i].From.x, _tweens[i].From.y);
                    break;

                case TweenType.Wait:
                    child = Animation.Wait(0f);
                    break;

                case TweenType.Activate:
                    child = Animation.Activate(_tweens[i].From.x > 0);
                    break;
                }

                if (!string.IsNullOrWhiteSpace(_tweens[i].Target))
                {
                    child.Target(_tweens[i].Target);
                }

                child.Easing(_tweens[i].Easing, _tweens[i].EasingParam1, _tweens[i].EasingParam2);
                child.PingPong(_tweens[i].IsPingPong);
                child.Loop(_tweens[i].IsLooping);
                child.Duration(_tweens[i].Duration);
                child.Delay(_tweens[i].Delay);

                if (_tweens[i].IsLowPriority)
                {
                    child.LowPriority();
                }

                tween.Child(child);
            }

            if (!string.IsNullOrWhiteSpace(_target))
            {
                tween.Target(_target);
            }

            tween.Loop(IsLooping);
            tween.PingPong(IsPingPong);

            if (IsLowPriority)
            {
                tween.LowPriority();
            }

            if (DurationOverride)
            {
                tween.Duration(Duration);
            }

            tween.Delay(Delay);

            return(tween);
        }