Example #1
0
        private static void InitializeManagersAndGameSettings()
        {
            LogManager = Kernel.Get <ILogManager>();
            LogManager.Boot("-----------------------[ Boot Log ]----------------------");

            var loaded = SystemConstants.LoadSystemDirectoriesFromConfig(GameConstants.DataPath);

            LogManager.Boot("{0} SystemDirectories loaded.", loaded);

            loaded = SystemConstants.LoadSystemFilesFromConfig();
            LogManager.Boot("{0} SystemFiles loaded.", loaded);

            LookupManager = Kernel.Get <ILookupManager>();

            LuaManager = Kernel.Get <ILuaManager>();

            NetworkManager = Kernel.Get <ITcpServer>();
            NetworkManager.Startup(Convert.ToInt32(ConfigurationManager.AppSettings["port"]),
                                   IPAddress.Parse(ConfigurationManager.AppSettings["host"]));
            NetworkManager.OnTcpUserStatusChanged += NetworkManager_OnOnTcpUserStatusChanged;

            RepositoryManager = Kernel.Get <IRepositoryManager>();

            var luaInitializer = Kernel.Get <IInitializer>("LuaInitializer");

            if (luaInitializer == null)
            {
                throw new ApplicationException("LuaInitializer failed to start");
            }

            LuaManager.DoLuaScript(SystemConstants.GetSystemFile(SystemFileTypes.Lookups));
            LuaManager.DoLuaScript(SystemConstants.GetSystemFile(SystemFileTypes.StatModLookups));

            BanManager      = Kernel.Get <IBanManager>();
            BoardManager    = Kernel.Get <IBoardManager>();
            CalendarManager = Kernel.Get <ICalendarManager>();

            GameManager = Kernel.Get <IGameManager>();
            GameManager.SetGameTime(CalendarManager.GameTime);
            GameManager.GameTime.SetTimeOfDay(GameConstants.GetSystemValue <int>("HourOfSunrise"),
                                              GameConstants.GetSystemValue <int>("HourOfDayBegin"), GameConstants.GetSystemValue <int>("HourOfSunset"),
                                              GameConstants.GetSystemValue <int>("HourOfNightBegin"));

            WeatherManager = Kernel.Get <IWeatherManager>();

            NewsManager = Kernel.Get <INewsManager>();

            AuctionManager = Kernel.Get <IAuctionManager>();

            ClanManager = Kernel.Get <IClanManager>();

            InitializeStaticGameData();
        }