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

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

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

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

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

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

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

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

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

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

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

            animation.Vector   = position;
            animation.Duration = duration;
            return(animation);
        }
示例#12
0
 public static int IndexOfAnimation(ABAnimation animation)
 {
     if (animation == null)
     {
         return((int)ABAnimationType.None);
     }
     return(IndexOfAnimationType(animation.Type));
 }
示例#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;
 }
示例#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;
            });
        }
示例#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;
            }
        }