public static Sprite3D LoadAsset(LuaTable el, ContentManager content) { var texture = content.Load<Texture2D>((string) el["assetName"]); var pos = el["pos"] as LuaTable; var ypr = el["yawpitchroll"] as LuaTable; var scale = el["scale"] as LuaTable; if (pos == null || ypr == null || scale == null) { throw new ContentLoadException(); } var asset = new Sprite3D( texture, null, TableToVector(pos), Quaternion.CreateFromYawPitchRoll((float) (double) ypr[1], (float) (double) ypr[2], (float) (double) ypr[3]), TableToVector(scale) ); var normalMap = el["normalMap"]; if (normalMap != null) asset.NormalMap = content.Load<Texture2D>((string) normalMap); return asset; }
public void PaymentCallback(string s) { #if UNITY_IOS && !UNITY_EDITOR JsonData jsonData = JsonMapper.ToObject(s); string base64Encoding = (string)jsonData["base64Encoding"]; string productIdentifier = (string)jsonData["productIdentifier"]; string transactionIdentifier = (string)jsonData["transactionIdentifier"]; string[] strs = productIdentifier.Split('_'); int id = 0; if (strs.Length > 1) { id = strs[1].ToInt32(); } /****** 此段为修复客户端表与app store商品ID不一致的问题所加 ******/ if (id == 26) { id = 105; } else if (id == 27) { id = 106; } /****** 此段为修复客户端表与app store商品ID不一致的问题所加 ******/ Debugger.Log("base64Encoding:" + base64Encoding); Debugger.Log("id:" + id); LuaInterface.LuaTable onlineGiftController = (LuaInterface.LuaTable)LuaInterface.LuaScriptMgr.Instance.CallLuaFunction("gamemanager.GetCtrl", "shop_controller")[0]; onlineGiftController.GetLuaFunction("AppStoreVerifyReq").Call(id, base64Encoding, transactionIdentifier); #endif }
/// <summary> /// 获取数据行 /// </summary> /// <param name="tablename">数据表名</param> /// <param name="keys">数据表主键</param> /// <param name="ltReturn">结果数据表</param> /// <returns>是否获取成功</returns> public bool GetDataTableRow(string tablename, LuaTable keys, ref LuaTable ltReturn) { string sql = string.Format("SELECT * FROM {0}", tablename); DataTable tbl = Helper.GetDataTable(sql, Conn); if (tbl.PrimaryKey.Length != keys.Keys.Count) { MessageBox.Show(string.Format("{0} —— 函数GetDataTableRow断言:{1}\r\n", DateTime.Now, "输入参数keys长度错误。")); } object[] KEYS = new object[tbl.PrimaryKey.Length]; for (int i = 0; i < KEYS.Length; i++) { KEYS[i] = ((LuaTable)keys)[i]; } DataRow row = tbl.Rows.Find(KEYS); if (row == null) { return false; } foreach (DataColumn col in tbl.Columns) { ltReturn[col.ColumnName] = (row[col.ColumnName] == DBNull.Value ? null : row[col.ColumnName]); } return true; }
static int GetLuaTable(IntPtr L) { int count = LuaDLL.lua_gettop(L); Type[] types0 = { typeof(IntPtr), typeof(int) }; Type[] types1 = { typeof(LuaScriptMgr), typeof(string) }; if (count == 2 && LuaScriptMgr.CheckTypes(L, types0, 1)) { IntPtr arg0 = (IntPtr)LuaScriptMgr.GetNumber(L, 1); int arg1 = (int)LuaScriptMgr.GetNumber(L, 2); LuaInterface.LuaTable o = LuaScriptMgr.GetLuaTable(arg0, arg1); LuaScriptMgr.Push(L, o); return(1); } else if (count == 2 && LuaScriptMgr.CheckTypes(L, types1, 1)) { LuaScriptMgr obj = LuaScriptMgr.GetNetObject <LuaScriptMgr>(L, 1); string arg0 = LuaScriptMgr.GetString(L, 2); LuaInterface.LuaTable o = obj.GetLuaTable(arg0); LuaScriptMgr.Push(L, o); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: LuaScriptMgr.GetLuaTable"); } return(0); }
private void OnConfirmExit(GameObject go) { GameSystem.Instance.mClient.pause = false; LuaInterface.LuaTable table = LuaScriptMgr.Instance.lua.NewTable(); table.Set("uiBack", (object)"UIHall"); LuaScriptMgr.Instance.CallLuaFunction("jumpToUI", new object[] { "UIPracticeCourt", null, table }); }
public void Request(string route, LuaInterface.LuaTable paramsTable, LuaInterface.LuaFunction func) { if (pc != null) { JsonObject msg = new JsonObject(); IEnumerator <DictionaryEntry> paramList = paramsTable.ToDictTable().GetEnumerator(); while (paramList.MoveNext()) { DictionaryEntry curr = paramList.Current; Debug.Log("key " + curr.Key + " value: " + curr.Value); msg[curr.Key.ToString()] = curr.Value; } pc.request(route, msg, (result) => { PomeloPackage pkg = new PomeloPackage(); if (func == null) { Debug.LogError("callback function is null!"); } pkg.luaFunc = func; pkg.ReturnData = result.ToString(); AddResultPackage(pkg); }); } else { Debug.LogError("Pomelo Client is null"); } }
public static Delegate CreateDelegate(Type t, LuaFunction func, LuaTable self) { DelegateValue Create = null; if (!dict.TryGetValue(t, out Create)) { throw new LuaException(string.Format("Delegate {0} not register", LuaMisc.GetTypeName(t))); } if (func != null) { LuaState state = func.GetLuaState(); LuaDelegate target = state.GetLuaDelegate(func, self); if (target != null) { return Delegate.CreateDelegate(t, target, target.method); } else { Delegate d = Create(func, self, true); target = d.Target as LuaDelegate; state.AddLuaDelegate(target, func, self); return d; } } return Create(func, self, true); }
static int Get(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.GameObject))) { UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.ToObject(L, 1); LuaInterface.LuaTable o = LuaBindSceneObj.Get(arg0); ToLua.Push(L, o); return(1); } else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.GameObject), typeof(LuaInterface.LuaTable))) { UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.ToObject(L, 1); LuaTable arg1 = ToLua.ToLuaTable(L, 2); LuaInterface.LuaTable o = LuaBindSceneObj.Get(arg0, arg1); ToLua.Push(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: LuaBindSceneObj.Get")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetFishLuaTable(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 1 && TypeChecker.CheckTypes <UnityEngine.Transform>(L, 1)) { UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.ToObject(L, 1); LuaInterface.LuaTable o = LuaTool.GetFishLuaTable(arg0); ToLua.Push(L, o); return(1); } else if (count == 1 && TypeChecker.CheckTypes <UnityEngine.GameObject>(L, 1)) { UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.ToObject(L, 1); LuaInterface.LuaTable o = LuaTool.GetFishLuaTable(arg0); ToLua.Push(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: LuaTool.GetFishLuaTable")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private static void Main() { Lua.DoFile(@"P:\XinFeiFei\gameres\addons\DefineText.lua"); Lua.DoFile(@"P:\XinFeiFei\gameres\addons\jobs.lua"); Lua.DoFile(@"P:\XinFeiFei\gameres\addons\propItem.lua"); ItemData = Lua.GetTable("propItem"); Console.WriteLine("Data loaded!"); Database = new FFModelContainer(ConfigurationManager.ConnectionStrings["FFModelContainer"].ConnectionString); AppDomain.CurrentDomain.ProcessExit += (EventHandler)((sender, args) => Database.SaveChanges()); new Thread(() => { while (Database != null) { Database.SaveChanges(); Thread.Sleep(Constants.DatabaseUpdateInterval); } }).Start(); var server = new TCPServer<FFConnection>(); server.Listen("127.0.0.1", 9111); }
public void Reload() { initialized = false; string script = resourcePath+ScriptName+".lua"; // will throw an exception on error... object[] res = L.DoFile (script); LuaTable env = (LuaTable)res[0]; // Poor man's OOP! These are all called on self //Debug.Log ("here"); if (env["Update"] != null || env["Start"] != null) AssignMethods (env); // the script may have an Init method, // which expects the object as an argument // and returns a table, otherwise we make // a new table with a 'this' field LuaFunction init = (LuaFunction)env["Init"]; if (init != null) { self = (LuaTable)(init.Call(this)[0]); } else { L.NewTable(ScriptName); self = (LuaTable)L[ScriptName]; self["this"] = this; } if (! initialized) AssignMethods(self); //Debug.Log ("here " + self.ToString ()); objects[gameObject] = self; }
public static string Export(LuaTable table, int indent) { StringBuilder sb = new StringBuilder(); List<DictionaryEntry> items = new List<DictionaryEntry>(); int maxlen = 0; bool allNumber = true; int cnt = 1; foreach (DictionaryEntry de in table) { items.Add(de); int len = de.Key.ToString().Length; if (len > maxlen) maxlen = len; if (!(de.Key is Double) || (int)(double)de.Key != cnt) allNumber = false; cnt++; } items.Sort(SortCompare); sb.Append("{\r\n"); string ind = GetIndentString(indent + 2); foreach (DictionaryEntry de in items) { if (de.Value is LuaTable) sb.AppendLine(); sb.Append(ind); FormatEntry(sb, maxlen, allNumber, indent, de); sb.Append(",\r\n"); if (de.Value is LuaTable) sb.AppendLine(); } ind = GetIndentString(indent); sb.Append(ind + "}"); return sb.ToString(); }
void Clear() { //_call = null; _add = null; _remove = null; self = null; luaState = null; }
public void ClickHeroComposeHandler() { // LuaInterface.LuaTable table = (LuaInterface.LuaTable)LuaInterface.LuaScriptMgr.Instance.CallLuaFunction("gamemanager.GetModel","consortia_model")[0]; // table.GetLuaFunction("OpenCreateConsortiaView").Call(); LuaInterface.LuaTable table = (LuaInterface.LuaTable)LuaInterface.LuaScriptMgr.Instance.CallLuaFunction("gamemanager.GetCtrl", "hero_controller")[0]; table.GetLuaFunction("OpenHeroComposeView").Call(); }
private void SafeRelease(ref LuaTable table) { if (table != null) { table.Dispose(); table = null; } }
public LuaTable storeRectInTable(System.Drawing.Rectangle r, LuaTable table) { table["x"] = r.X; table["y"] = r.Y; table["width"] = r.Width; table["height"] = r.Height; return table; }
static int ToLuaTable(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); MPObject obj = LuaScriptMgr.GetNetObject <MPObject>(L, 1); LuaInterface.LuaTable o = obj.ToLuaTable(); LuaScriptMgr.Push(L, o); return(1); }
public void LoadLuaTable(LuaTable reqs) { System.Collections.IEnumerator luatb = reqs.Values.GetEnumerator(); while (luatb.MoveNext()) { AddReqToQueue((CRequest)luatb.Current); } BeginQueue(); }
public uint Show(uint oldvalue, LuaTable nums, LuaTable texts) { Form1 frm = new Form1(oldvalue, nums, texts); DialogResult result = frm.ShowDialog(); if (result == DialogResult.OK) return frm.ret; else // cancel return oldvalue; }
static int getActivityLuaTable(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); DynamicStringManager obj = (DynamicStringManager)LuaScriptMgr.GetNetObjectSelf(L, 1, "DynamicStringManager"); LuaInterface.LuaTable o = obj.getActivityLuaTable(); LuaScriptMgr.Push(L, o); return(1); }
public static LuaFunction getTableFunction(LuaTable luaTable, string name) { object obj2 = luaTable.rawget(name); if (obj2 is LuaFunction) { return (LuaFunction) obj2; } return null; }
public void GetUIPrefab(string assetName, Transform parent, LuaTable luaTable, LuaFunction luaCallBack) { if (mResManager == null) return; string tmpAssetName = assetName; if (GameSetting.DevelopMode) { tmpAssetName = "UIPrefab/" + assetName; } mResManager.LoadPrefab(assetName + GameSetting.ExtName, tmpAssetName, delegate(UnityEngine.Object[] objs) { if (objs.Length == 0) return; GameObject prefab = objs[0] as GameObject; if (prefab == null) { return; } GameObject go = UnityEngine.GameObject.Instantiate(prefab) as GameObject; go.name = assetName; go.layer = LayerMask.NameToLayer("UI"); Vector3 anchorPos = Vector3.zero; Vector2 sizeDel = Vector2.zero; Vector3 scale = Vector3.one; RectTransform rtTr = go.GetComponent<RectTransform>(); if (rtTr != null) { anchorPos = rtTr.anchoredPosition; sizeDel = rtTr.sizeDelta; scale = rtTr.localScale; } go.transform.SetParent(parent, false); if (rtTr != null) { rtTr.anchoredPosition = anchorPos; rtTr.sizeDelta = sizeDel; rtTr.localScale = scale; } LuaBehaviour tmpBehaviour = go.AddComponent<LuaBehaviour>(); tmpBehaviour.Init(luaTable); if (luaCallBack != null) { luaCallBack.BeginPCall(); luaCallBack.Push(go); luaCallBack.PCall(); luaCallBack.EndPCall(); } Debug.Log("CreatePanel::>> " + assetName + " " + prefab); //mUIList.Add(go); }); }
static int GetList(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); FriendData obj = (FriendData)LuaScriptMgr.GetNetObjectSelf(L, 1, "FriendData"); fogs.proto.msg.FriendOperationType arg0 = (fogs.proto.msg.FriendOperationType)LuaScriptMgr.GetNetObject(L, 2, typeof(fogs.proto.msg.FriendOperationType)); LuaInterface.LuaTable o = obj.GetList(arg0); LuaScriptMgr.Push(L, o); return(1); }
protected LuaTable m_luaTable; // LuaTable public LuaCSBridgeByteBuffer() : base ("NetMsgData") //base("ByteBuffer") { string path = "LuaScript/DataStruct/NetMsgData.lua"; Ctx.m_instance.m_luaScriptMgr.DoFile(path); m_luaTable = Ctx.m_instance.m_luaScriptMgr.GetLuaTable(m_tableName); // 设置系统字节序 setSysEndian((int)SystemEndian.m_sEndian); }
//LuaFunction _call = null; public LuaEvent(LuaTable table) { self = table; luaState = table.GetLuaState(); self.AddRef(); _add = self.RawGetLuaFunction("Add"); _remove = self.RawGetLuaFunction("Remove"); //_call = self.RawGetLuaFunction("__call"); }
static int GetTable(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); IntPtr arg0 = (IntPtr)LuaScriptMgr.GetNumber(L, 1); int arg1 = (int)LuaScriptMgr.GetNumber(L, 2); LuaInterface.LuaTable o = LuaScriptMgr.GetTable(arg0, arg1); LuaScriptMgr.Push(L, o); return(1); }
static int GetListByType(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); int arg0 = (int)LuaScriptMgr.GetNumber(L, 1); object arg1 = LuaScriptMgr.GetVarObject(L, 2); LuaInterface.LuaTable o = CommonFunction.GetListByType(arg0, arg1); LuaScriptMgr.Push(L, o); return(1); }
public static List <object> Table2List(LuaInterface.LuaTable table) { List <object> list = new List <object>(); foreach (DictionaryEntry e in table) { list.Add(e.Value); } return(list); }
public static Delegate CreateDelegate(Type t, LuaFunction func, LuaTable self) { DelegateValue create = null; if (!dict.TryGetValue(t, out create)) { throw new LuaException(string.Format("Delegate {0} not register", LuaMisc.GetTypeName(t))); } return create(func, self, true); }
public void UnLink(CScriptObject scriptObj) { transform = null; luaTable = null; cacheObjs.Clear(); cacheObjs = null; cacheTrans.Clear(); cacheTrans = null; this.eventDispatcher.RemoveEvent(OnEvent); UnityEngine.Object.Destroy(this.eventDispatcher); }
public void LuaTableTest(LuaInterface.LuaTable table) { Debug.Log("LuaTableTest values is: " + table.Length); IEnumerator <DictionaryEntry> tmp = table.ToDictTable().GetEnumerator(); while (tmp.MoveNext()) { DictionaryEntry curr = tmp.Current; Debug.Log("key " + curr.Key + " value: " + curr.Value); } }
protected override void ValidateAndStore(LuaTable data) { try { gravity = (float) (double) data["gravity"]; } catch { throw new ArgumentException("Invalid unit description."); } }
static public int TableI(LuaInterface.LuaTable t, string k) { object ob = t[k]; if (ob == null) { return(0); } double db = (double)ob; return((int)db); }
// 根据表注册 UI 事件, LuaTable 的格式如下 luaTable {name="Panel_Name", BtnClickTable={"ui/click", "ui/tab"} ImageClickTable={"ui/click", "ui/tab"}} public void registerWidgetEventByTable(LuaTable luaTable) { m_form.formName = luaTable["name"] as string; LuaTable btnClickTable = luaTable["BtnClickTable"] as LuaTable; string[] btnArray = btnClickTable.ToArray<string>(); m_form.registerBtnClickEventByList(btnArray); // LuaTable imageClickTable = luaTable["ImageClickTable"] as LuaTable; // string[] imageArary = imageClickTable.ToArray<string>(); // m_form.registerImageClickEventByList(imageArary); }
public void ShowSpecifiedUI(string strUIName, uint param) { if (UICallList.ContainsKey(strUIName)) { UICallList[strUIName](param); } else { LuaInterface.LuaTable topPanelMgr = LuaScriptMgr.Instance.GetLuaTable("TopPanelManager"); LuaInterface.LuaFunction funcShowPanel = topPanelMgr["ShowPanel"] as LuaInterface.LuaFunction; funcShowPanel.Call(new object[] { topPanelMgr, strUIName, param }); } }
//LuaFunction _call = null; public LuaEvent(LuaTable table) { self = table; luaState = table.GetLuaState(); self.AddRef(); LuaTable meta = self.GetMetaTable(); _add = meta.RawGetLuaFunction("Add"); _remove = meta.RawGetLuaFunction("Remove"); meta.Dispose(); meta = null; //_call = self.RawGetLuaFunction("__call"); }
public void Dispose() { transform = null; luaTable = null; cacheObjs.Clear(); cacheObjs = null; cacheTrans.Clear(); cacheTrans = null; this.eventDispatcher.RemoveEvent(OnEvent); GameObject.Destroy(gameObject); }
void OnDestroy() { if (info.funcOnDestroy != null) { info.funcOnDestroy.Call(table); } table.Release(); table = null; LuaInterface.LuaTable topPanelMgr = LuaScriptMgr.Instance.GetLuaTable("TopPanelManager"); LuaInterface.LuaFunction SetLuaComNil = topPanelMgr["SetLuaComNil"] as LuaInterface.LuaFunction; SetLuaComNil.Call(new object[] { topPanelMgr, info.scriptName }); }
public void Link(GameObject obj, LuaInterface.LuaTable table) { this.gameObject = obj; this.eventDispatcher = this.gameObject.GetComponent <LuaGameObjectEventDispatcher>(); if (this.eventDispatcher == null) { this.eventDispatcher = this.gameObject.AddComponent <LuaGameObjectEventDispatcher>(); } this.transform = this.gameObject.transform; luaTable = table; this.eventDispatcher.AddEvent(OnEvent); SetLuaValue("CSharpObject", this); //lua可以通过CSharpObject直接访问到当前的对象 }
static int GetNewTable(IntPtr L) { try { ToLua.CheckArgsCount(L, 0); LuaInterface.LuaTable o = LuaHelper.GetNewTable(); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void Add(LuaFunction func, LuaTable obj) { if (func == null) { return; } _add.BeginPCall(); _add.Push(self); _add.Push(func); _add.Push(obj); _add.PCall(); _add.EndPCall(); }
static int QPYX_get_table_YXQP(IntPtr L_YXQP) { object QPYX_o_YXQP = null; try { QPYX_o_YXQP = ToLua.ToObject(L_YXQP, 1); UniWebViewMessage QPYX_obj_YXQP = (UniWebViewMessage)QPYX_o_YXQP; LuaInterface.LuaTable QPYX_ret_YXQP = QPYX_obj_YXQP.table; ToLua.Push(L_YXQP, QPYX_ret_YXQP); return(1); } catch (Exception QPYX_e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, QPYX_e_YXQP, QPYX_o_YXQP, "attempt to index table on a nil value")); } }
static int GetBagItemData(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); LuaTestMediator4 obj = (LuaTestMediator4)ToLua.CheckObject(L, 1, typeof(LuaTestMediator4)); LuaInterface.LuaTable o = obj.GetBagItemData(); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int TestLuaCallByLuaArrayTable(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); LuaTable arg0 = ToLua.CheckLuaTable(L, 1); LuaInterface.LuaTable o = GUtil.TestLuaCallByLuaArrayTable(arg0); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetLuaTable(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); LuaComponent obj = (LuaComponent)ToLua.CheckObject <LuaComponent>(L, 1); LuaInterface.LuaTable o = obj.GetLuaTable(); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetLuaTable(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); CLuaTableBehaviour obj = (CLuaTableBehaviour)ToLua.CheckObject<CLuaTableBehaviour>(L, 1); LuaInterface.LuaTable o = obj.GetLuaTable(); ToLua.Push(L, o); return 1; } catch (Exception e) { return LuaDLL.toluaL_exception(L, e); } }
static int RetrieveProxy(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); string arg0 = ToLua.CheckString(L, 1); LuaInterface.LuaTable o = LuaFacade.RetrieveProxy(arg0); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetInstance(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); FXGame.LuaBehaviour obj = (FXGame.LuaBehaviour)ToLua.CheckObject <FXGame.LuaBehaviour>(L, 1); LuaInterface.LuaTable o = obj.GetInstance(); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int getLuaScript(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); LuaFramework.LuaBehaviour obj = (LuaFramework.LuaBehaviour)ToLua.CheckObject(L, 1, typeof(LuaFramework.LuaBehaviour)); LuaInterface.LuaTable o = obj.getLuaScript(); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetLuaComponent(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject)); LuaInterface.LuaTable o = LuaComponent.GetLuaComponent(arg0); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
protected override void ValidateAndStore(LuaTable data) { base.ValidateAndStore(data); try { Speed = (float) (double) data["speed"]; AttackRange = (float) (double) data["attack_range"]; InitialHP = (int) (double) data["initial_hp"]; } catch { throw new ArgumentException("Invalid unit description."); } }
void RunLuaFile() { if (luaFile == null || string.IsNullOrEmpty(luaFile.text)) return; object[] luaRet = GameManager.Instance.LuaMgr.DoString(luaFile.text); if (luaRet != null && luaRet.Length >= 1) { this.LuaModule = luaRet[0] as LuaTable; this.LuaModule["gameObject"] = this.gameObject; this.LuaModule["transform"] = this.transform; } else { Debug.LogError("Lua脚本没有返回Table对象:" + luaFile.name); } }
protected override void ValidateAndStore(LuaTable data) { base.ValidateAndStore(data); try { var v = (LuaTable) data["velocity"]; _velocity = new Vector3((float) (double) v[1], (float) (double) v[2], (float) (double) v[3]); var a = (LuaTable) data["acceleration"]; _acc = new Vector3((float) (double) a[1], (float) (double) a[2], (float) (double) a[3]); _height = (float) (double) data["height"]; _range = (float) (double) data["range"]; } catch { throw new ArgumentException("Invalid unit description."); } }
/// <summary> /// 创建面板 /// </summary> IEnumerator StartCreatePanel(string name, AssetBundle bundle, LuaFunction func = null,LuaTable luaTable = null) { name += "Panel"; GameObject prefab = Util.LoadAsset(bundle, name); yield return new WaitForEndOfFrame(); if (Parent.FindChild(name) != null || prefab == null) { yield break; } GameObject go = Instantiate(prefab) as GameObject; go.name = name; go.layer = LayerMask.NameToLayer("Default"); go.transform.parent = Parent; go.transform.localScale = Vector3.one; go.transform.localPosition = Vector3.zero; yield return new WaitForEndOfFrame(); go.AddComponent<LuaBehaviour>().OnInit(bundle); if (func != null) func.Call(luaTable,go); Debug.Log("StartCreatePanel------>>>>" + name); }
/// <summary> /// 调用Lua虚拟机,执行一个脚本文件 /// </summary> void RunLuaFile(TextAsset luaFile) { if (luaFile == null || string.IsNullOrEmpty(luaFile.text)) return; if (s_luaState == null) { s_luaState = new LuaScriptMgr(); s_luaState.Start(); } object[] luaRet = s_luaState.DoString(luaFile.text); if (luaRet != null && luaRet.Length >= 1) { // 约定:第一个返回的Table对象作为Lua模块 this.LuaModule = luaRet[0] as LuaTable; } else { Debug.LogError("Lua脚本没有返回Table对象:" + luaFile.name); } }
public void Init(LuaTable tb) { mLuaState = SimpleLuaClient.GetMainState(); if (mLuaState == null) return; if (tb == null) { mLuaTable = mLuaState.GetTable(name); } else { mLuaTable = tb; } if (mLuaTable == null) { Debug.LogWarning("mLuaTable is null:" + name); return; } mLuaTable["gameObject"] = gameObject; mLuaTable["transform"] = transform; mLuaTable["lua_behaviour"] = this; LuaFunction awakeFunc = mLuaTable.GetLuaFunction("Awake") as LuaFunction; if (awakeFunc != null) { awakeFunc.BeginPCall(); awakeFunc.Push(mLuaTable); awakeFunc.PCall(); awakeFunc.EndPCall(); awakeFunc.Dispose(); awakeFunc = null; } mUpdateFunc = mLuaTable.GetLuaFunction("Update") as LuaFunction; mFixedUpdateFunc = mLuaTable.GetLuaFunction("FixedUpdate") as LuaFunction; mLateUpdateFunc = mLuaTable.GetLuaFunction("LateUpdate") as LuaFunction; }
public void SetLuaTable(LuaTable tb) { mLuaState = SimpleLuaClient.GetMainState(); if (mLuaState == null) return; if (tb == null) { mLuaTable = mLuaState.GetTable("NetworkManager"); } else { mLuaTable = tb; } if (mLuaTable == null) { Debug.LogWarning("NetworkManager is null:"); return; } else { mLuaOnSocketDataFunc = mLuaTable.GetLuaFunction("on_socket_data") as LuaFunction; } }
public void Remove(LuaFunction func, LuaTable obj) { if (func == null) { return; } _remove.BeginPCall(); _remove.Push(self); _remove.Push(func); _remove.Push(obj); _remove.PCall(); _remove.EndPCall(); }
public int Resume(object[] args, LuaTable env) { int result = 0; int oldTop = LuaDLL.lua_gettop(L); // If thread isn't started, it needs to be restarted if( start ) { start = false; func.push( L ); if (env != null) { env.push(L); LuaDLL.lua_setfenv(L, -2); } result = resume(args, oldTop); } // If thread is suspended, resume it else if( IsSuspended() ) { result = resume(args, oldTop); } return result; }
public ListDictionary GetTableDict(LuaTable table) { ListDictionary dict = new ListDictionary(); int oldTop = LuaDLL.lua_gettop(L); translator.push(L, table); LuaDLL.lua_pushnil(L); while (LuaDLL.lua_next(L, -2) != 0) { dict[translator.getObject(L, -2)] = translator.getObject(L, -1); LuaDLL.lua_settop(L, -2); } LuaDLL.lua_settop(L, oldTop); return dict; }