Esempio n. 1
0
        protected override void Initialize()
        {
            //Init spritebatch for drawing
            SpriteBatch = new SpriteBatch(GraphicsDevice);

            //Init event manager
            EventManager = new EventManager();

            //Init input manager
            InputManager = new InputManager(EventManager, new InputConfig());

            //Init Scene Manager
            SceneManager = new SceneManager(Content, GraphicsManager, EventManager);

            //Add scenes to scene manager
            SceneManager.AddScene(new Scene[] {
                new TestScene2(),
                new TestScene(),
                new DebugScene()
            });

            //start first scene
            SceneManager.StartScene(nameof(TestScene));

            //Launch second scene in parallel
            SceneManager.LaunchScene(nameof(TestScene2));

            //global key press event
            EventManager.AddEventListener("keypress", (Event) =>
            {
                //Enable debug
                switch (Event.Keyboard.KeyEnum)
                {
                case Keys.F3:

                    Console.WriteLine("Launching Debug Scene");

                    if (SceneManager.ActiveSceneExist(nameof(DebugScene)))
                    {
                        SceneManager.StopScene(nameof(DebugScene));
                    }
                    else
                    {
                        SceneManager.LaunchScene(nameof(DebugScene));
                    }

                    break;
                    //case Keys.F4:
                    //    GraphicsManager.ToggleFullScreen();
                    //    break;
                }
            });

            base.Initialize();
        }