Exemple #1
0
 public MethodFind(ICLRSharp_Environment env, ICLRType type)
 {
     this.env           = env;
     this.DeclaringType = type;
     this.ReturnType    = env.GetType(typeof(GameObject));
     ParamList          = MethodParamList.Make(env.GetType(typeof(string)));
 }
Exemple #2
0
 public MethodCreatePrimitive(ICLRSharp_Environment env, ICLRType type)
 {
     this.env           = env;
     this.DeclaringType = type;
     this.ReturnType    = env.GetType(typeof(GameObject));
     ParamList          = MethodParamList.Make(env.GetType(typeof(PrimitiveType)));
 }
 public void Notify(eMonoMessageType mType, params object[] data)
 {
     callBack.Notify(mType, data);
     if (method_notify == null)
     {
         method_notify = class_type.GetMethod("Notify", MethodParamList.Make(LSharpModule.env.GetType(typeof(eMonoMessageType))));
     }
     method_notify.Invoke(ThreadContext.activeContext, inst, new object[] { mType });
 }
        public void SetShopType(ShopType type)
        {
            ICLRType type2  = this.mRunEnv.GetType("GUIScript.ShopCtrl");
            IMethod  method = type2.GetMethod("SetType", MethodParamList.Make(new ICLRType[]
            {
                this.mContext.environment.GetType(typeof(ShopType))
            }));

            method.Invoke(this.mContext, null, new object[]
            {
                type
            });
        }
        public void OpenWindow(WindowID winId)
        {
            ICLRType type   = this.mRunEnv.GetType("GUIScript.ShellClass");
            IMethod  method = type.GetMethod("OpenWindow", MethodParamList.Make(new ICLRType[]
            {
                this.mContext.environment.GetType(typeof(WindowID))
            }));

            method.Invoke(this.mContext, null, new object[]
            {
                winId
            });
        }
 private void Init()
 {
     if (class_name_L == "")
     {
         class_name_L = default_class_name;
         Debug.LogWarning("传入的L#类名为空,将使用L#基类进行绑定!");
     }
     class_type = LSharpModule.env.GetType(class_name_L);
     if (inst == null)
     {
         IMethod ctor = class_type.GetMethod(".ctor", MethodParamList.Make(LSharpModule.env.GetType(typeof(GameObject))));
         inst = ctor.Invoke(ThreadContext.activeContext, null, new object[] { gameObject });
     }
 }
Exemple #7
0
    public void InvokeScriptMethod(byte[] datas)
    {
        var    ot     = env.GetType("FlyModel.Proto.ClientMethod") as Type_Common_CLRSharp;
        int    opcode = BitConverter.ToInt32(datas, 0);
        string method = "";

        foreach (var f in ot.type_CLRSharp.Fields)
        {
            if (f.HasConstant && (int)f.Constant == opcode)
            {
                method = f.Name;
                break;
            }
        }
        Debug.Log("try invoke method " + method);
        var ms = commandType.GetMethods(method);

        if (ms.Length > 0)
        {
            var m = ms[0];
            if (m.Name == method)
            {
                if (m.ParamList.Count > 0)
                {
                    var pt     = m.ParamList[0];
                    var po     = new CLRSharp_Instance(pt as ICLRType_Sharp);
                    var ptctor = pt.GetMethod(".ctor", MethodParamList.constEmpty()); //取得构造函数
                    ptctor.Invoke(context, po, null);                                 //执行构造函数

                    paramArray[0] = po;
                    var ts = pt.GetMethod("ReadFrom", MethodParamList.Make(
                                              HotFixScript.env.GetType(typeof(byte[])),
                                              HotFixScript.env.GetType(typeof(int)),
                                              HotFixScript.env.GetType(typeof(int))
                                              ));
                    ts.Invoke(context, po, new object[] { datas, 4, datas.Length - 4 });

                    m.Invoke(context, null, paramArray);
                }
            }
        }
        else
        {
            Debug.LogError("Command " + method + " not found");
        }
    }
