예제 #1
0
        /// <summary>
        /// Apply target values to a starting point before tweening.
        /// </summary>
        /// <param name="values">The values to apply, in an anonymous type ( new { prop1 = 100, prop2 = 0} ).</param>
        /// <returns>A reference to this.</returns>
        public Glide From(object values)
        {
            foreach (PropertyInfo property in values.GetType().GetProperties())
            {
                int index = vars.FindIndex(i => String.Compare(i.Name, property.Name, true) == 0);
                if (index >= 0)
                {
                    //	if we're already tweening this value, adjust the range
                    var info = vars[index];

                    var to = new GlideInfo(values, property.Name, false);
                    info.Value = to.Value;

                    start[index] = info.Value;
                    range[index] = this.end[index] - start[index];
                }
                else
                {
                    //	if we aren't tweening this value, just set it
                    var info = new GlideInfo(target, property.Name, true);
                    var to   = new GlideInfo(values, property.Name, false);
                    info.Value = to.Value;
                }
            }

            return(this);
        }
예제 #2
0
        /// <summary>
        /// Tweens a set of numeric properties on an object.
        /// </summary>
        /// <param name="target">The object to tween.</param>
        /// <param name="values">The values to tween to, in an anonymous type ( new { prop1 = 100, prop2 = 0} ).</param>
        /// <param name="duration">Duration of the tween in seconds.</param>
        /// <param name="delay">Delay before the tween starts, in seconds.</param>
        /// <returns>The tween created, for setting properties on.</returns>
        public Glide Tween(object target, object values, float duration, float delay = 0)
        {
            if (parent != null)
            {
                throw new Exception("Tween can only be called from standalone instances!");
            }

            var glide = new Glide();

            glide.target   = target;
            glide.duration = duration;
            glide.delay    = delay;

            glide.parent = this;

            toAdd.Add(glide);

            if (values == null)             // in case of timer
            {
                return(glide);
            }

            foreach (PropertyInfo property in values.GetType().GetProperties())
            {
                var info = new GlideInfo(target, property.Name);
                var to   = new GlideInfo(values, property.Name, false).Value;

                float s = info.Value;
                float r = to - s;

                glide.vars.Add(info);
                glide.start.Add(s);
                glide.range.Add(r);
                glide.end.Add(to);
            }

            return(glide);
        }
예제 #3
0
        /// <summary>
        /// Tweens a set of numeric properties on an object.
        /// </summary>
        /// <param name="target">The object to tween.</param>
        /// <param name="values">The values to tween to, in an anonymous type ( new { prop1 = 100, prop2 = 0} ).</param>
        /// <param name="duration">Duration of the tween in seconds.</param>
        /// <param name="delay">Delay before the tween starts, in seconds.</param>
        /// <returns>The tween created, for setting properties on.</returns>
        public Glide Tween(object target, object values, float duration, float delay = 0)
        {
            if (parent != null)
                throw new Exception("Tween can only be called from standalone instances!");

            var glide = new Glide();

            glide.target = target;
            glide.duration = duration;
            glide.delay = delay;

            glide.parent = this;

            toAdd.Add(glide);

            if (values == null) // in case of timer
                return glide;

            foreach (PropertyInfo property in values.GetType().GetProperties())
            {
                var info = new GlideInfo(target, property.Name);
                var to = new GlideInfo(values, property.Name, false).Value;

                float s = info.Value;
                float r = to - s;

                glide.vars.Add(info);
                glide.start.Add(s);
                glide.range.Add(r);
                glide.end.Add(to);
            }

            return glide;
        }
예제 #4
0
        /// <summary>
        /// Apply target values to a starting point before tweening.
        /// </summary>
        /// <param name="values">The values to apply, in an anonymous type ( new { prop1 = 100, prop2 = 0} ).</param>
        /// <returns>A reference to this.</returns>
        public Glide From(object values)
        {
            foreach (PropertyInfo property in values.GetType().GetProperties())
            {
                int index = vars.FindIndex(i => String.Compare(i.Name, property.Name, true) == 0);
                if (index >= 0)
                {
                    //	if we're already tweening this value, adjust the range
                    var info = vars[index];

                    var to = new GlideInfo(values, property.Name, false);
                    info.Value = to.Value;

                    start[index] = info.Value;
                    range[index] = this.end[index] - start[index];
                }
                else
                {
                    //	if we aren't tweening this value, just set it
                    var info = new GlideInfo(target, property.Name, true);
                    var to = new GlideInfo(values, property.Name, false);
                    info.Value = to.Value;
                }
            }

            return this;
        }