コード例 #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Graphics.GraphicsProfile             = GraphicsProfile.HiDef;
            Graphics.PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8;
            Graphics.ApplyChanges();

            var path = "C:\\GitHub\\Maps\\Goldenrod\\goldenrod.dat";
            //var path = "C:\\GitHub\\Maps\\YourRoom\\yourroom.dat";
            //var path = "C:\\GitHub\\Maps\\UnderwaterCave\\main.dat";
            //var path = "C:\\GitHub\\Maps\\Kolben\\devoffices.dat";
            var text      = File.ReadAllText(path);
            var levelInfo = LevelLoader.Load(text, path);

            var camera = new Camera3DMonoGame(this);

            Components.Add(camera);

            var modelSelector = new ModelSelectorDefault(camera);

            Components.Add(modelSelector);

            _render = new Render(GraphicsDevice, camera, modelSelector, levelInfo);
            Components.Add(_render);

            Components.Add(new DebugTextComponent(GraphicsDevice, Components));

            base.Initialize();
        }
コード例 #2
0
        /// <summary>
        /// Invoked after either control has created its graphics device.
        /// </summary>
        private void GraphicsControl_OnLoadContent(object sender, GraphicsDeviceEventArgs e)
        {
            GraphicsDevice = e.GraphicsDevice;

            Camera = new Camera3DGemini(this);
            Camera.UpdateProjectionMatrix(45f, GraphicsDevice.Viewport.AspectRatio, 0.01f, 1000f);
            Components.Add(Camera);

            var modelSelector = new ModelSelectorDefault(Camera);

            Components.Add(modelSelector);

            Render = new Render(GraphicsDevice, Camera, modelSelector, SceneViewModel.LevelInfo);
            Components.Add(Render);

            Components.Add(new DebugTextComponent(GraphicsDevice, Components));

            Run();
            GraphicsControl.AlwaysRefresh = true;
        }