Inheritance: MonoBehaviour
コード例 #1
0
ファイル: LuaManager.cs プロジェクト: huiguochen/Lua4Net
        private static int AddGlobalObject(LuaManager Instance,IntPtr l)
        {
            // get method arguments
                  int objId = (int)LuaApi.lua_tonumber(l,3);
                  Object obj = LuaManager.Instance.GetObjectT<Object>(objId);

                  // call method
                  Int32 methodRetVar = Instance.AddHeapObject(obj);

                  LuaApi.lua_pushnumber(l,methodRetVar);
                  return 1;
        }
コード例 #2
0
ファイル: LuaManager.cs プロジェクト: huiguochen/Lua4Net
        private static int GetObject(LuaManager Instance,IntPtr l)
        {
            // get method arguments
                  Int32 id = (Int32)LuaApi.lua_tonumber(l,3);

                  // call method
                  Object methodRetVar = Instance.GetObject(id);

                  int nRetObjectId = LuaManager.Instance.PushStackObject(methodRetVar);
                  LuaApi.lua_pushnumber(l,nRetObjectId);
                  return 1;
        }
コード例 #3
0
ファイル: LuaOffline.cs プロジェクト: phzou204/UWPTools
        private static int update_desc(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.Function, LConst.NTable))
            {
                return(0);
            }

            int callbackF = -1;
            Dictionary <string, string> dic = null;

            if (Lua.Lua_istable(L, -1))
            {
                dic = new Dictionary <string, string>();
                Lua.Lua_pushnil(L);
                while (Lua.Lua_next(L, -2) != 0)
                {
                    String value = Lua.Lua_tostring(L, -1).ToString();
                    String key   = Lua.Lua_tostring(L, -2).ToString();

                    dic[key] = value;
                    Lua.Lua_pop(L, 1);
                }
                Lua.Lua_pop(L, 1);
            }

            if (Lua.Lua_isfunction(L, -1))
            {
                callbackF = Lua.LuaL_ref(L, Lua._LUA_REGISTRYINDEX);
            }
            Action <int> callBack = null;

            if (callbackF != -1)
            {
                callBack = (mustUpdate) =>
                {
                    LuaManager.GetLuaManager(L).ExecuteCallBackFunctionWithParam(callbackF, mustUpdate);
                };
            }

            MethodInfo mi = LuaManager.GetLuaManager(L).DetailV_.GetType().GetMethod("OfflineUpdate_Desc", new Type[] { typeof(Action <int>), typeof(Dictionary <string, string>) });

            if (mi != null)
            {
                mi.Invoke(LuaManager.GetLuaManager(L).DetailV_, new object[] { callBack, dic });
            }
            return(0);
        }
コード例 #4
0
ファイル: LuaBehaviour.cs プロジェクト: hw233/mmoclient
    public void LoadLuaScript(string fullPath)
    {
        if (string.IsNullOrEmpty(fullPath))
        {
            return;
        }
        FullPath = fullPath;

        if (!component)
        {
            string className = System.IO.Path.GetFileNameWithoutExtension(FullPath);
            luaTable = LuaManager.GetTable(className);
            if (luaTable == null)
            {
                LuaManager.DoFile(FullPath);
                if (!string.IsNullOrEmpty(className))
                {
                    luaTable = LuaManager.GetTable(className);
                    if (luaTable == null)
                    {
                        Util.LogError("Game", string.Format("没有找到{0}对应的lua表, 请确保文件名和lua表名一致", className));
                    }
                }
            }
        }
        else
        {
            object[] luaRet = LuaManager.DoFile(FullPath);
            if (luaRet != null && luaRet.Length >= 1)
            {
                // 约定:第一个返回的Table对象作为Lua模块
                luaTable = luaRet[0] as LuaTable;
            }
            else
            {
                Util.LogError("Game", "Lua脚本没有返回Table对象:" + FullPath);
            }
        }

        if (luaTable != null)
        {
            luaTable["transform"]  = transform;
            luaTable["gameObject"] = gameObject;
        }
        Call("Awake");
    }
