Ejemplo n.º 1
0
        public static Tweener PlayFromTo(object targ, string propName, Ease ease, object start, object end, float dur, object option = null)
        {
            var tween = new ObjectTweener(targ, MemberCurve.CreateFromTo(targ, propName, ease, start, end, dur, option));

            tween.Play();
            return(tween);
        }
Ejemplo n.º 2
0
        public static Tweener PlayFrom(object targ, string propName, object start, float dur, object option = null)
        {
            var tween = new ObjectTweener(targ, MemberCurve.CreateFrom(targ, propName, EaseMethods.LinearEaseNone, start, dur, option));

            tween.Play();
            return(tween);
        }
Ejemplo n.º 3
0
        public static Tweener PlayBy(object targ, string propName, Ease ease, object amt, float dur, object option = null)
        {
            var tween = new ObjectTweener(targ, MemberCurve.CreateBy(targ, propName, ease, amt, dur, option));

            tween.Play();
            return(tween);
        }
        public static MemberCurve CreateRedirectTo(object target, string propName, Ease ease, object start, object end, float dur, object option = null)
        {
            if (target == null)
            {
                throw new System.ArgumentNullException("target");
            }
            if (ease == null)
            {
                throw new System.ArgumentNullException("ease");
            }

            System.Type memberType;
            var         accessor = MemberCurve.GetAccessor(target, propName, out memberType);

            var curve = CreateUnitializedCurve(memberType, accessor);

            curve._ease     = ease;
            curve._accessor = accessor;
            if (curve is ISupportRedirectToMemberCurve)
            {
                (curve as ISupportRedirectToMemberCurve).ConfigureAsRedirectTo(memberType, dur, accessor.Get(target), start, end, option);
            }
            else
            {
                //try to coerce
                curve._dur = dur;
                var current = accessor.Get(target);
                dur = (1f - MathUtil.PercentageOffMinMax(ConvertUtil.ToSingle(current), ConvertUtil.ToSingle(end), ConvertUtil.ToSingle(start))) * dur;
                return(MemberCurve.Create(memberType, accessor, ease, dur, current, ConvertUtil.ToPrim(end, memberType), option));
            }

            return(curve);
        }
Ejemplo n.º 5
0
        public static Tweener PlayCurve(object targ, string propName, AnimationCurve curve, float dur, object option = null)
        {
            if (curve == null)
            {
                throw new System.ArgumentNullException("curve");
            }
            var tween = new ObjectTweener(targ, MemberCurve.CreateFromTo(targ, propName, EaseMethods.FromAnimationCurve(curve), null, null, dur, option));

            tween.Play();
            return(tween);
        }
Ejemplo n.º 6
0
        public new static MemberCurve CreateFromTo(object target, string propName, Ease ease, object start, object end, float dur, object option = null)
        {
            if (target == null)
            {
                throw new System.ArgumentNullException("target");
            }
            System.Type memberType;
            var         accessor = MemberCurve.GetAccessor(target, propName, out memberType);

            return(MemberCurve.Create(memberType, accessor, ease, dur, start, end, option));
        }
Ejemplo n.º 7
0
        public sealed override void Update(object targ, float dt, float t)
        {
            var value = GetValueAt(dt, t);

            if (_accessor == null)
            {
                System.Type memberType;
                _accessor = MemberCurve.GetAccessor(targ, _memberName, out memberType);
            }
            _accessor.Set(targ, value);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates a curve that will animate from the current value to the end value, but will rescale the duration from how long it should have
        /// taken from start to end, but already animated up to current.
        /// </summary>
        /// <param name="target"></param>
        /// <param name="propName"></param>
        /// <param name="ease"></param>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <param name="dur"></param>
        /// <param name="option"></param>
        /// <returns></returns>
        public new static MemberCurve CreateRedirectTo(object target, string propName, Ease ease, float start, float end, float dur, object option = null)
        {
            if (target == null)
            {
                throw new System.ArgumentNullException("target");
            }
            System.Type memberType;
            var         accessor = MemberCurve.GetAccessor(target, propName, out memberType);

            var current = accessor.Get(target);

            dur = MathUtil.PercentageOffMinMax(ConvertUtil.ToSingle(current), end, start) * dur;

            return(MemberCurve.Create(memberType, accessor, ease, dur, current, ConvertUtil.ToPrim(end, memberType), option));
        }
        private TweenCurve CreateCurve(PropInfo prop)
        {
            try
            {
                Ease  ease = (prop.ease == null) ? _defaultEase : prop.ease;
                float dur  = prop.dur;
                switch (prop.mode)
                {
                case AnimMode.AnimCurve:
                    return(MemberCurve.CreateFromTo(_targ, prop.name, ease, null, null, dur, prop.option));

                case AnimMode.Curve:
                    return(prop.value as TweenCurve);

                case AnimMode.To:
                    return(MemberCurve.CreateTo(_targ, prop.name, ease, prop.value, dur, prop.option));

                case AnimMode.From:
                    return(MemberCurve.CreateFrom(_targ, prop.name, ease, prop.value, dur, prop.option));

                case AnimMode.By:
                    return(MemberCurve.CreateBy(_targ, prop.name, ease, prop.value, dur, prop.option));

                case AnimMode.FromTo:
                    return(MemberCurve.CreateFromTo(_targ, prop.name, ease, prop.value, prop.altValue, dur, prop.option));

                case AnimMode.RedirectTo:
                    return(MemberCurve.CreateRedirectTo(_targ, prop.name, ease, prop.value, prop.altValue, dur, prop.option));
                }
            }
            catch
            {
                return(null);
            }

            return(null);
        }
 public static TweenCurve CreateBy(object target, string propName, Ease ease, object amt, float dur, object option = null)
 {
     return(MemberCurve.CreateBy(target, propName, ease, amt, dur, option));
 }
 public static TweenCurve CreateFromTo(object target, string propName, Ease ease, object start, object end, float dur, object option = null)
 {
     return(MemberCurve.CreateFromTo(target, propName, ease, start, end, dur, option));
 }