示例#1
0
文件: Bind.cs 项目: vb0067/LGame
 public Bind(Object o)
 {
     if (o is Actor)
     {
         type                   = 1;
         actorObject            = (Actor)o;
         this.isBindPos         = true;
         this.isBindGetPos      = true;
         this.isBindRotation    = true;
         this.isBindGetRotation = true;
         this.isBindUpdate      = true;
         this.isBindScale       = true;
         this.isBindSize        = true;
     }
     else if (o is Shape)
     {
         type                   = 2;
         shapeObject            = (Shape)o;
         this.isBindPos         = true;
         this.isBindGetPos      = true;
         this.isBindRotation    = true;
         this.isBindGetRotation = true;
         this.isBindUpdate      = false;
         this.isBindScale       = true;
         this.isBindSize        = true;
     }
     else if (o is LComponent)
     {
         type                   = 3;
         compObject             = (LComponent)o;
         this.isBindPos         = true;
         this.isBindGetPos      = true;
         this.isBindRotation    = false;
         this.isBindGetRotation = false;
         this.isBindUpdate      = true;
         this.isBindScale       = false;
         this.isBindSize        = true;
     }
     else if (o is LObject)
     {
         type                   = 4;
         lObject                = (LObject)o;
         this.isBindPos         = true;
         this.isBindGetPos      = true;
         this.isBindRotation    = true;
         this.isBindGetRotation = true;
         this.isBindUpdate      = true;
         this.isBindScale       = false;
         this.isBindSize        = true;
     }
     else
     {
         type = 0;
         Bind.BindObject obj0 = BindClass(this.obj = o);
         this.methods           = obj0.methods;
         this.isBindPos         = obj0.bindPos;
         this.isBindGetPos      = obj0.bindGetPos;
         this.isBindRotation    = obj0.bindRotation;
         this.isBindGetRotation = obj0.bindGetRotation;
         this.isBindUpdate      = obj0.bindUpdate;
         this.isBindScale       = obj0.bindScale;
         this.isBindSize        = obj0.bindSize;
     }
 }
