public PropertyColorAccesser(Getter getter, Setter setter) : base(getter, setter)
        {
            r = new PropertyAccesser <TObject, float>(
                getter: (obj) => {
                return(this.Get(obj).r);
            },
                setter: (obj, value) => {
                var v = this.Get(obj);
                v.r   = value;
                this.Set(obj, v);
            }
                );
            g = new PropertyAccesser <TObject, float>(
                getter: (obj) => {
                return(this.Get(obj).g);
            },
                setter: (obj, value) => {
                var v = this.Get(obj);
                v.g   = value;
                this.Set(obj, v);
            }
                );

            b = new PropertyAccesser <TObject, float>(
                getter: (obj) => {
                return(this.Get(obj).b);
            },
                setter: (obj, value) => {
                var v = this.Get(obj);
                v.b   = value;
                this.Set(obj, v);
            }
                );

            a = new PropertyAccesser <TObject, float>(
                getter: (obj) => {
                return(this.Get(obj).a);
            },
                setter: (obj, value) => {
                var v = this.Get(obj);
                v.a   = value;
                this.Set(obj, v);
            }
                );

            rgb = new PropertyVector3Accesser <TObject>(
                getter: (obj) => {
                var color = this.Get(obj);
                return(new Vector3(color.r, color.g, color.b));
            },
                setter: (obj, value) => {
                var color = this.Get(obj);
                color.r   = value.x;
                color.g   = value.y;
                color.b   = value.z;
                this.Set(obj, color);
            }
                );
        }
Example #2
0
 public static TweenOperation Prepare(TObject target,PropertyAccesser<TObject,TValue> property, TValue from,TweenOptions options){
     var state = new State(){
         from = from,
         target = target,
         property = property
     };
     return TweenAction<State>.Prepare(state,options);          
 }
 /// <summary>
 /// 根据位置属性创建一个角度空间属性
 /// </summary>
 public static PropertyAccesser <TObject, float> Degree <TObject>(PropertyAccesser <TObject, Vector2> position, Vector2 center, float radius)
 {
     return(new PropertyAccesser <TObject, float>(
                setter: (obj, value) => {
         var x = Mathf.Cos(value * Mathf.Deg2Rad);
         var y = Mathf.Sin(value * Mathf.Deg2Rad);
         position.Set(obj, radius * new Vector2(x, y));
     },
                getter: (obj) => {
         var pos = position.Get(obj);
         var vec = pos - center;
         return Vector2.SignedAngle(Vector2.right, vec);
     }
                ));
 }
        public PropertyVector4Accesser(Getter getter, Setter setter) : base(getter, setter)
        {
            x = new PropertyAccesser <TObject, float>(
                getter: (obj) => {
                return(this.Get(obj).x);
            },
                setter: (obj, value) => {
                var v = this.Get(obj);
                v.x   = value;
                this.Set(obj, v);
            }
                );
            y = new PropertyAccesser <TObject, float>(
                getter: (obj) => {
                return(this.Get(obj).y);
            },
                setter: (obj, value) => {
                var v = this.Get(obj);
                v.y   = value;
                this.Set(obj, v);
            }
                );

            z = new PropertyAccesser <TObject, float>(
                getter: (obj) => {
                return(this.Get(obj).z);
            },
                setter: (obj, value) => {
                var v = this.Get(obj);
                v.z   = value;
                this.Set(obj, v);
            }
                );
            w = new PropertyAccesser <TObject, float>(
                getter: (obj) => {
                return(this.Get(obj).w);
            },
                setter: (obj, value) => {
                var v = this.Get(obj);
                v.w   = value;
                this.Set(obj, v);
            }
                );
        }
Example #5
0
 public TweenOperation Property <TObject>(TObject target, PropertyAccesser <TObject, TValue> property, float duration)
 {
     return(PropertyController.Prepare(target, property, delta, new TweenOptions(duration)));
 }
Example #6
0
 public TweenOperation Property <TObject>(TObject target, PropertyAccesser <TObject, TValue> property, TweenOptions options)
 {
     return(PropertyController.Prepare(target, property, delta, options));
 }
 /// <summary>
 /// 创建一个属性,代表与目标对象的距离. 其中TValue必须支持距离运算符
 /// </summary>
 public static PropertyAccesser <TObject, float> Distance <TObject, TValue>(TObject target, PropertyAccesser <TObject, TValue> property)
 {
     return(new PropertyAccesser <TObject, float>(
                setter: (source, value) => {
         var from = property.Get(source);
         var to = property.Get(target);
         var dis = ValueUtility.Distance(from, to);
         var resultValue = ValueUtility.Lerp(from, to, 1 - value / dis);
         property.Set(source, resultValue);
     },
                getter: (source) => {
         var from = property.Get(source);
         var to = property.Get(target);
         return ValueUtility.Distance(from, to);
     }
                ));
 }
Example #8
0
 public TweenOperation Property <TObject>(TObject target, PropertyAccesser <TObject, TValue> property, float duration)
 {
     return(Property <TObject>(target, property, new TweenOptions(duration)));
 }
Example #9
0
 public TweenOperation Property <TObject>(TObject target, PropertyAccesser <TObject, TValue> property)
 {
     return(Property <TObject>(target, property, 1));
 }
        public PropertyVector3Accesser(Getter getter, Setter setter) : base(getter, setter)
        {
            x = new PropertyAccesser <TObject, float>(
                getter: (obj) => {
                return(this.Get(obj).x);
            },
                setter: (obj, value) => {
                var v = this.Get(obj);
                v.x   = value;
                this.Set(obj, v);
            }
                );
            y = new PropertyAccesser <TObject, float>(
                getter: (obj) => {
                return(this.Get(obj).y);
            },
                setter: (obj, value) => {
                var v = this.Get(obj);
                v.y   = value;
                this.Set(obj, v);
            }
                );

            z = new PropertyAccesser <TObject, float>(
                getter: (obj) => {
                return(this.Get(obj).z);
            },
                setter: (obj, value) => {
                var v = this.Get(obj);
                v.z   = value;
                this.Set(obj, v);
            }
                );

            xy = new PropertyAccesser <TObject, Vector2>(
                getter: (obj) => {
                return((Vector2)this.Get(obj));;
            },
                setter: (obj, value) => {
                var v = this.Get(obj);
                v.x   = value.x;
                v.y   = value.y;
                this.Set(obj, v);
            }
                );
            yz = new PropertyAccesser <TObject, Vector2>(
                getter: (obj) => {
                var value = this.Get(obj);
                return(new Vector2(value.y, value.z));
            },
                setter: (obj, value) => {
                var v = this.Get(obj);
                v.y   = value.x;
                v.z   = value.y;
                this.Set(obj, v);
            }
                );
            xz = new PropertyAccesser <TObject, Vector2>(
                getter: (obj) => {
                var value = this.Get(obj);
                return(new Vector2(value.x, value.z));
            },
                setter: (obj, value) => {
                var v = this.Get(obj);
                v.x   = value.x;
                v.z   = value.y;
                this.Set(obj, v);
            }
                );
        }
Example #11
0
        public TweenOperation Property <TObject>(TObject target, PropertyAccesser <TObject, TValue> property, TweenOptions options)
        {
            var context = new TargetProperty <TObject, TValue>(target, property);

            return(this.Action(PropertyUpdateAction <TObject> .onUpdate, context, options));
        }