コード例 #5
0
        static void GenProtocol()
        {
            LuaManager luaMgr           = new LuaManager();
            Action <string, string> gen = null;

            XLua.LuaTable protocol = null;
            try
            {
                luaMgr.Init();
                luaMgr.AddSearchPath(EditorConst.EditorDir);
                luaMgr.AddSearchPath(EditorConst.ScriptDir);
                protocol = luaMgr.GetTable("Protocol");

                List <string> files = new List <string>(Directory.GetFiles(c2s_dir));
                files.Add(notice_file);
                StringBuilder des = new StringBuilder();
                for (int i = 0; i < files.Count; i++)
                {
                    string content = File.ReadAllText(files[i]);
                    des.AppendFormat("{0}\n", content);
                }

                string rawProto  = File.ReadAllText(protoc_file);
                string desString = string.Format("return [[\n{0}]]", des.ToString());
                gen = protocol.Get <Action <string, string> >("GenProtocol");
                gen(desString, rawProto);
                gen = null;

                string messageString = protocol.Get <Func <string> >("GetMessageString")();
                string protoString   = protocol.Get <Func <string> >("GetProtoString")();
                string dir           = EditorConst.ScriptDir + "/Protocol/";
                File.WriteAllText(dir + "Descriptor.lua", desString);
                File.WriteAllText(dir + "Protocol.lua", protoString);
                File.WriteAllText(dir + "Message.lua", messageString);
            }
            catch (Exception e)
            {
                Debug.LogErrorFormat("{0}\n{1}", e.Message, e.StackTrace);
            }
            finally
            {
                protocol.Dispose();
                protocol = null;
                luaMgr.Dispose();
            }
        }
コード例 #6
0
    /// <summary>
    ///  355 eval
    ///  lua脚本
    /// </summary>
    public bool command_evalScript()
    {
        string src = this.currentParam[0];

        Debug.Log(src);

        XLua.LuaTable scriptEnv = LuaManager.getInterpreterEnvTable(this);

        object[] results = LuaManager.LuaEnv.DoString(src, string.Format("event_eval_{0}", this.eventId), scriptEnv);

        if (results != null && results.Length > 0)
        {
            return((bool)results[0]);
        }

        return(true);
    }
コード例 #7
0
    public string LoadConfigFile(string configName)
    {
        ConfigRequest configReq = null;

        if (!HasConfigRequest(configName, out configReq))
        {
            return("");
        }
#if RESOURCE_DEBUG
        TextAsset text = Resources.Load <TextAsset>(configReq.ConfigResourcePath);
        return(text.text);
#elif UNITY_ANDROID
        return(FileManager.LoadFileWithString(configReq.ConfigResourcePath + ".txt"));
#else
        return(FileManager.LoadFileWithString(LuaManager.GetConfigPath() + "/" + configReq.ConfigResourcePath + ".txt"));
#endif
    }
コード例 #8
0
    static int get_luaMgr(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            GameManager obj = (GameManager)o;
            LuaManager  ret = obj.luaMgr;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index luaMgr on a nil value" : e.Message));
        }
    }
コード例 #9
0
ファイル: LuaManagerWrap.cs プロジェクト: hw233/mmoclient
 static int GetTable(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         LuaManager            obj  = (LuaManager)ToLua.CheckObject(L, 1, typeof(LuaManager));
         string                arg0 = ToLua.CheckString(L, 2);
         bool                  arg1 = LuaDLL.luaL_checkboolean(L, 3);
         LuaInterface.LuaTable o    = obj.GetTable(arg0, arg1);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #10
0
    private static int LuaGC(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 1);
            LuaManager luaManager = (LuaManager)ToLua.CheckObject(L, 1, typeof(LuaManager));
            luaManager.LuaGC();
            result = 0;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
コード例 #11
0
        static int get(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.String))
            {
                return(0);
            }
            string key   = Lua.Lua_tostring(L, 2);
            var    value = RYTDatabase.GetKVData(key);

            if (value != null)
            {
                if (value is string)
                {
                    Lua.Lua_pushstring(L, value.ToString());
                }
                else if (value is double)
                {
                    Lua.Lua_pushnumber(L, (double)value);
                }
                else if (value is Boolean)
                {
                    int result = (int)value;
                    Lua.Lua_pushboolean(L, result);
                }
                else
                {
                    List <KeyValuePair <string, string> > list = value as List <KeyValuePair <string, string> >;

                    if (list != null && list.Count > 0)
                    {
                        Lua.Lua_newtable(L);
                        for (int i = 0; i < list.Count; i++)
                        {
                            LuaManager.PushValueByType(L, list[i].Key);
                            LuaManager.PushValueByType(L, list[i].Value);
                            Lua.Lua_rawset(L, -3);
                        }
                    }
                }
            }
            else
            {
                Lua.Lua_pushnil(L);
            }
            return(1);
        }