示例#2
0
        private static Bind.BindObject BindClass(Object o)
        {
            Bind.BindObject result;
            Type clazz = o.GetType();

            if (methodList == null)
            {
                methodList = new Dictionary<Type, BindObject>(10);
            }
            result = (BindObject)CollectionUtils.Get(methodList, clazz);

            if (result == null)
            {
                result = new Bind.BindObject(new MethodInfo[11]);
                try
                {
                    MethodInfo setX = JavaRuntime.GetMethod(clazz, "SetX", typeof(float));
                    MethodInfo setY = JavaRuntime.GetMethod(clazz, "SetY", typeof(float));
                    result.methods[0] = setX;
                    result.methods[1] = setY;
                    result.bindPos = true;

                }
                catch (Exception e)
                {
                    Log.Exception(e);
                    result.bindPos = false;
                }
                if (result.bindPos)
                {
                    try
                    {
                        MethodInfo getX = JavaRuntime.GetMethod(clazz, "GetX");
                        MethodInfo getY = JavaRuntime.GetMethod(clazz, "GetY");
                        result.methods[7] = getX;
                        result.methods[8] = getY;
                        result.bindGetPos = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindGetPos = false;
                    }
                }
                if (result.bindPos && !result.bindGetPos)
                {
                    try
                    {
                        MethodInfo getX_1 = JavaRuntime.GetMethod(clazz, "X");
                        MethodInfo getY_2 = JavaRuntime.GetMethod(clazz, "Y");
                        result.methods[7] = getX_1;
                        result.methods[8] = getY_2;
                        result.bindGetPos = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindGetPos = false;
                    }
                }
                if (!result.bindPos)
                {
                    try
                    {
                        MethodInfo setX_4 = JavaRuntime.GetMethod(clazz, "SetX", typeof(int));
                        MethodInfo setY_5 = JavaRuntime.GetMethod(clazz, "SetY", typeof(int));
                        result.methods[0] = setX_4;
                        result.methods[1] = setY_5;
                        result.bindPos = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindPos = false;
                    }
                }
                if (!result.bindPos)
                {
                    try
                    {
                        MethodInfo location = JavaRuntime.GetMethod(clazz, "SetLocation", typeof(float));
                        result.methods[0] = location;
                        result.bindPos = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindPos = false;
                    }
                }
                if (!result.bindPos)
                {
                    try
                    {
                        MethodInfo location_8 = JavaRuntime.GetMethod(clazz, "SetLocation", typeof(int));
                        result.methods[0] = location_8;
                        result.bindPos = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindPos = false;
                    }
                }
                if (!result.bindPos)
                {
                    try
                    {
                        MethodInfo location_10 = JavaRuntime.GetMethod(clazz, "SetPosition", typeof(float));
                        result.methods[0] = location_10;
                        result.bindPos = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindPos = false;
                    }
                }
                if (!result.bindPos)
                {
                    try
                    {
                        MethodInfo location_12 = JavaRuntime.GetMethod(clazz, "SetPosition", typeof(int));
                        result.methods[0] = location_12;
                        result.bindPos = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindPos = false;
                    }
                }
                try
                {
                    MethodInfo rotation = JavaRuntime.GetMethod(clazz, "SetRotation", typeof(float));
                    result.methods[2] = rotation;
                    result.bindRotation = true;
                }
                catch (Exception ex)
                {
                    Log.Exception(ex);
                    result.bindRotation = false;
                }
                if (result.bindRotation)
                {
                    try
                    {
                        MethodInfo getRotation = JavaRuntime.GetMethod(clazz, "GetRotation");
                        result.methods[6] = getRotation;
                        result.bindGetRotation = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindGetRotation = false;
                    }
                }
                if (!result.bindRotation)
                {
                    try
                    {
                        MethodInfo rotation_16 = JavaRuntime.GetMethod(clazz, "SetRotation", typeof(int));
                        result.methods[2] = rotation_16;
                        result.bindRotation = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindRotation = false;
                    }
                }
                if (!result.bindRotation)
                {
                    try
                    {
                        MethodInfo rotation_18 = JavaRuntime.GetMethod(clazz, "SetAngle", typeof(float));
                        result.methods[2] = rotation_18;
                        result.bindRotation = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindRotation = false;
                    }
                }
                if (result.bindRotation && !result.bindGetRotation)
                {
                    try
                    {
                        MethodInfo getRotation_20 = JavaRuntime.GetMethod(clazz, "GetAngle");
                        result.methods[6] = getRotation_20;
                        result.bindGetRotation = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindGetRotation = false;
                    }
                }
                if (!result.bindRotation)
                {
                    try
                    {
                        MethodInfo rotation_22 = JavaRuntime.GetMethod(clazz, "SetAngle", typeof(int));
                        result.methods[2] = rotation_22;
                        result.bindRotation = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindRotation = false;
                    }
                }
                try
                {
                    MethodInfo update = JavaRuntime.GetMethod(clazz, "Update", typeof(long));
                    result.methods[3] = update;
                    result.bindUpdate = true;

                }
                catch (Exception ex)
                {
                    Log.Exception(ex);
                    result.bindUpdate = false;
                }
                try
                {
                    MethodInfo setScaleX = JavaRuntime.GetMethod(clazz, "SetScaleX", typeof(float));
                    MethodInfo setScaleY = JavaRuntime.GetMethod(clazz, "SetScaleY", typeof(float));
                    result.methods[4] = setScaleX;
                    result.methods[5] = setScaleY;
                    result.bindScale = true;
                }
                catch (Exception ex)
                {
                    Log.Exception(ex);
                    result.bindScale = false;
                }
                if (!result.bindScale)
                {
                    try
                    {
                        MethodInfo scale = JavaRuntime.GetMethod(clazz, "SetScale", typeof(float));
                        result.methods[4] = scale;
                        result.bindScale = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindScale = false;
                    }
                }
                try
                {
                    MethodInfo width = JavaRuntime.GetMethod(clazz, "GetWidth");
                    MethodInfo height = JavaRuntime.GetMethod(clazz, "GetHeight");
                    result.methods[9] = width;
                    result.methods[10] = height;
                    result.bindSize = true;
                }
                catch (Exception ex)
                {
                    Log.Exception(ex);
                    result.bindSize = false;
                }
                CollectionUtils.Put(methodList, clazz, result);
            }
            return result;
        }
