Ejemplo n.º 1
0
        /// <summary>
        /// Inicializa as configurações do servidor.
        /// </summary>
        public static void Initialize()
        {
            Settings.ParseConfigFile("Config.txt");

            Log.Enabled = Settings.GetBoolean("Log");

            var error  = string.Empty;
            var result = true;

            if (Log.Enabled)
            {
                result = Log.OpenFile(out error);

                if (!result)
                {
                    Log.Write($"Ocorreu um erro ao abrir o arquivo de logs", Color.Red);
                    Log.Write(error, Color.Red);
                }
            }

            Configuration.Discovery      = Settings.GetString("Discovery");
            Configuration.Port           = Settings.GetInt32("Port");
            Configuration.Sleep          = Settings.GetInt32("Sleep");
            Configuration.MaxConnections = Settings.GetInt32("MaximumConnections");

            Log.Write($"Discovery: {Configuration.Discovery}", Color.Black);
            Log.Write($"Port: {Configuration.Port}", Color.Black);
            Log.Write($"Sleep: {Configuration.Sleep}", Color.Black);
            Log.Write($"Max Connections: {Configuration.MaxConnections}", Color.Black);
            Log.Write($"Loading scripts", Color.Black);
            LuaConfig.InitializeConfig();

            Log.Write("Connect Server Start", Color.Green);
            NetworServer.Initialize();
        }
Ejemplo n.º 2
0
        private static void refreshData()
        {
            mConfig = XConfig.GetConfig <LuaConfig>(LuaConst.ConfigPath_Resources, AssetLoadType.Resources, false);



            mDataRefreshed = true;
        }
Ejemplo n.º 3
0
        public void castingTest4()
        {
            var cfg = new LuaConfig()
            {
                LazyLoading = true
            };

            using (var l = new Lua <ILua51>(cfg))
            {
                Assert.Throws <InvalidCastException>(() => (ILua52)l.API); // std. l.API contains the initialized 51
            }
        }
Ejemplo n.º 4
0
        private List <recipe> readReipes(string path)
        {
            // 读取文件


            StreamReader reader = new StreamReader(path, Encoding.UTF8);

            string factorioData = reader.ReadToEnd().Trim().Replace("data:extend(", "factorioData=").Replace(")", "");

            // 读取lua
            LuaConfig lc = new LuaConfig();


            LuaTable lt = lc.ReadLua(factorioData, false);
            // LuaTable lt =lc.ReadLua(path, Encoding.UTF8, false );

            LuaTable lt1 = (LuaTable)lt["factorioData"];

            object o = lt1[1];

            List <recipe> recipe_list = new List <recipe>();


            for (int i = 1; i < lt1.Length + 1; i++)
            {
                recipe recipe = new recipe();


                IDictionary <string, object> d = (((LuaTable)lt1[i]).Members);



                recipe.Type = d["type"].ToString();
                recipe.Name = d["name"].ToString();
                LuaTable lt_ingredients = null;
                if (d.ContainsKey("normal"))
                {
                    d = ((LuaTable)d["normal"]).Members;
                }
                lt_ingredients = ((LuaTable)d["ingredients"]);

                for (int j = 1; j < lt_ingredients.Length + 1; j++)
                {
                    IList <object> ilist = (((LuaTable)lt_ingredients[j])).ArrayList;
                    if (ilist.Count > 0)
                    {
                        recipe.Ingredients.Add(ilist[0].ToString(), (int)ilist[1]);
                    }
                }
                recipe_list.Add(recipe);
            }
            return(recipe_list);
        }
Ejemplo n.º 5
0
        public void castingTest3()
        {
            var cfg = new LuaConfig()
            {
                LazyLoading = true
            };

            using (ILua l = new Lua <ILua51>(cfg))
            {
                Assert.Equal(LuaVersion.Lua53, ((ILua52)l.U).Version);    // because l.U contains latest ILuaN

                Assert.Equal(LuaVersion.Lua52, (l.v <ILua52>()).Version); // because it recreates initial bridge
            }
        }
Ejemplo n.º 6
0
        public void castingTest1()
        {
            var cfg = new LuaConfig()
            {
                LazyLoading = true
            };

            using (var l = new Lua <ILua52>(cfg))
            {
                Assert.Equal(LuaVersion.Lua52, l.API.Version);

                Assert.Equal(LuaVersion.Lua52, ((ILua51)l.API).Version);

                Assert.Equal(LuaVersion.Lua51, (l.v <ILua51>()).Version);
            }
        }