コード例 #12
0
 static int CallFunction(IntPtr L)
 {
     try
     {
         int        count = LuaDLL.lua_gettop(L);
         LuaManager obj   = (LuaManager)ToLua.CheckObject <LuaManager>(L, 1);
         string     arg0  = ToLua.CheckString(L, 2);
         object[]   arg1  = ToLua.ToParamsObject(L, 3, count - 2);
         object[]   o     = obj.CallFunction(arg0, arg1);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #13
0
        static int __CreateInstance(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                if (LuaAPI.lua_gettop(L) == 1)
                {
                    LuaManager gen_ret = new LuaManager();
                    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 LuaManager constructor!"));
        }
コード例 #14
0
ファイル: LuaUtility.cs プロジェクト: phzou204/UWPTools
        static int passwordEncryption(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.Table, LConst.Table, LConst.Function))
            {
                return(0);
            }

            Dictionary <String, object> parameters = null;
            bool isTable = Lua.Lua_istable(L, 2);

            if (isTable)
            {
                parameters = new Dictionary <String, object>();
                Lua.Lua_pushnil(L);
                while (Lua.Lua_next(L, 2) != 0)
                {
                    String value = Lua.Lua_tostring(L, -1).ToString();
                    String key   = Lua.Lua_tostring(L, -2).ToString();
                    parameters[key] = value;
                    Lua.Lua_pop(L, 1);
                }
            }
            Dictionary <String, String> modes = null;

            isTable = Lua.Lua_istable(L, 3);
            if (isTable)
            {
                modes = new Dictionary <String, String>();
                Lua.Lua_pushnil(L);
                while (Lua.Lua_next(L, 3) != 0)
                {
                    String value = Lua.Lua_tostring(L, -1).ToString();
                    String key   = Lua.Lua_tostring(L, -2).ToString();
                    modes[key] = value;
                    Lua.Lua_pop(L, 1);
                }
            }
            int        callbackF = Lua.LuaL_ref(L, Lua._LUA_REGISTRYINDEX);
            object     page      = LuaManager.GetLuaManager(L).DetailV_;
            MethodInfo pe        = page.GetType().GetMethod("passwordEncryption");

            Object[] pars = new Object[] { parameters, modes, callbackF };
            pe.Invoke(page, pars);

            return(0);
        }
コード例 #15
0
        public OverlayProfileModel(DeviceManager deviceManager, LuaManager luaManager,
                                   AudioCaptureManager audioCaptureManager) : base(deviceManager, luaManager)
        {
            Settings  = SettingsProvider.Load <OverlayProfileSettings>();
            DataModel = new OverlayProfileDataModel();

            var defaultPlayback = MMDeviceEnumerator.TryGetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);

            if (defaultPlayback != null)
            {
                _endPointVolume = AudioEndpointVolume.FromDevice(defaultPlayback);
            }

            audioCaptureManager.AudioDeviceChanged += OnAudioDeviceChanged;

            Enable();
        }
コード例 #16
0
        public WoWModel(DeviceManager deviceManager, LuaManager luaManager, WowPacketScanner packetScanner, MetroDialogService dialogService) : base(deviceManager, luaManager)
        {
            Settings  = SettingsProvider.Load <WoWSettings>();
            DataModel = new WoWDataModel();
            ProcessNames.Add("Wow-64");

            _packetScanner = packetScanner;
            _dialogService = dialogService;
            _packetScanner.RaiseDataReceived += (sender, args) => HandleGameData(args.Command, args.Data);

            FindWoW();

            // I simply cannot be sure wether this addon will bring people's accounts in trouble so
            // lets remove it whenever Artemis isn't running the WoW module.
            // (This also means the addon isnt left behind should the user uninstall Artemis.)
            RemoveAddon();
        }