示例#3
0
文件: Bind.cs 项目: vb0067/LGame
        private static Bind.BindObject BindClass(Object o)
        {
            Bind.BindObject result;
            Type            clazz = o.GetType();

            if (methodList == null)
            {
                methodList = new Dictionary <Type, BindObject>(10);
            }
            result = (BindObject)CollectionUtils.Get(methodList, clazz);

            if (result == null)
            {
                result = new Bind.BindObject(new MethodInfo[11]);
                try
                {
                    MethodInfo setX = JavaRuntime.GetMethod(clazz, "SetX", typeof(float));
                    MethodInfo setY = JavaRuntime.GetMethod(clazz, "SetY", typeof(float));
                    result.methods[0] = setX;
                    result.methods[1] = setY;
                    result.bindPos    = true;
                }
                catch (Exception e)
                {
                    Log.Exception(e);
                    result.bindPos = false;
                }
                if (result.bindPos)
                {
                    try
                    {
                        MethodInfo getX = JavaRuntime.GetMethod(clazz, "GetX");
                        MethodInfo getY = JavaRuntime.GetMethod(clazz, "GetY");
                        result.methods[7] = getX;
                        result.methods[8] = getY;
                        result.bindGetPos = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindGetPos = false;
                    }
                }
                if (result.bindPos && !result.bindGetPos)
                {
                    try
                    {
                        MethodInfo getX_1 = JavaRuntime.GetMethod(clazz, "X");
                        MethodInfo getY_2 = JavaRuntime.GetMethod(clazz, "Y");
                        result.methods[7] = getX_1;
                        result.methods[8] = getY_2;
                        result.bindGetPos = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindGetPos = false;
                    }
                }
                if (!result.bindPos)
                {
                    try
                    {
                        MethodInfo setX_4 = JavaRuntime.GetMethod(clazz, "SetX", typeof(int));
                        MethodInfo setY_5 = JavaRuntime.GetMethod(clazz, "SetY", typeof(int));
                        result.methods[0] = setX_4;
                        result.methods[1] = setY_5;
                        result.bindPos    = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindPos = false;
                    }
                }
                if (!result.bindPos)
                {
                    try
                    {
                        MethodInfo location = JavaRuntime.GetMethod(clazz, "SetLocation", typeof(float));
                        result.methods[0] = location;
                        result.bindPos    = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindPos = false;
                    }
                }
                if (!result.bindPos)
                {
                    try
                    {
                        MethodInfo location_8 = JavaRuntime.GetMethod(clazz, "SetLocation", typeof(int));
                        result.methods[0] = location_8;
                        result.bindPos    = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindPos = false;
                    }
                }
                if (!result.bindPos)
                {
                    try
                    {
                        MethodInfo location_10 = JavaRuntime.GetMethod(clazz, "SetPosition", typeof(float));
                        result.methods[0] = location_10;
                        result.bindPos    = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindPos = false;
                    }
                }
                if (!result.bindPos)
                {
                    try
                    {
                        MethodInfo location_12 = JavaRuntime.GetMethod(clazz, "SetPosition", typeof(int));
                        result.methods[0] = location_12;
                        result.bindPos    = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindPos = false;
                    }
                }
                try
                {
                    MethodInfo rotation = JavaRuntime.GetMethod(clazz, "SetRotation", typeof(float));
                    result.methods[2]   = rotation;
                    result.bindRotation = true;
                }
                catch (Exception ex)
                {
                    Log.Exception(ex);
                    result.bindRotation = false;
                }
                if (result.bindRotation)
                {
                    try
                    {
                        MethodInfo getRotation = JavaRuntime.GetMethod(clazz, "GetRotation");
                        result.methods[6]      = getRotation;
                        result.bindGetRotation = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindGetRotation = false;
                    }
                }
                if (!result.bindRotation)
                {
                    try
                    {
                        MethodInfo rotation_16 = JavaRuntime.GetMethod(clazz, "SetRotation", typeof(int));
                        result.methods[2]   = rotation_16;
                        result.bindRotation = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindRotation = false;
                    }
                }
                if (!result.bindRotation)
                {
                    try
                    {
                        MethodInfo rotation_18 = JavaRuntime.GetMethod(clazz, "SetAngle", typeof(float));
                        result.methods[2]   = rotation_18;
                        result.bindRotation = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindRotation = false;
                    }
                }
                if (result.bindRotation && !result.bindGetRotation)
                {
                    try
                    {
                        MethodInfo getRotation_20 = JavaRuntime.GetMethod(clazz, "GetAngle");
                        result.methods[6]      = getRotation_20;
                        result.bindGetRotation = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindGetRotation = false;
                    }
                }
                if (!result.bindRotation)
                {
                    try
                    {
                        MethodInfo rotation_22 = JavaRuntime.GetMethod(clazz, "SetAngle", typeof(int));
                        result.methods[2]   = rotation_22;
                        result.bindRotation = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindRotation = false;
                    }
                }
                try
                {
                    MethodInfo update = JavaRuntime.GetMethod(clazz, "Update", typeof(long));
                    result.methods[3] = update;
                    result.bindUpdate = true;
                }
                catch (Exception ex)
                {
                    Log.Exception(ex);
                    result.bindUpdate = false;
                }
                try
                {
                    MethodInfo setScaleX = JavaRuntime.GetMethod(clazz, "SetScaleX", typeof(float));
                    MethodInfo setScaleY = JavaRuntime.GetMethod(clazz, "SetScaleY", typeof(float));
                    result.methods[4] = setScaleX;
                    result.methods[5] = setScaleY;
                    result.bindScale  = true;
                }
                catch (Exception ex)
                {
                    Log.Exception(ex);
                    result.bindScale = false;
                }
                if (!result.bindScale)
                {
                    try
                    {
                        MethodInfo scale = JavaRuntime.GetMethod(clazz, "SetScale", typeof(float));
                        result.methods[4] = scale;
                        result.bindScale  = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                        result.bindScale = false;
                    }
                }
                try
                {
                    MethodInfo width  = JavaRuntime.GetMethod(clazz, "GetWidth");
                    MethodInfo height = JavaRuntime.GetMethod(clazz, "GetHeight");
                    result.methods[9]  = width;
                    result.methods[10] = height;
                    result.bindSize    = true;
                }
                catch (Exception ex)
                {
                    Log.Exception(ex);
                    result.bindSize = false;
                }
                CollectionUtils.Put(methodList, clazz, result);
            }
            return(result);
        }