public GalaxyMapControl(IServiceProvider services)
 {
     Name = "Galaxy View";
     HorizontalAlignment = HorizontalAlignment.Stretch;
     VerticalAlignment = VerticalAlignment.Stretch;
     _spritebatch = (SpriteBatch)services.GetService(typeof(SpriteBatch));
     _content = (ContentController)services.GetService(typeof(ContentController));
     _gameManager = (GameManager)services.GetService(typeof(GameManager));
     _parallax1SpeedMod = 1.5f;
     _parallax2SpeedMod = 2f;
 }
 private void LoadServices(IServiceProvider services)
 {
     _content = (ContentController)services.GetService(typeof(ContentController));
     _gameManager = (GameManager)services.GetService(typeof(GameManager));
 }
 public GameScreenBase(IServiceProvider services)
 {
     _content = (ContentController)services.GetService(typeof(ContentController));
     _gameManager = (GameManager)services.GetService(typeof(GameManager));
 }
Esempio n. 4
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();
        }