コード例 #17
0
    public override void Execute(IMessage message)
    {
        //-----------------关联命令-----------------------
        PlotFacade.Instance.RegisterCommand(NotiConst.DISPATCH_MESSAGE, typeof(SocketCommand));

        //-----------------初始化管理器-----------------------
        luaMgr = PlotFacade.Instance.AddManager <LuaManager>();
        PlotFacade.Instance.AddManager <SoundManager>();
        PlotFacade.Instance.AddManager <TimerManager>();
        PlotFacade.Instance.AddManager <NetworkManager>();
        PlotFacade.Instance.AddManager <ThreadManager>();
        //        AppFacade.Instance.AddManager<GameManager>();
        PlotFacade.Instance.AddManager <SceneStageManager>();
        //PlotFacade.Instance.AddManager<CutsceneManager>();

        LuaStart();
    }
コード例 #18
0
    static int set_luaMgr(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            GameManager obj  = (GameManager)o;
            LuaManager  arg0 = (LuaManager)ToLua.CheckUnityObject(L, 2, typeof(LuaManager));
            obj.luaMgr = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index luaMgr on a nil value" : e.Message));
        }
    }
コード例 #19
0
    /**
     * path:读取文件的路径
     * content:读取文件的内容
     */
    public static string LoadFileWithString(string path)
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        int    size = 0;
        IntPtr p    = IntPtr.Zero;
        LuaInterface.LuaDLL.getAsset(path, out p, out size);
        if (p != IntPtr.Zero)
        {
            byte[] content = new byte[size];
            Marshal.Copy(p, content, 0, size);
            LuaInterface.LuaDLL.freeObj(p);
            Debug.Log("path is " + path + " size is " + size + " data " + content.ToString());
            return(System.Text.Encoding.UTF8.GetString(content));
        }
        else
        {
            Debug.Log(string.Format("Read file {0} failed", path));
        }

        return("");
#else
        //使用流的形式读取
        string       content = null;
        StreamReader sr      = null;
        try
        {
            string filepath = LuaManager.GetScriptPath() + "/" + path;
            sr = File.OpenText(filepath);
        }
        catch (Exception e)
        {
            //路径与名称未找到文件则直接返回空
#if LOG_DEBUG
            Debug.Log("Failed to open file " + path + " Error : " + e.Message);
#endif
            return("");
        }
        content = sr.ReadToEnd();
        //关闭流
        sr.Close();
        //销毁流
        sr.Dispose();
        return(content);
#endif
    }
コード例 #20
0
        /// <summary>
        /// 同步网络请求
        /// </summary>
        /// <param name="lua"></param>
        /// <returns></returns>
        static int postSyn(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.Table, LConst.String, LConst.String))
            {
                Lua.Lua_pushnil(L);
                return(1);
            }

            int num = Lua.Lua_gettop(L);

            if (num == 4)
            {
                Dictionary <String, String> headers = new Dictionary <string, string>();
                bool isTable = Lua.Lua_istable(L, 2);
                if (isTable)
                {
                    Lua.Lua_pushnil(L);
                    while (Lua.Lua_next(L, 2) != 0)
                    {
                        String value = Lua.Lua_tostring(L, -1).ToString();
                        String key   = Lua.Lua_tostring(L, -2).ToString();
                        headers[key] = value;
                        Lua.Lua_pop(L, 1);
                    }
                }

                string url  = Lua.Lua_tostring(L, 3).ToString();
                string body = string.Empty;
                if (Lua.Lua_isstring(L, 4))
                {
                    body = Lua.Lua_tostring(L, 4).ToString();
                }
                object     page    = LuaManager.GetLuaManager(L).DetailV_;
                MethodInfo methods = page.GetType().GetMethod("postSyn");
                Object[]   pars    = new Object[] { headers, url, body };
                String     result  = (String)methods.Invoke(page, pars);
                Lua.Lua_pushstring(L, result);
            }
            else
            {
                Lua.Lua_pushnil(L);
            }

            return(1);
        }