Ejemplo n.º 7
0
        public void castingTest5()
        {
            var cfg = new LuaConfig()
            {
                LazyLoading = true
            };

            using (ILua l = new Lua <ILua51>(cfg))
            {
                Assert.Equal(LuaVersion.Lua51, (((Lua <ILua51>)l).API).Version);
            }

            using (ILua l = new Lua <ILua52>(cfg))
            {
                Assert.Equal(LuaVersion.Lua52, (((Lua <ILua52>)l).API).Version);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initialize the InputManager object and configuration.
        /// </summary>
        public Input()
        {
            inputKeys = new Dictionary<String, String>();
            keyStates = new Dictionary<String,KeyState>();
            keyPresses = new Dictionary<String, Boolean>();

            // Default action assignments
            inputKeys.Add("MenuUp", "up");
            inputKeys.Add("MenuDown", "down");
            inputKeys.Add("MenuLeft", "left");
            inputKeys.Add("MenuRight", "right");
            inputKeys.Add("MenuSelect", "enter");
            inputKeys.Add("MenuToggle", "escape");

            inputKeys.Add("Up", "w");
            inputKeys.Add("Down", "s");
            inputKeys.Add("Left", "a");
            inputKeys.Add("Right", "d");
            inputKeys.Add("WeaponNext", "q");
            inputKeys.Add("Fire", "Mouse1");
            inputKeys.Add("Camera", "Mouse2");
            inputKeys.Add("Pause", "p");
            #if DEBUG
            inputKeys.Add("DebugFramerate", "control+f");
            inputKeys.Add("DebugCollisions", "control+c");
            inputKeys.Add("DebugCulling", "control+u");
            inputKeys.Add("DebugBoundingBoxes", "control+b");
            inputKeys.Add("DebugFlying", "control+y");
            inputKeys.Add("DebugCameraPosition", "control+alt+c");
            inputKeys.Add("DebugHelixPosition", "control+alt+h");
            inputKeys.Add("DebugZoomIn", "control+pageup");
            inputKeys.Add("DebugZoomOut", "control+pagedown");
            inputKeys.Add("DebugTriggers", "control+t");
            #endif

            // Read from the user's config file
            inputConfig = new LuaConfig(new Dictionary<string,double>(), inputKeys);
            inputConfig.readFile(inputConfigFile);
            inputKeys = inputConfig.getStrings();

            this.reset();
        }
Ejemplo n.º 9
0
        public static SettingsProvider XRuntimeSetting()
        {
            return(new SettingsProvider(LuaEditorConst.ProjectSetting_Node, SettingsScope.Project, new string[] { "Nekonya", "TinaX", "Lua", "TinaX.Lua", "xLua" })
            {
                label = "X Lua",
                guiHandler = (searchContent) =>
                {
                    if (!mDataRefreshed)
                    {
                        refreshData();
                    }
                    if (mConfig == null)
                    {
                        GUILayout.Space(20);
                        GUILayout.Label(I18Ns.NoConfig);
                        if (GUILayout.Button(I18Ns.BtnCreateConfigFile, Styles.style_btn_normal, GUILayout.MaxWidth(120)))
                        {
                            mConfig = XConfig.CreateConfigIfNotExists <LuaConfig>(LuaConst.ConfigPath_Resources, AssetLoadType.Resources);
                            refreshData();
                        }
                    }
                    else
                    {
                        GUILayout.Space(20);

                        //Enable Lua
                        mConfig.EnableLua = EditorGUILayout.ToggleLeft(I18Ns.EnableLua, mConfig.EnableLua);


                        //Entry File
                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField(I18Ns.EntryFilePath);
                        EditorGUILayout.BeginHorizontal();
                        mConfig.EntryLuaFileLoadPath = EditorGUILayout.TextField(mConfig.EntryLuaFileLoadPath);
                        if (GUILayout.Button("Select", Styles.style_btn_normal, GUILayout.Width(55)))
                        {
                            var path = EditorUtility.OpenFilePanel("Select Lua Entry File", "Assets/", "");
                            if (!path.IsNullOrEmpty())
                            {
                                var root_path = Directory.GetCurrentDirectory().Replace("\\", "/");
                                if (path.StartsWith(root_path))
                                {
                                    path = path.Substring(root_path.Length + 1, path.Length - root_path.Length - 1);
                                    path = path.Replace("\\", "/");
                                    mConfig.EntryLuaFileLoadPath = path;
                                }
                                else
                                {
                                    Debug.LogError("Invalid Path: " + path);
                                }
                            }
                        }
                        EditorGUILayout.EndHorizontal();


                        //Framework Lua Folder Load Path
                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField(I18Ns.FrameworkInternalLuaFolderLoadPath);
                        EditorGUILayout.BeginHorizontal();
                        mConfig.FrameworkInternalLuaFolderLoadPath = EditorGUILayout.TextField(mConfig.FrameworkInternalLuaFolderLoadPath);
                        EditorGUILayout.EndHorizontal();


                        //extension
                        EditorGUILayout.Space();
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.LabelField(I18Ns.LuaExtension, GUILayout.MaxWidth(120));
                        mConfig.LuaFileExtensionName = EditorGUILayout.TextField(mConfig.LuaFileExtensionName, GUILayout.MaxWidth(120));
                        if (mConfig.LuaFileExtensionName != ".lua.txt")
                        {
                            if (GUILayout.Button(".lua.txt", Styles.style_btn_normal, GUILayout.Width(75)))
                            {
                                mConfig.LuaFileExtensionName = ".lua.txt";
                            }
                        }
                        if (mConfig.LuaFileExtensionName != ".lua.bytes")
                        {
                            if (GUILayout.Button(".lua.bytes", Styles.style_btn_normal, GUILayout.Width(75)))
                            {
                                mConfig.LuaFileExtensionName = ".lua.bytes";
                            }
                        }
                        if (mConfig.LuaFileExtensionName != ".txt")
                        {
                            if (GUILayout.Button(".txt", Styles.style_btn_normal, GUILayout.Width(75)))
                            {
                                mConfig.LuaFileExtensionName = ".txt";
                            }
                        }

                        EditorGUILayout.EndHorizontal();
                    }
                },
                deactivateHandler = () =>
                {
                    if (mConfig != null)
                    {
                        if (!mConfig.LuaFileExtensionName.IsNullOrEmpty())
                        {
                            mConfig.LuaFileExtensionName = mConfig.LuaFileExtensionName.ToLower();
                            if (!mConfig.LuaFileExtensionName.StartsWith("."))
                            {
                                mConfig.LuaFileExtensionName = "." + mConfig.LuaFileExtensionName;
                            }
                        }
                        EditorUtility.SetDirty(mConfig);
                        AssetDatabase.SaveAssets();
                        AssetDatabase.Refresh();
                    }
                }
            });
        }
Ejemplo n.º 10
0
        public void InitializeServer()
        {
            trayIcon = new NotifyIcon();
            trayMenu = new ContextMenu();

            Configuration.ParseConfigFile(Settings.FILE_CONFIG);

            // CARREGA TODAS AS INFORMAÇÕES DE CONFIURAÇÃO
            Settings.WorldServerName = Configuration.GetString("WorldServerName");
            WriteLog($"World Server Name: {Settings.WorldServerName}", Color.CornflowerBlue);
            Text = $"World Server @ {Settings.WorldServerName}";

            Settings.Discovery = Configuration.GetString("Discovery");
            WriteLog($"Discovery: {Settings.Discovery}", Color.Black);

            Settings.Port = Configuration.GetInt32("Port");
            WriteLog($"Port: {Settings.Port}", Color.Black);

            Settings.MaxConnection = Configuration.GetInt32("MaximumConnections");
            WriteLog($"MaxConnection: {Settings.MaxConnection}", Color.Black);

            Settings.ConnectionTimeOut = Configuration.GetInt32("ConnectionTimeOut");
            WriteLog($"ConnectionTimeOut: {Settings.ConnectionTimeOut}", Color.Black);

            Settings.LogSystem = Configuration.GetBoolean("LogSystem");
            WriteLog($"LogSystem: {Settings.LogSystem}", Color.Black);

            Settings.Sleep = Configuration.GetInt32("Sleep");
            WriteLog($"Sleep: {Settings.Sleep}", Color.Black);

            LuaConfig.InitializeConfig();

            WriteLog($"Create Character: {GameSettings.CharacterCreation}", Color.MediumVioletRed);
            WriteLog($"Delete Character: {GameSettings.CharacterDelete}", Color.MediumVioletRed);

            InitializeServerConfig();

            if (Settings.LogSystem == true)
            {
                WriteLog("LogSystem - Ativado.", Color.Green);
                FileLog.Open();
            }
            else
            {
                WriteLog("LogSystem - Desativado.", Color.Black);
            }

            WriteLog("Carregando config do mysql", Color.Black);

            string tempError = string.Empty;

            Common_DB.Server   = Configuration.GetString("MySQL_IP");
            Common_DB.Port     = Configuration.GetInt32("MySQL_Port");
            Common_DB.Username = Configuration.GetString("MySQL_User");
            Common_DB.Password = Configuration.GetString("MySQL_Pass");
            Common_DB.Database = Configuration.GetString("MySQL_DB");

            // Tenta fazer a conexão com o banco de dados
            if (!Common_DB.Open(out tempError))
            {
                WriteLog(tempError, Color.Red);
            }
            else
            {
                WriteLog("Connectado ao banco de dados", Color.Green);
            }


            Authentication.HexID  = new HashSet <HexaID>();
            Authentication.Player = new HashSet <PlayerData>();

            InitializeGuild();
            InitializeClasse();

            WorldNetwork.InitializeServer();
            GameNetwork.InitializeGameServer();

            WriteLog("World Server Start.", Color.Green);

            //################# sysTray ########################
            trayMenu.MenuItems.Add("Mostrar", ShowForm);
            trayMenu.MenuItems.Add("Sair", quit_MenuItem_Click);

            trayIcon.Text = "World Server @";
            trayIcon.Icon = this.Icon;

            trayIcon.ContextMenu = trayMenu;
        }