/// <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() { _spriteBatch = new SpriteBatch(GraphicsDevice); _gameAudioManager = new GameAudioManager(); _gameAudioManager.Initialize(); var screenSizeManager = new ScreenSizeManager( _graphics, new ScreenResolutionConverter(), GameConstants.GameSetupConstants.VirtualResolution); //ToDo Remove this line once player preference settings are implemented screenSizeManager.SetScreenResolution(ScreenResolutionOption.SRO_1920X1080); _gameContext = new GameContext( this, _spriteBatch, screenSizeManager, _gameAudioManager); _gameContext.StateMachine.AddState(new SplashState(_gameContext, new SplashStateGraphicsComponent(_gameContext)), false); //_gameContext.StateMachine.ActiveState.Initialize(); base.Initialize(); }
public GameContext(Microsoft.Xna.Framework.Game game, SpriteBatch spriteBatch, IScreenSizeManager screenSizeManager, IGameAudioManager gameAudioManager) { _game = game ?? throw new ArgumentNullException(nameof(game)); if (spriteBatch == null) { throw new ArgumentNullException(nameof(spriteBatch)); } if (screenSizeManager == null) { throw new ArgumentNullException(nameof(screenSizeManager)); } GameGraphics = new GameGraphics(spriteBatch, screenSizeManager, new TrackingCamera2D(this) { Zoom = 1f }); GameAudio = gameAudioManager ?? throw new ArgumentNullException(nameof(gameAudioManager)); Random = new Random(); AssetManager = new AssetManager(_game); StateMachine = new GameStateMachine(); MenuFactory = new MenuFactory(this); CollisionSystem = new BasicCollisionSystem(); NotificationMediator = new NotificationMediator(); }