Example #1
0
        public static void Main()
        {
            Console.Title = Title;
            Core.I18N.Logger.PrintHeader(ConsoleText);
            InitializeConfiguration();
            TypeAdapterConfig.GlobalSettings.Default.IgnoreAttribute(typeof(I18NFromAttribute));
            LogLanguage.Language = DatabaseConfiguration.Language;
            try
            {
                var optionsBuilder = new DbContextOptionsBuilder <NosCoreContext>();
                optionsBuilder.UseNpgsql(DatabaseConfiguration.Database.ConnectionString);
                DataAccessHelper.Instance.Initialize(optionsBuilder.Options);

                var npcMonsters = _npcMonsterDao.LoadAll().ToList();
                TypeAdapterConfig <MapMonsterDto, GameObject.MapMonster> .NewConfig().ConstructUsing(src => new GameObject.MapMonster(npcMonsters, Logger));

                TypeAdapterConfig <MapNpcDto, GameObject.MapNpc> .NewConfig().ConstructUsing(src => new GameObject.MapNpc(null, null, null, npcMonsters, Logger));

                while (true)
                {
                    Logger.Information(LogLanguage.Instance.GetMessageFromKey(LogLanguageKey.SELECT_MAPID));
                    var input = Console.ReadLine();
                    if ((input == null) || !int.TryParse(input, out var askMapId))
                    {
                        Logger.Error(LogLanguage.Instance.GetMessageFromKey(LogLanguageKey.WRONG_SELECTED_MAPID));
                        continue;
                    }

                    var map = _mapDao.FirstOrDefault(m => m.MapId == askMapId).Adapt <GameObject.Map.Map>();

                    if ((map?.XLength > 0) && (map.YLength > 0))
                    {
                        if (_guiWindow?.Exists ?? false)
                        {
                            _guiWindow.Exit();
                        }

                        new Thread(() =>
                        {
                            _guiWindow = new GuiWindow(map, 4, map.XLength, map.YLength, GraphicsMode.Default,
                                                       $"NosCore Pathfinder GUI - Map {map.MapId}");
                            _guiWindow.Run(30);
                        }).Start();
                    }
                }
            }
            catch
            {
                Console.ReadKey();
            }
        }
Example #2
0
        public static void Main()
        {
            PrintHeader();
            InitializeLogger();
            InitializeConfiguration();
            LogLanguage.Language = DatabaseConfiguration.Language;
            try
            {
                var optionsBuilder = new DbContextOptionsBuilder <NosCoreContext>();
                optionsBuilder.UseNpgsql(DatabaseConfiguration.Database.ConnectionString);
                DataAccessHelper.Instance.Initialize(optionsBuilder.Options);

                while (true)
                {
                    Logger.Log.Info(LogLanguage.Instance.GetMessageFromKey(LanguageKey.SELECT_MAPID));
                    var input = Console.ReadLine();
                    if (input == null || !int.TryParse(input, out var askMapId))
                    {
                        Logger.Log.Error(LogLanguage.Instance.GetMessageFromKey(LanguageKey.WRONG_SELECTED_MAPID));
                        continue;
                    }

                    var map = (Map)DAOFactory.MapDAO.FirstOrDefault(m => m.MapId == askMapId);

                    if (map?.XLength > 0 && map.YLength > 0)
                    {
                        map.Initialize();

                        if (_guiWindow?.Exists == true)
                        {
                            _guiWindow.Exit();
                        }

                        new Thread(() =>
                        {
                            _guiWindow = new GuiWindow(map, 4, map.XLength, map.YLength, GraphicsMode.Default,
                                                       $"NosCore Pathfinder GUI - Map {map.MapId}");
                            _guiWindow.Run(30);
                        }).Start();
                    }
                }
            }
            catch
            {
                Console.ReadKey();
            }
        }
Example #3
0
        public static void Main()
        {
            PrintHeader();
            InitializeLogger();
            InitializeConfiguration();
            LogLanguage.Language = _databaseConfiguration.Language;
            DAOFactory.RegisterMapping(typeof(Character).Assembly);
            try
            {
                DataAccessHelper.Instance.Initialize(_databaseConfiguration.Database);

                do
                {
                    Logger.Log.Info(LogLanguage.Instance.GetMessageFromKey(LogLanguageKey.SELECT_MAPID));
                    string input = Console.ReadLine();
                    if (input == null || !double.TryParse(input, out double askMapId))
                    {
                        Logger.Log.Error(LogLanguage.Instance.GetMessageFromKey(LogLanguageKey.WRONG_SELECTED_MAPID));
                        continue;
                    }
                    Map map = (Map)DAOFactory.MapDAO.FirstOrDefault(m => m.MapId == askMapId);

                    if (map != null && map.XLength > 0 && map.YLength > 0)
                    {
                        map.Initialize();

                        if (guiWindow?.Exists == true)
                        {
                            guiWindow.Exit();
                        }

                        new Thread(() =>
                        {
                            guiWindow = new GuiWindow(map, 4, map.XLength, map.YLength, GraphicsMode.Default, $"NosCore Pathfinder GUI - Map {map.MapId}");
                            guiWindow.Run(30);
                        }).Start();
                    }
                } while (true);
            }
            catch
            {
                Console.ReadKey();
            }
        }