public GameOrchestrator( Func <RellowGame> gameFactory, Func <MainMenuPage> menuFactory, GraphicsDevice graphicsDevice, IScreenTransformationMatrixProvider matrixScaleProvider, SoundManager soundManager, IWebPageOpener webPageOpener) { _gameFactory = gameFactory ?? throw new ArgumentNullException(nameof(gameFactory)); _menuFactory = menuFactory ?? throw new ArgumentNullException(nameof(menuFactory)); _webPageOpener = webPageOpener ?? throw new ArgumentNullException(nameof(webPageOpener)); _soundManager = soundManager ?? throw new ArgumentNullException(nameof(soundManager)); _graphicsDevice = graphicsDevice ?? throw new ArgumentNullException(nameof(graphicsDevice)); _matrixScaleProvider = matrixScaleProvider ?? throw new ArgumentNullException(nameof(matrixScaleProvider)); if (_matrixScaleProvider is DynamicScalingMatrixProvider) { (_matrixScaleProvider as DynamicScalingMatrixProvider).ScaleMatrixChanged += GameOrchestrator_ScaleMatrixChanged; } RegenerateRenderTarget(); ShouldEndApplication = false; _stateTransition = new FadeObject(_fadeDuration, Color.White); _stateTransition.FadeOutCompleted += _stateTransition_FadeOutCompleted; }
public GameOrchestrator( Func <InfartGame> gameFactory, Func <MainMenuPage> menuFactory, Func <ScorePage> scoreFactory, GraphicsDevice graphicsDevice, AssetsLoader assets, ISettingsRepository settingsRepository, IScreenTransformationMatrixProvider matrixScaleProvider, IWebPageOpener webPageOpener, ILocalizedStringsRepository localizedStringsRepository) { _gameFactory = gameFactory ?? throw new ArgumentNullException(nameof(gameFactory)); _menuFactory = menuFactory ?? throw new ArgumentNullException(nameof(menuFactory)); _scoreFactory = scoreFactory ?? throw new ArgumentNullException(nameof(scoreFactory)); _webPageOpener = webPageOpener ?? throw new ArgumentNullException(nameof(webPageOpener)); _graphicsDevice = graphicsDevice ?? throw new ArgumentNullException(nameof(graphicsDevice)); _assets = assets ?? throw new ArgumentNullException(nameof(assets)); _settingsRepository = settingsRepository ?? throw new ArgumentNullException(nameof(settingsRepository)); _localizedStringsRepository = localizedStringsRepository ?? throw new ArgumentNullException(nameof(localizedStringsRepository)); _matrixScaleProvider = matrixScaleProvider ?? throw new ArgumentNullException(nameof(matrixScaleProvider)); if (_matrixScaleProvider is DynamicScalingMatrixProvider) { (_matrixScaleProvider as DynamicScalingMatrixProvider).ScaleMatrixChanged += GameOrchestrator_ScaleMatrixChanged; } RegenerateRenderTarget(); ShouldEndApplication = false; _stateTransition = new FadeObject(_fadeDuration, Color.White); _stateTransition.FadeOutCompleted += _stateTransition_FadeOutCompleted; }
public InfartBootstrap( ITextFileLoader textFileAssetsLoader, ISettingsRepository settingsRepository, IWebPageOpener webPageOpener, CultureInfo gameCulture, bool isPc, bool isFullScreen, Uri rateMeUri, int?deviceWidth = null, int?deviceHeight = null) { _isPc = isPc; Window.Title = GameName; _rateMeUri = rateMeUri; _currentState = RunningStates.Splashscreen; _textFileAssetsLoader = textFileAssetsLoader; _settingsRepository = settingsRepository; _webPageOpener = webPageOpener; _gameCulture = gameCulture; GraphicsDeviceManager = new GraphicsDeviceManager(this) { SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeLeft, IsFullScreen = isFullScreen }; if (deviceWidth != null && deviceHeight != null) { GraphicsDeviceManager.PreferredBackBufferWidth = deviceWidth.Value; GraphicsDeviceManager.PreferredBackBufferHeight = deviceHeight.Value; } _localizedStringsRepository = new InMemoryLocalizedStringsRepository(new Dictionary <string, string>()); }
/// <summary> /// Constructs the dialog /// </summary> /// <param name="launchesUntilPrompt"></param> /// <param name="maxRateShowTimes"></param> /// <param name="rateAppUri"></param> /// <param name="dialogDefinition"></param> /// <param name="font"></param> /// <param name="localizedStringsRepository"></param> /// <param name="rateMeDialogStrings"></param> /// <param name="webPageOpener"></param> /// <param name="settingsRepository"></param> /// <param name="buttonADefinition"></param> /// <param name="buttonBDefinition"></param> /// <param name="backgroundColor"></param> /// <param name="buttonsBackgroundColor"></param> /// <param name="buttonsShadowColor"></param> /// <param name="backgroundShadowColor"></param> /// <param name="titleColor"></param> /// <param name="buttonsTextColor"></param> /// <param name="titlePositionOffset"></param> /// <param name="buttonTextPadding"></param> /// <param name="titlePadding"></param> public RateMeDialog( int launchesUntilPrompt, int maxRateShowTimes, Uri rateAppUri, Rectangle dialogDefinition, SpriteFont font, ILocalizedStringsRepository localizedStringsRepository, RateMeDialogStrings rateMeDialogStrings, IWebPageOpener webPageOpener, ISettingsRepository settingsRepository, Rectangle buttonADefinition, Rectangle buttonBDefinition, Color backgroundColor, Color buttonsBackgroundColor, Color buttonsShadowColor, Color backgroundShadowColor, Color titleColor, Color buttonsTextColor, Vector2 titlePositionOffset, float buttonTextPadding, float titlePadding) { _launchesUntilPrompt = launchesUntilPrompt; _maxRateShowTimes = maxRateShowTimes; _rateAppUri = rateAppUri; _localizedStringsRepository = localizedStringsRepository; _settingsRepository = settingsRepository; AddStrings(rateMeDialogStrings); var buttonA = new ButtonWithText( font: font, text: localizedStringsRepository.Get(_rateItButtonTextKey), collisionRectangle: buttonADefinition, backgroundColor: buttonsBackgroundColor, textColor: buttonsTextColor, shadowColor: buttonsShadowColor, onClick: () => { _settingsRepository.SetBool(_dontShowAgainSettingKey, true); ShouldShowDialog = false; webPageOpener.OpenWebpage(_rateAppUri); }, textPadding: buttonTextPadding); var buttonB = new ButtonWithText( font: font, text: localizedStringsRepository.Get(_notNowButtonTextKey), collisionRectangle: buttonBDefinition, backgroundColor: buttonsBackgroundColor, textColor: buttonsTextColor, shadowColor: buttonsShadowColor, onClick: () => { // If users says "Not now", I reset the app launch count _settingsRepository.SetInt(_appLaunchCountSettingKey, 0); ShouldShowDialog = false; }, textPadding: buttonTextPadding); var minScale = Math.Min(buttonA.TextScale, buttonB.TextScale); buttonA.TextScale = minScale; buttonB.TextScale = minScale; _titleButtonButtonDialog = new Dialog( title: localizedStringsRepository.Get(_messageTextKey), font: font, dialogWindowDefinition: dialogDefinition, titlePositionOffset: titlePositionOffset, backgroundColor: backgroundColor, backgroundShadowColor: backgroundShadowColor, titleColor: titleColor, titlePadding: titlePadding, buttons: new ButtonWithText[] { buttonA, buttonB }); EvaluateRateMe(); }