Exemplo n.º 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 Tween From(object values)
        {
            var props = values.GetType().GetProperties();
            for (int i = 0; i < props.Length; ++i)
            {
                var property = props[i];
                var propValue = property.GetValue(values, null);

                int index = -1;
                if (varHash.TryGetValue(property.Name, out index))
                {
                    //	if we're already tweening this value, adjust the range
                    start[index] = propValue;
                }

                //	if we aren't tweening this value, just set it
                var info = new GlideInfo(Target, property.Name, true);
                info.Value = propValue;
            }

            return this;
        }
Exemplo n.º 2
0
        private void AddLerp(Lerper lerper, GlideInfo info, object from, object to)
        {
            varHash.Add(info.PropertyName, vars.Count);
            vars.Add(info);

            start.Add(from);
            end.Add(to);

            lerpers.Add(lerper);
        }
Exemplo n.º 3
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 Tween 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] = Convert.ToSingle(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;
        }