コード例 #21
0
    /// <summary>
    /// 程序启动
    /// </summary>
    public void AppLaunch()
    {
        DontDestroyOnLoad(gameObject);
        SetResourceLoadType();               //设置资源加载类型
        ResourcesConfigManager.Initialize(); //资源路径管理器启动

        MemoryManager.Init();                //内存管理初始化
        Timer.Init();                        //计时器启动
        InputManager.Init();                 //输入管理器启动

#if !UNITY_WEBGL
        UIManager.Init();                    //UIManager启动
#else
        UIManager.InitAsync();               //异步加载UIManager
#endif

        ApplicationStatusManager.Init();     //游戏流程状态机初始化
        GlobalLogicManager.Init();           //初始化全局逻辑

        if (AppMode != AppMode.Release)
        {
            GUIConsole.Init(); //运行时Console

            DevelopReplayManager.OnLunchCallBack += () =>
            {
#if USE_LUA
                LuaManager.Init();
#endif
                InitGlobalLogic();                                 //全局逻辑
                ApplicationStatusManager.EnterTestModel(m_Status); //可以从此处进入测试流程
            };

            DevelopReplayManager.Init(m_quickLunch);   //开发者复盘管理器
        }
        else
        {
            Log.Init(false); //关闭 Debug

#if USE_LUA
            LuaManager.Init();
#endif
            InitGlobalLogic();                              //全局逻辑
            ApplicationStatusManager.EnterStatus(m_Status); //游戏流程状态机,开始第一个状态
        }
    }
コード例 #22
0
    /// <summary>
    /// 程序启动
    /// </summary>
    public void AppLaunch()
    {
        DontDestroyOnLoad(gameObject);
        SetResourceLoadType();               //设置资源加载类型
        ResourcesConfigManager.Initialize(); //资源路径管理器启动

        MemoryManager.Init();                //内存管理初始化
        HeapObjectPool.Init();
        Timer.Init();                        //计时器启动
        InputManager.Init();                 //输入管理器启动
        UIManager.Init();                    //UIManager启动

        ApplicationStatusManager.Init();     //游戏流程状态机初始化
        GlobalLogicManager.Init();           //初始化全局逻辑

        if (m_AppMode != AppMode.Release)
        {
            GUIConsole.Init(); //运行时Console

            DevelopReplayManager.OnLunchCallBack += () =>
            {
                if (m_useLua)
                {
                    LuaManager.Init();
                }

                InitGlobalLogic();                                 //全局逻辑
                ApplicationStatusManager.EnterTestModel(m_Status); //可以从此处进入测试流程
            };

            DevelopReplayManager.Init(m_quickLunch);   //开发者复盘管理器
        }
        else
        {
            Log.Init(false); //关闭 Debug

            if (m_useLua)
            {
                LuaManager.Init();
            }

            InitGlobalLogic();                              //全局逻辑
            ApplicationStatusManager.EnterStatus(m_Status); //游戏流程状态机,开始第一个状态
        }
    }
コード例 #23
0
    /// <summary>
    /// 初始化游戏管理器
    /// </summary>
    void Start()
    {
        DontDestroyOnLoad(gameObject);  //防止销毁自己

        mLuaManager = gameObject.GetComponent <LuaManager>();
        if (mLuaManager == null)
        {
            mLuaManager = gameObject.AddComponent <LuaManager>();
        }

        mKbeMain = gameObject.GetComponent <KBEMain>();
        if (mKbeMain == null)
        {
            mKbeMain = gameObject.AddComponent <KBEMain>();
        }

        OnInitialize();
    }
