Example #1
0
        public static void Animation(this object o, string name, double n, uint frameCount, Action act = null)
        {
            Type          objType  = o.GetType();
            PropertyInfo  property = objType.GetProperty(name);
            AnimationBase ani      = null;

            if (property != null)
            {
                ani = new AnimationBaseProperty <double>(o, property, n, frameCount, AnimationFunc, act);
            }
            else
            {
                FieldInfo filed = objType.GetField(name);
                if (filed != null)
                {
                    ani = new AnimationBaseField <double>(o, filed, n, frameCount, AnimationFunc, act);
                }
            }

            AddAnimationBase(ani);
        }
Example #2
0
        public static void Animation <T>(this object o, string name, T n, uint frameCount, Action act = null)
        {
            Type tType   = typeof(T);
            Type objType = o.GetType();

            PropertyInfo property = objType.GetProperty(name, tType);

            AnimationBase ani = null;

            if (property != null)
            {
                if (tType == typeof(float))
                {
                    ani = new AnimationBaseProperty <float>(o, property,
                                                            (float)(object)n, frameCount, AnimationFunc, act);
                }
                else if (tType == typeof(double))
                {
                    ani = new AnimationBaseProperty <double>(o, property,
                                                             (double)(object)n, frameCount, AnimationFunc, act);
                }
                else if (tType == typeof(int))
                {
                    ani = new AnimationBaseProperty <int>(o, property,
                                                          (int)(object)n, frameCount, AnimationFunc, act);
                }
                else if (tType == typeof(Vector2d))
                {
                    ani = new AnimationBaseProperty <Vector2d>(o, property,
                                                               (Vector2d)(object)n, frameCount, AnimationFunc, act);
                }
                else if (tType == typeof(Vector3d))
                {
                    ani = new AnimationBaseProperty <Vector3d>(o, property,
                                                               (Vector3d)(object)n, frameCount, AnimationFunc, act);
                }
                else if (tType == typeof(Color))
                {
                    ani = new AnimationBaseProperty <Color>(o, property,
                                                            (Color)(object)n, frameCount, AnimationFunc, act);
                }
                else if (tType == typeof(Vector4))
                {
                    ani = new AnimationBaseProperty <Vector4>(o, property,
                                                              (Vector4)(object)n, frameCount, AnimationFunc, act);
                }
                else if (tType == typeof(Color4))
                {
                    ani = new AnimationBaseProperty <Color4>(o, property,
                                                             (Color4)(object)n, frameCount, AnimationFunc, act);
                }
                else if (tType == typeof(Matrix4))
                {
                    ani = new AnimationBaseProperty <Matrix4>(o, property,
                                                              (Matrix4)(object)n, frameCount, AnimationFunc, act);
                }
                else if (tType == typeof(Vector2))
                {
                    ani = new AnimationBaseProperty <Vector2>(o, property,
                                                              (Vector2)(object)n, frameCount, AnimationFunc, act);
                }
            }
            else
            {
                FieldInfo filed = objType.GetField(name);
                if (filed != null)
                {
                    if (tType == typeof(float))
                    {
                        ani = new AnimationBaseField <float>(o, filed,
                                                             (float)(object)n, frameCount, AnimationFunc, act);
                    }
                    else if (tType == typeof(double))
                    {
                        ani = new AnimationBaseField <double>(o, filed,
                                                              (double)(object)n, frameCount, AnimationFunc, act);
                    }
                    else if (tType == typeof(int))
                    {
                        ani = new AnimationBaseField <int>(o, filed,
                                                           (int)(object)n, frameCount, AnimationFunc, act);
                    }
                    else if (tType == typeof(Vector2d))
                    {
                        ani = new AnimationBaseField <Vector2d>(o, filed,
                                                                (Vector2d)(object)n, frameCount, AnimationFunc, act);
                    }
                    else if (tType == typeof(Vector3d))
                    {
                        ani = new AnimationBaseField <Vector3d>(o, filed,
                                                                (Vector3d)(object)n, frameCount, AnimationFunc, act);
                    }
                    else if (tType == typeof(Color))
                    {
                        ani = new AnimationBaseField <Color>(o, filed,
                                                             (Color)(object)n, frameCount, AnimationFunc, act);
                    }
                    else if (tType == typeof(Vector4))
                    {
                        ani = new AnimationBaseField <Vector4>(o, filed,
                                                               (Vector4)(object)n, frameCount, AnimationFunc, act);
                    }
                    else if (tType == typeof(Color4))
                    {
                        ani = new AnimationBaseField <Color4>(o, filed,
                                                              (Color4)(object)n, frameCount, AnimationFunc, act);
                    }
                    else if (tType == typeof(Matrix4))
                    {
                        ani = new AnimationBaseField <Matrix4>(o, filed,
                                                               (Matrix4)(object)n, frameCount, AnimationFunc, act);
                    }
                    else if (tType == typeof(Vector2))
                    {
                        ani = new AnimationBaseField <Vector2>(o, filed,
                                                               (Vector2)(object)n, frameCount, AnimationFunc, act);
                    }
                }
            }

            AddAnimationBase(ani);
        }