Beispiel #1
0
        public static ABAnimation WaitForDuration(float duration)
        {
            var animation = new ABAnimation(ABAnimationType.Wait);

            animation.Duration = duration;
            return(animation);
        }
Beispiel #2
0
        public static ABAnimation Group(List <ABAnimation> animations)
        {
            var animation = new ABAnimation(ABAnimationType.Group);

            animation.Animations = animations;
            return(animation);
        }
Beispiel #3
0
        public static ABAnimation Sequence(List <ABAnimation> animations)
        {
            var animation = new ABAnimation(ABAnimationType.Sequence);

            animation.Animations = animations;
            return(animation);
        }
Beispiel #4
0
        public static ABAnimation FadeOut(float duration)
        {
            var animation = new ABAnimation(ABAnimationType.FadeOut);

            animation.Duration = duration;
            return(animation);
        }
Beispiel #5
0
        public static ABAnimation FadeAlphaBy(float deltaAlpha, float duration)
        {
            var animation = new ABAnimation(ABAnimationType.FadeAlphaBy);

            animation.Value    = deltaAlpha;
            animation.Duration = duration;
            return(animation);
        }
Beispiel #6
0
        public static ABAnimation FadeAlphaTo(float alpha, float duration)
        {
            var animation = new ABAnimation(ABAnimationType.FadeAlphaTo);

            animation.Value    = alpha;
            animation.Duration = duration;
            return(animation);
        }
Beispiel #7
0
        public static ABAnimation ScaleBy(Vector3 deltaScale, float duration)
        {
            var animation = new ABAnimation(ABAnimationType.ScaleBy);

            animation.Vector   = deltaScale;
            animation.Duration = duration;
            return(animation);
        }
Beispiel #8
0
        public static ABAnimation ScaleTo(Vector3 scale, float duration)
        {
            var animation = new ABAnimation(ABAnimationType.ScaleTo);

            animation.Vector   = scale;
            animation.Duration = duration;
            return(animation);
        }
Beispiel #9
0
        public static ABAnimation RotateBy(Vector3 deltaRotation, float duration)
        {
            var animation = new ABAnimation(ABAnimationType.RotateBy);

            animation.Vector   = deltaRotation;
            animation.Duration = duration;
            return(animation);
        }
Beispiel #10
0
        public static ABAnimation RotateTo(Vector3 rotation, float duration)
        {
            var animation = new ABAnimation(ABAnimationType.RotateTo);

            animation.Vector   = rotation;
            animation.Duration = duration;
            return(animation);
        }
Beispiel #11
0
        public static ABAnimation MoveTo(Vector3 position, float duration)
        {
            var animation = new ABAnimation(ABAnimationType.MoveTo);

            animation.Vector   = position;
            animation.Duration = duration;
            return(animation);
        }
Beispiel #12
0
 public static int IndexOfAnimation(ABAnimation animation)
 {
     if (animation == null)
     {
         return((int)ABAnimationType.None);
     }
     return(IndexOfAnimationType(animation.Type));
 }
Beispiel #13
0
 public ABAnimation(ABAnimation animation)
 {
     Type         = animation.Type;
     Animations   = new List <ABAnimation> (animation.Animations);
     Vector       = animation.Vector;
     Duration     = animation.duration;
     RepeatsCount = animation.RepeatsCount;
     Value        = animation.Value;
 }
Beispiel #14
0
        public static void PreviewAnimation(ABAnimation animation, GameObject obj)
        {
            var position = obj.transform.position;
            var rotation = obj.transform.rotation;
            var scale    = obj.transform.localScale;
            var renderer = obj.GetComponent <SpriteRenderer> ();
            var color    = renderer.color;

            RunAnimation(animation, obj, () => {
                obj.transform.position   = position;
                obj.transform.rotation   = rotation;
                obj.transform.localScale = scale;
                renderer.color           = color;
            });
        }
Beispiel #15
0
        public static void RunAnimation(ABAnimation animation, GameObject obj, Action completion = null)
        {
            if (animation == null || obj == null)
            {
                return;
            }

            switch (animation.Type)
            {
            case ABAnimationType.RotateBy:
                RunRotateByAnimation(obj, animation.Vector, animation.Duration, animation.Timing, completion, animation.RepeatsCount);
                break;

            case ABAnimationType.RotateTo:
                RunRotateToAnimation(obj, animation.Vector, animation.Duration, animation.Timing, completion);
                break;

            case ABAnimationType.MoveBy:
//				var pos = new ABPosition (animation.Vector);
//				var vector = pos.ToVector ();
                RunMoveByAnimation(obj, animation.Vector, animation.Duration, animation.Timing, completion, animation.RepeatsCount);
                break;

            case ABAnimationType.MoveTo:
//				pos = new ABPosition (animation.Vector);
//				vector = pos.ToVector ();
                RunMoveToAnimation(obj, animation.Vector, animation.Duration, animation.Timing, completion);
                break;

            case ABAnimationType.Sequence:
                RunAnimationSequence(obj, animation.Animations, completion, animation.RepeatsCount);
                break;

            case ABAnimationType.Group:
                RunAnimationGroup(obj, animation.Animations, completion, animation.RepeatsCount);
                break;

            case ABAnimationType.ScaleBy:
                RunScaleByAnimation(obj, animation.Vector, animation.Duration, animation.Timing, completion, animation.RepeatsCount);
                break;

            case ABAnimationType.ScaleTo:
                RunScaleToAnimation(obj, animation.Vector, animation.Duration, animation.Timing, completion);
                break;

            case ABAnimationType.FadeAlphaBy:
                RunFadeAlphaByAnimation(obj, animation.Value, animation.Duration, animation.Timing, completion, animation.RepeatsCount);
                break;

            case ABAnimationType.FadeAlphaTo:
                RunFadeAlphaToAnimation(obj, animation.Value, animation.Duration, animation.Timing, completion);
                break;

            case ABAnimationType.FadeIn:
                RunFadeInAnimation(obj, animation.Duration, animation.Timing, completion);
                break;

            case ABAnimationType.FadeOut:
                RunFadeOutAnimation(obj, animation.Duration, animation.Timing, completion);
                break;

            case ABAnimationType.Wait:
                RunWaitForDurationAnimation(animation.Duration, completion);
                break;

            default:
                break;
            }
        }