コード例 #24
0
        private void BindLuaScript()
        {
            LuaManager luaMgr    = FrameworkEntry.GetModule <LuaManager>();
            LuaTable   scriptEnv = luaMgr.luaEnv.NewTable();
            LuaTable   meta      = luaMgr.luaEnv.NewTable();

            meta.Set("__index", luaMgr.luaEnv.Global);
            scriptEnv.SetMetaTable(meta);
            meta.Dispose();
            string luaFileName = string.Concat(UIName + "Logic");
            string cmd         = string.Concat("require 'ui/", luaFileName, "'");

            luaMgr.luaEnv.DoString(cmd, luaFileName, scriptEnv);
            logicEnv = scriptEnv.Get <LuaTable>(UIName);
            //string bindMethodName = string.Concat(UIName, ".", BindMethod);
            //scriptEnv.GetInPath<Action<LuaTable, UIWnd>>(bindMethodName)?.Invoke(logicEnv, this);
            logicEnv.Get <Action <LuaTable, UIWnd> >(BindMethod)?.Invoke(logicEnv, this);
        }
コード例 #25
0
    public override void Trigger()
    {
        if (!Application.isPlaying)
        {
            return;
        }

        LuaManager luaMgr = AppFacade.Instance.GetManager <LuaManager>();

        LuaFunction func = luaMgr.mainLua.GetFunction("EntityTextureNamePanel.show");

        func.BeginPCall();
        func.Push(ImageName);
        func.Push(Size);
        func.Push((int)Direction);
        func.PCall();
        func.EndPCall();
    }
コード例 #26
0
ファイル: LuaCheckBox.cs プロジェクト: tamasseller/Artemis
        public LuaCheckBox(LuaManager luaManager, string text, bool isChecked, double x, double y, double?width, double?height)
        {
            _luaManager = luaManager;

            CheckBox = new CheckBox {
                Content = text, IsChecked = isChecked
            };
            if (width != null)
            {
                CheckBox.Width = width.Value;
            }
            if (height != null)
            {
                CheckBox.Height = height.Value;
            }

            CheckBox.Click += CheckBoxOnClick;
        }
コード例 #27
0
ファイル: LuaTextBox.cs プロジェクト: tamasseller/Artemis
        public LuaTextBox(LuaManager luaManager, string text, double x, double y, double?width, double?height)
        {
            _luaManager = luaManager;

            TextBox = new TextBox {
                Text = text
            };
            if (width != null)
            {
                TextBox.Width = width.Value;
            }
            if (height != null)
            {
                TextBox.Height = height.Value;
            }

            TextBox.TextChanged += TextBoxOnTextChanged;
        }
コード例 #28
0
        public LuaButton(LuaManager luaManager, string text, double x, double y, double?width, double?height)
        {
            _luaManager = luaManager;

            Button = new Button {
                Content = text
            };
            if (width != null)
            {
                Button.Width = width.Value;
            }
            if (height != null)
            {
                Button.Height = height.Value;
            }

            Button.Click += ButtonOnClick;
        }
コード例 #29
0
ファイル: LuaTool.cs プロジェクト: l1000965431/LuaDofile
    private void DoLuaFile()
    {
        if (luaFilePath.Length == 0)
        {
            EditorGUILayout.HelpBox("文件路径错误", MessageType.None);
            return;
        }

        if (!File.Exists(luaFilePath))
        {
            EditorGUILayout.HelpBox("文件不存在", MessageType.None);
            return;
        }

        LuaManager mgr = AppFacade.Instance.GetManager <LuaManager>(ManagerName.Lua);

        mgr.DoFile(luaFilePath);
    }
コード例 #30
0
        public LuaComboBox(LuaManager luaManager, string value, List <string> values, double x, double y, double?width, double?height)
        {
            _luaManager = luaManager;

            ComboBox = new ComboBox {
                ItemsSource = new ObservableCollection <string>(values), SelectedItem = value
            };
            if (width != null)
            {
                ComboBox.Width = (double)width;
            }
            if (height != null)
            {
                ComboBox.Height = (double)height;
            }

            ComboBox.SelectionChanged += ComboBoxOnSelectionChanged;
        }