Exemple #8
0
 public static MainUIThread GetInstance()
 {
     if (ui == null)
     {
         ui = GameObject.FindObjectOfType(typeof(MainUIThread)) as MainUIThread;
         if (!ui)
         {
             GameObject obj = new GameObject("_MainUIThread");
             GameObject.DontDestroyOnLoad(obj);
             ui = obj.AddComponent <MainUIThread>();
             ICLRType program           = LSharpModule.env.GetType("GameUI.Program");
             IMethod  main              = program.GetMethod("GetInstance", MethodParamList.constEmpty());
             object   program_object    = main.Invoke(ThreadContext.activeContext, null, null);
             IMethod  method_AddNotifys = program.GetMethod("AddNotifys", MethodParamList.Make(LSharpModule.env.GetType(typeof(MainUIThread))));
             method_AddNotifys.Invoke(ThreadContext.activeContext, program_object, new object[] { ui });
         }
     }
     return(ui);
 }
Exemple #9
0
            /// <summary>
            /// 构造函数只是为了把脚本实例传进来,用其他的形式也可以
            /// </summary>
            /// <param name="inst"></param>
            public Base_IMyType(CLRSharp.CLRSharp_Instance inst)
            {
                var context = ThreadContext.activeContext;

                this.inst = inst;
                //这里先把需要的脚本方法记下来,只是为了后面调用起来方便
                var ms = this.inst.type.GetMethodNames();

                foreach (string name in ms)
                {
                    if (name.Contains("GetName"))
                    {
                        _GetName = this.inst.type.GetMethod(name, MethodParamList.constEmpty());
                    }
                    if (name.Contains("GetDesc"))
                    {
                        _GetDesc = this.inst.type.GetMethod(name, MethodParamList.constEmpty());
                    }
                    if (name.Contains("SetName"))
                    {
                        _SetName = this.inst.type.GetMethod(name, MethodParamList.Make(context.environment.GetType(typeof(string))));
                    }
                }
            }
            public Base_IMyType(CLRSharp_Instance inst)
            {
                ThreadContext activeContext = ThreadContext.activeContext;

                this.inst = inst;
                string[] methodNames = this.inst.type.GetMethodNames();
                string[] array       = methodNames;
                for (int i = 0; i < array.Length; i++)
                {
                    string text = array[i];
                    if (text.Contains("get_transform"))
                    {
                        this._get_transform = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("get_gameObject"))
                    {
                        this._get_gameobject = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("get_WinResCfg"))
                    {
                        this._get_WinResCfg = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("get_uiWindow"))
                    {
                        this._get_uiWindow = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("set_uiWindow"))
                    {
                        this._set_uiWindow = this.inst.type.GetMethod(text, MethodParamList.Make(new ICLRType[]
                        {
                            activeContext.environment.GetType(typeof(TUIWindow))
                        }));
                    }
                    if (text.Contains("Init"))
                    {
                        this._Init = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("Destroy"))
                    {
                        this._Destroy = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("HandleAfterOpenView"))
                    {
                        this._HandleAfterOpenView = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("HandleBeforeCloseView"))
                    {
                        this._HandleBeforeCloseView = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("RegisterUpdateHandler"))
                    {
                        this._RegisterUpdateHandler = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("CancelUpdateHandler"))
                    {
                        this._CancelUpdateHandler = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("RefreshUI"))
                    {
                        this._RefreshUI = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("DataUpdated"))
                    {
                        this._DataUpdated = this.inst.type.GetMethod(text, MethodParamList.Make(new ICLRType[]
                        {
                            activeContext.environment.GetType(typeof(object))
                        }));
                    }
                    if (text.Contains("Initialize"))
                    {
                        this._Initialize = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("HandleHideEvent"))
                    {
                        this._HandleHideEvent = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("HandleDestroyEvent"))
                    {
                        this._HandleDestroyEvent = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                }
            }