private void LoadServices(IServiceProvider services)
 {
     _consoleManager = (ConsoleManager)services.GetService(typeof(ConsoleManager));
     _galaxyManager = (GalaxyManager)services.GetService(typeof(GalaxyManager));
 }
Beispiel #2
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()
        {
            // TODO: Add your initialization logic here

            // The services are stored in Game.Services to make them accessible by all
            // game components.

            _spriteBatch = new SpriteBatch(GraphicsDevice);
            Services.AddService(typeof(SpriteBatch), _spriteBatch);

            Services.AddService(typeof(ContentManager), Content);

            // Add the input service, which manages device input, button presses, etc.
            _inputManager = new InputManager(false);
            Services.AddService(typeof(IInputService), _inputManager);

            // Add the UI service, which manages UI screens.
            _uiManager = new UIManager(this, _inputManager);
            Services.AddService(typeof(IUIService), _uiManager);

            // Add the animation service.
            _animationManager = new AnimationManager();
            Services.AddService(typeof(IAnimationService), _animationManager);

            _consoleManager = new ConsoleManager();
            Services.AddService(typeof(ConsoleManager), _consoleManager);

            _contentController = new ContentController(GraphicsDevice, Content);
            _contentController.LoadContent();
            Services.AddService(typeof(ContentController), _contentController);

            _gameContentManager = new GameContentManager(Services);
            _gameContentManager.LoadGameContent();
            Services.AddService(typeof(GameContentManager), _gameContentManager);

            _galaxyManager = new GalaxyManager(Services);
            Services.AddService(typeof(GalaxyManager), _galaxyManager);

            _gameManager = new GameManager(Services);
            _gameManager.NewGame();
            Services.AddService(typeof(GameManager), _gameManager);

            _eventManager = new EventManager();
            Services.AddService(typeof(EventManager), _eventManager);

            // ----- Add GameComponents
            // The component that shows the individual screen.
            Components.Add(new CentauriGame(this));

            base.Initialize();
        }