protected override void Initialize() { sceneManager = this.Services.GetService<SceneManager>(); sceneManager.GameObj = this; sceneManager.Initialized += OnSceneInitialized; sceneManager.Loaded += OnSceneLoaded; sceneManager.Unloaded += OnSceneUnloaded; keyboardManager = this.Services.GetService<KeyboardManager>(); keyboardManager.Pressed += OnKeyPressed; //add spriteBatch to services spriteBatch = new SpriteBatch(GraphicsDevice); this.Services.AddService(typeof(SpriteBatch), spriteBatch); //load input scene with first scene sceneManager.Load<PhysicsTestScene>(); base.Initialize(); }
private void InitializeServices() { if (SceneContent == null) { ContentManager content = game.Services.GetService<ContentManager>(); if (content == null) throw new SceneManagerException("the BIOXScene required ContentManager game service!"); SceneContent = new ContentManager(content.ServiceProvider, content.RootDirectory); cursorContent = new ContentManager(content.ServiceProvider, content.RootDirectory); } if (sceneManager == null) { sceneManager = game.Services.GetService<SceneManager>(); if (sceneManager == null) throw new SceneManagerException("the BIOXScene required SceneManager game service!"); } if (songManager == null) { songManager = game.Services.GetService<SongManager>(); if (songManager == null) { songManager = new SongManager(game); songManager.Initialize(); } } if (soundManager == null) { soundManager = game.Services.GetService<SoundManager>(); if (soundManager == null) { soundManager = new SoundManager(game); soundManager.Initialize(); } } if (keyboardManager == null) { keyboardManager = game.Services.GetService<KeyboardManager>(); if (keyboardManager == null) { keyboardManager = new KeyboardManager(game); keyboardManager.Initialize(); } } if (mouseManager == null) { mouseManager = game.Services.GetService<MouseManager>(); if (mouseManager == null) { mouseManager = new MouseManager(game); mouseManager.Initialize(); } } if (collision2DManager == null) { collision2DManager = game.Services.GetService<Collision2DManager>(); if (collision2DManager == null) { collision2DManager = new Collision2DManager(game); collision2DManager.Initialize(); } collision2DManager.EnableCollisionDetection = false; //disable for default } if (gravityManager == null) { gravityManager = game.Services.GetService<GravityManager>(); if (gravityManager == null) { gravityManager = new GravityManager(game); gravityManager.Initialize(); } } }