public FreedomEffect(Type clazz, int count_0, int limit, int x_1, int y_2, int w, int h) { this.visible = true; this.tex2ds = new List <LTexture>(10); this.SetLocation(x_1, y_2); this.width = w; this.height = h; this.count = count_0; this.timer = new LTimer(80); this.kernels = (IKernel[])Arrays.NewInstance(clazz, count_0); try { System.Reflection.ConstructorInfo constructor = JavaRuntime.GetConstructor(clazz, new Type[] { typeof(int), typeof(int), typeof(int) }); for (int i = 0; i < count_0; i++) { int no = MathUtils.Random(0, limit); kernels[i] = (IKernel)JavaRuntime.Invoke(constructor, new object[] { ((int)(no)), ((int)(w)), ((int)(h)) }); } } catch (Exception e) { Console.Error.WriteLine(e.StackTrace); } }
/// <summary> /// 以反射方式,尝试通过Application读取数据 /// </summary> /// <param name="pathUri"></param> /// <returns></returns> public static System.IO.Stream ApplicationResourceStream(Uri pathUri) { if (!supportApplication) { return(null); } try { if (appType == null) { try { appType = JavaRuntime.ClassforName("System.Windows.Application"); supportApplication = true; } catch { supportApplication = false; } } object o = JavaRuntime.NewInstance(appType); System.Reflection.MethodInfo method = JavaRuntime.GetMethod(appType, "GetResourceStream", pathUri.GetType()); object res = JavaRuntime.Invoke(method, o, pathUri); if (res != null) { System.Reflection.MethodInfo info = res.GetType().GetMethod("get_Stream"); object open = JavaRuntime.Invoke(info, res); return(open as System.IO.Stream); } } catch { } return(null); }
public void CallPos(float x, float y) { switch (type) { case 0: try { if (isBindPos) { if (methods != null) { if (methods[1] != null) { JavaRuntime.Invoke(methods[0], obj, x); JavaRuntime.Invoke(methods[1], obj, y); } else { JavaRuntime.Invoke(methods[0], obj, x, y); } } } } catch (Exception ex) { Log.Exception(ex); } break; case 1: if (actorObject != null) { actorObject.SetLocation((int)x, (int)y); } break; case 2: if (shapeObject != null) { shapeObject.SetLocation(x, y); } break; case 3: if (compObject != null) { compObject.SetLocation(x, y); } break; case 4: if (lObject != null) { lObject.SetLocation(x, y); } break; } }
public float GetRotation() { switch (type) { case 0: try { if (isBindGetRotation) { if (methods != null) { if (methods[6] != null) { Object o = JavaRuntime.Invoke(methods[6], obj); if (o is Single) { return((Single)o); } else if (o is Int32) { return((Int32)o); } } } } } catch (Exception ex) { Log.Exception(ex); } break; case 1: if (actorObject != null) { return(actorObject.GetRotation()); } break; case 2: if (shapeObject != null) { return(shapeObject.GetRotation()); } break; case 4: if (lObject != null) { return(lObject.GetRotation()); } break; } return(0); }
public void CallUpdate(long elapsedTime) { switch (type) { case 0: try { if (isBindUpdate) { if (methods != null) { if (methods[3] != null) { JavaRuntime.Invoke(methods[3], obj, elapsedTime); } } } } catch (Exception ex) { Log.Exception(ex); } break; case 1: if (actorObject != null) { actorObject.Action(elapsedTime); } break; case 3: if (compObject != null) { compObject.Update(elapsedTime); } break; case 4: if (lObject != null) { lObject.Update(elapsedTime); } break; } }
public void CallRotation(float r) { switch (type) { case 0: try { if (isBindRotation) { if (methods != null) { if (methods[2] != null) { JavaRuntime.Invoke(methods[2], obj, r); } } } } catch (Exception ex) { Log.Exception(ex); } break; case 1: if (actorObject != null) { actorObject.SetRotation(r); } break; case 2: if (shapeObject != null) { shapeObject.SetRotation(r); } break; case 4: if (lObject != null) { lObject.SetRotation(r); } break; } }
public void CallScale(float scaleX, float scaleY) { switch (type) { case 0: try { if (isBindScale) { if (methods != null) { if (methods[5] != null) { JavaRuntime.Invoke(methods[4], obj, scaleX); JavaRuntime.Invoke(methods[5], obj, scaleY); } else { JavaRuntime.Invoke(methods[4], obj, scaleX, scaleY); } } } } catch (Exception ex) { Log.Exception(ex); } break; case 1: if (actorObject != null) { actorObject.SetScale(scaleX, scaleY); } break; case 2: if (shapeObject != null) { shapeObject.SetScale(scaleX, scaleY); } break; } }
public void Register(LSetting setting, Type clazz, params object[] args) { MaxScreen(setting.width, setting.height); Initialization(setting.landscape, setting.mode); SetShowFPS(setting.showFPS); SetShowMemory(setting.showMemory); SetShowLogo(setting.showLogo); SetFPS(setting.fps); if (GamePage != null) { GamePage.Title = setting.title; } if (clazz != null) { if (args != null) { try { int funs = args.Length; if (funs == 0) { SetScreen((Screen)JavaRuntime.NewInstance(clazz)); ShowScreen(); } else { Type[] functions = new Type[funs]; for (int i = 0; i < funs; i++) { functions[i] = GetType(args[i]); } System.Reflection.ConstructorInfo constructor = JavaRuntime.GetConstructor(clazz, functions); Object o = JavaRuntime.Invoke(constructor, args); } } catch (Exception ex) { Log.Exception(ex); } } } }
public void Register(LSetting setting, Type clazz, params object[] args) { XNAConfig.Load(); SetShowFPS(setting.showFPS); SetShowMemory(setting.showMemory); SetShowLogo(setting.showLogo); SetFPS(setting.fps); if (clazz != null) { if (args != null) { try { int funs = args.Length; if (funs == 0) { SetScreen((Screen)JavaRuntime.NewInstance(clazz)); ShowScreen(); } else { Type[] functions = new Type[funs]; for (int i = 0; i < funs; i++) { functions[i] = GetType(args[i]); } System.Reflection.ConstructorInfo constructor = JavaRuntime.GetConstructor(clazz, functions); object o = JavaRuntime.Invoke(constructor, args); } } catch (Exception ex) { Loon.Utils.Debug.Log.Exception(ex); } } } }
/// <summary> /// 注册指定对象中指定名称函数为指定数值 /// </summary> /// /// <param name="object"></param> /// <param name="beanProperty"></param> /// <param name="value"></param> private static void Register(object obj0, string beanProperty, string value_ren) { object[] beanObject = Bind(obj0.GetType(), beanProperty); object[] cache = new object[1]; MethodInfo getter = (MethodInfo)beanObject[0]; MethodInfo setter = (MethodInfo)beanObject[1]; try { string methodType = getter.ReturnType.FullName; if (methodType.Equals("long", StringComparison.InvariantCultureIgnoreCase)) { cache[0] = Int64.Parse(value_ren); JavaRuntime.Invoke(setter, obj0, cache); } else if (methodType.Equals("int", StringComparison.InvariantCultureIgnoreCase) || methodType.Equals("integer", StringComparison.InvariantCultureIgnoreCase)) { cache[0] = Int32.Parse(value_ren); JavaRuntime.Invoke(setter, obj0, cache); } else if (methodType.Equals("short", StringComparison.InvariantCultureIgnoreCase)) { cache[0] = Int16.Parse(value_ren); JavaRuntime.Invoke(setter, obj0, cache); } else if (methodType.Equals("float", StringComparison.InvariantCultureIgnoreCase)) { cache[0] = Single.Parse(value_ren); JavaRuntime.Invoke(setter, obj0, cache); } else if (methodType.Equals("double", StringComparison.InvariantCultureIgnoreCase)) { cache[0] = Double.Parse(value_ren); JavaRuntime.Invoke(setter, obj0, cache); } else if (methodType.Equals("bool", StringComparison.InvariantCultureIgnoreCase) || methodType.Equals("boolean", StringComparison.InvariantCultureIgnoreCase)) { cache[0] = Boolean.Parse(value_ren); JavaRuntime.Invoke(setter, obj0, cache); } else if (methodType.Equals("string", StringComparison.InvariantCultureIgnoreCase)) { cache[0] = value_ren; JavaRuntime.Invoke(setter, obj0, cache); } else if (methodType.Equals("stream", StringComparison.InvariantCultureIgnoreCase)) { } else if (methodType.Equals("char", StringComparison.InvariantCultureIgnoreCase)) { cache[0] = (((char)value_ren[0])); JavaRuntime.Invoke(setter, obj0, cache); } } catch (Exception ex) { throw new Exception(beanProperty + " is " + ex.Message); } }
public int GetHeight() { switch (type) { case 0: try { if (isBindSize) { if (methods != null) { if (methods[10] != null) { Object o = JavaRuntime.Invoke(methods[10], obj); if (o is Single) { return(System.Convert.ToInt32(((Single)o))); } else if (o is Int32) { return((Int32)o); } } } } } catch (Exception ex) { Log.Exception(ex); } break; case 1: if (actorObject != null) { return(actorObject.GetHeight()); } break; case 2: if (shapeObject != null) { return((int)shapeObject.GetHeight()); } break; case 3: if (compObject != null) { return(compObject.GetHeight()); } break; case 4: if (lObject != null) { return(lObject.GetHeight()); } break; } return(0); }