static int _e_quitDl(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); int gen_param_count = LuaAPI.lua_gettop(L); LuaMain gen_to_be_invoked = (LuaMain)translator.FastGetCSObj(L, 1); LuaMain.OnQuit gen_delegate = translator.GetDelegate <LuaMain.OnQuit>(L, 3); if (gen_delegate == null) { return(LuaAPI.luaL_error(L, "#3 need LuaMain.OnQuit!")); } if (gen_param_count == 3) { if (LuaAPI.xlua_is_eq_str(L, 2, "+")) { gen_to_be_invoked.quitDl += gen_delegate; return(0); } if (LuaAPI.xlua_is_eq_str(L, 2, "-")) { gen_to_be_invoked.quitDl -= gen_delegate; return(0); } } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } LuaAPI.luaL_error(L, "invalid arguments to LuaMain.quitDl!"); return(0); }
//public Player CurrentAttacker { set; get; } public void Init(Room ParentRoom) { Room = ParentRoom; LuaMain.Run(); PlayerList = Room.Groups.SelectMany(O => O.Participants).ToList(); ResortPlayerList(); PlayerList.ForEach(Player => Player.BattleData.Init(Player, this, Room.Groups.First(O => O.Participants.Contains(Player)))); LuaMain.LuaState["Battlefield"] = this; Record = new Record() { Id = Room.Id, Participants = PlayerList.Select(O => new Participant() { Id = O.Id, Name = O.Name, Avator = O.Avator, Group = O.BattleData.Group.Name, TotalDamage = 0, TotalInjured = 0 }).ToDictionary(O => O.Id, P => P), Time = DateTime.Now, Type = ParentRoom.BattleType }; Round = 0; }
static int _m_StartLua(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); LuaMain gen_to_be_invoked = (LuaMain)translator.FastGetCSObj(L, 1); { string _module = LuaAPI.lua_tostring(L, 2); string _function = LuaAPI.lua_tostring(L, 3); var gen_ret = gen_to_be_invoked.StartLua(_module, _function); LuaAPI.lua_pushboolean(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
private void Awake() { DontDestroyOnLoad(this.gameObject); Instance = this; ResMgr.Init(); LuaMain = LuaMain.getInstance(); }
static int _m_InitLuaEvn_xlua_st_(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); int gen_param_count = LuaAPI.lua_gettop(L); if (gen_param_count == 3 && translator.Assignable <UnityEngine.GameObject>(L, 1) && translator.Assignable <LuaMain.OnQuit>(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3)) { UnityEngine.GameObject _host = (UnityEngine.GameObject)translator.GetObject(L, 1, typeof(UnityEngine.GameObject)); LuaMain.OnQuit _cb = translator.GetDelegate <LuaMain.OnQuit>(L, 2); float _gcIns = (float)LuaAPI.lua_tonumber(L, 3); var gen_ret = LuaMain.InitLuaEvn(_host, _cb, _gcIns); translator.Push(L, gen_ret); return(1); } if (gen_param_count == 2 && translator.Assignable <UnityEngine.GameObject>(L, 1) && translator.Assignable <LuaMain.OnQuit>(L, 2)) { UnityEngine.GameObject _host = (UnityEngine.GameObject)translator.GetObject(L, 1, typeof(UnityEngine.GameObject)); LuaMain.OnQuit _cb = translator.GetDelegate <LuaMain.OnQuit>(L, 2); var gen_ret = LuaMain.InitLuaEvn(_host, _cb); translator.Push(L, gen_ret); return(1); } if (gen_param_count == 1 && translator.Assignable <UnityEngine.GameObject>(L, 1)) { UnityEngine.GameObject _host = (UnityEngine.GameObject)translator.GetObject(L, 1, typeof(UnityEngine.GameObject)); var gen_ret = LuaMain.InitLuaEvn(_host); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to LuaMain.InitLuaEvn!")); }
// Start is called before the first frame update void Start() { LuaMain luaenv = LuaMain.InitLuaEvn(this.gameObject, OnQuit, 1); string[] folds = { Application.dataPath + "/lualogic/lua/" , Application.dataPath + "/ReuseScript/lua/" }; luaenv.InitNormalFileLoader(folds); luaenv.StartLua("test_attach", "Main"); Debug.Log("load ok"); }
static public LuaMain InitLuaEvn(GameObject host, OnQuit cb = null, float gcIns = 1) { if (null == instance) { instance = host.AddComponent <LuaMain>(); instance.luaenv = new LuaEnv(); if (cb != null) { instance.quitDl += cb; } instance.GCInterval = gcIns; instance._customLoader = new LuaCustomLoader(); } return(instance); }
// Start is called before the first frame update void Start() { _logFile = new LogFile(); LuaMain luaenv = LuaMain.InitLuaEvn(this.gameObject, OnQuit, 1); string[] folds = { Application.dataPath + "/chat_prj/script/" , Application.dataPath + "/ReuseScript/lua/" }; luaenv.InitNormalFileLoader(folds); luaenv.StartLua("chat_test", "Main"); Debug.Log("load ok"); }
static int __CreateInstance(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); if (LuaAPI.lua_gettop(L) == 1) { var gen_ret = new LuaMain(); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to LuaMain constructor!")); }
static int _m_InitNormalFileLoader(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); LuaMain gen_to_be_invoked = (LuaMain)translator.FastGetCSObj(L, 1); { string[] _paths = (string[])translator.GetObject(L, 2, typeof(string[])); gen_to_be_invoked.InitNormalFileLoader(_paths); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
static int _m_InitZipLoader(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); LuaMain gen_to_be_invoked = (LuaMain)translator.FastGetCSObj(L, 1); { string _zipfile = LuaAPI.lua_tostring(L, 2); gen_to_be_invoked.InitZipLoader(_zipfile); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
// Start is called before the first frame update void Start() { _logFile = new LogFile(); LuaMain luaenv = LuaMain.InitLuaEvn(this.gameObject, OnQuit, 1); if (useZip) { string luazip = Application.streamingAssetsPath + "/core.zip"; luaenv.InitZipLoader(luazip); } else { string[] folds = { Application.dataPath + "/lualogic/lua/" , Application.dataPath + "/ReuseScript/lua/" }; luaenv.InitNormalFileLoader(folds); } luaenv.StartLua("main", "Main"); Debug.Log("load ok"); }
public void ExecuteLua(string code) { LuaMain.DoString(code); }
void Awake() { m_Main = this; InitResources(); }