コード例 #1
0
ファイル: CaravelApp.cs プロジェクト: jocamar/Caravel
        protected sealed override void Initialize()
        {
            if (!EditorRunning)
            {
                CurrentGraphicsDevice = GraphicsDevice;
            }

            Cv_Debug debug = new Cv_Debug();

            debug.Initialize("Logs/logTags.xml");

            if (!CheckEngineSystemResources())
            {
                Cv_Debug.Error("Not enough system resources to run the engine.");
                Exit();
                return;
            }

            if (!VCheckGameSystemResources())
            {
                Cv_Debug.Error("Not enough system resources to run the game.");
                Exit();
                return;
            }

            ReadProjectFile();

            ResourceManager = new Cv_ResourceManager();
            if (!ResourceManager.Initialize(m_BundleInfo, UseDevelopmentDirectories))
            {
                Cv_Debug.Error("Unable to initialize resource manager.");
                Exit();
                return;
            }

            if (!EditorRunning && !LoadStrings("English"))
            {
                Cv_Debug.Error("Unable to load strings.");
                Exit();
                return;
            }

            ProcessManager = new Cv_ProcessManager();
            if (!ProcessManager.Initialize())
            {
                Cv_Debug.Error("Unable to initialize process manager.");
                Exit();
                return;
            }

            ScriptManager = new Cv_LuaScriptManager();
            if (!ScriptManager.VInitialize())
            {
                Cv_Debug.Error("Unable to initialize script manager.");
                Exit();
                return;
            }

            //This loads the preInit Lua script if there's one
            if (InitScriptLocation != null && InitScriptLocation != "" && InitScriptBundle != null && InitScriptBundle != "")
            {
                Cv_ScriptResource initScript = ResourceManager.GetResource <Cv_ScriptResource>(InitScriptLocation, InitScriptBundle);
                initScript.RunScript();
            }

            EventManager = new Cv_EventManager(true);
            if (!EventManager.Initialize())
            {
                Cv_Debug.Error("Unable to initialize event manager.");
                Exit();
                return;
            }

            SoundManager = new Cv_SoundManager();
            if (!SoundManager.Initialize())
            {
                Cv_Debug.Error("Unable to initialize sound manager.");
                Exit();
                return;
            }

            InputManager = new Cv_InputManager();
            if (!InputManager.Initialize())
            {
                Cv_Debug.Error("Unable to initialize input manager.");
                Exit();
                return;
            }

            Window.Title      = VGetGameTitle();
            SaveGameDirectory = GetSaveGameDirectory(VGetGameAppDirectoryName());

            Logic = VCreateGameLogic();
            if (Logic == null)
            {
                Cv_Debug.Error("Unable to create game logic.");
                Exit();
                return;
            }

            Scene = new Cv_SceneElement(this);
            var gvs = VCreateGameViews();

            foreach (var gv in gvs)
            {
                Logic.AddView(gv);
            }
            Logic.AddGamePhysics(VCreateGamePhysics());
            Logic.Initialize();

            Running = true;

            VInitialize();

            base.Initialize();
        }