コード例 #31
0
ファイル: GameManager.cs プロジェクト: zh423328/RunAway
        /// <summary>
        /// 资源初始化结束
        /// </summary>
        public void OnResourceInited()
        {
            //gameman添加main
            Component c = gameObject.GetComponent <Main>();

            if (c == null)
            {
                gameObject.AddComponent <Main>();
            }

            LuaManager.Start();
            int start = Environment.TickCount;

            LuaManager.DoFile("Logic/Network");     //加载网络
            LuaManager.DoFile("Logic/GameManager"); //加载游戏

            initialize = true;                      //初始化完

            NetManager.OnInit();                    //初始化网络



            //---------------------Lua面板---------------------------
            object[] panels = CallMethod("LuaScriptPanel");

            foreach (object o in panels)
            {
                string name = o.ToString().Trim();
                if (string.IsNullOrEmpty(name))
                {
                    continue;
                }
                name += "Panel";    //添加

                LuaManager.DoFile("View/" + name);
                Debug.LogWarning("LoadLua---->>>>" + name + ".lua");
            }
            //------------------------------------------------------------
            CallMethod("OnInitOK");   //初始化完成

            int end = Environment.TickCount;

            UnityEngine.Debug.Log("tick" + (end - start));
        }
コード例 #32
0
ファイル: LuaDocument.cs プロジェクト: phzou204/UWPTools
        static int getElementsByProperty(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.Table))
            {
                return(0);
            }
            bool   isTable = Lua.Lua_istable(L, -1);
            object page    = LuaManager.GetLuaManager(L).DetailV_;

            if (isTable && page != null)
            {
                Dictionary <String, String> dic = new Dictionary <string, string>();
                Lua.Lua_pushnil(L);
                while (Lua.Lua_next(L, -2) != 0)
                {
                    String value = Lua.Lua_tostring(L, -1).ToString();
                    String key   = Lua.Lua_tostring(L, -2).ToString();
                    dic[key] = value;
                    Lua.Lua_pop(L, 1);
                }
                MethodInfo    methods = page.GetType().GetMethod("getElementsByProperty");
                Object[]      pars    = new Object[] { dic };
                List <Object> temp    = (List <Object>)methods.Invoke(page, pars);
                Lua.Lua_newtable(L);
                if (temp.Count == 0)
                {
                    //string keyValue = dic[dic.Keys.GetEnumerator().Current];
                    //string message = string.Format("Control name='{0}' NOT found!", keyValue);
                    //MessageBox.Show("getElementsByProperty return null");
                    //-return 0;
                    Lua.Lua_rawset(L, -1);
                    return(1);
                }
                for (int i = 0; i < temp.Count; i++)
                {
                    Lua.Lua_pushnumber(L, i + 1);
                    Lua.Lua_pushlightuserdata(L, temp[i]);
                    Lua.LuaL_getmetatable(L, "elementFunction");
                    Lua.Lua_setmetatable(L, -2);
                    Lua.Lua_rawset(L, -3);
                }
            }
            return(1);
        }
コード例 #33
0
ファイル: LuaManager.cs プロジェクト: huiguochen/Lua4Net
 private static int get_Instance(LuaManager Instance,IntPtr l)
 {
     int id = LuaManager.Instance.PushStackObject(LuaManager.Instance);
           LuaApi.lua_pushnumber(l,id);
           return 1;
 }
コード例 #34
0
ファイル: Program.cs プロジェクト: huiguochen/Lua4Net
 static void Main(string[] args)
 {
     LuaManager lm = new LuaManager();
     lm.Initialize(new Lua4NetRoot(), "Lua4NetRoot.lua", "application.lua", null);
     Console.ReadLine();
 }
コード例 #35
0
ファイル: LuaManager.cs プロジェクト: huiguochen/Lua4Net
        private static int Test(LuaManager Instance,IntPtr l)
        {
            // get method arguments
                  LuaStackFunction lsf = new LuaStackFunction(3);
                  LuaRefFunction lrf = new LuaRefFunction(4,l);

                  // call method
                  Instance.Test(lsf,lrf);

                  return 0;
        }
コード例 #36
0
ファイル: LuaManager.cs プロジェクト: huiguochen/Lua4Net
        private static int SetGlobalObject(LuaManager Instance,IntPtr l)
        {
            // get method arguments
                  Int32 id = (Int32)LuaApi.lua_tonumber(l,3);
                  int objId = (int)LuaApi.lua_tonumber(l,4);
                  Object obj = LuaManager.Instance.GetObjectT<Object>(objId);

                  // call method
                  Instance.SetHeapObject(id,obj);

                  return 0;
        }