Exemple #1
0
        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;
        }
Exemple #2
0
        public ScorePage(
            AssetsLoader assets,
            ISettingsRepository settingsRepository,
            IScreenTransformationMatrixProvider matrixScaleProvider,
            ILocalizedStringsRepository localizedStringsRepository)
        {
            _font                = assets.Font;
            _background          = assets.OtherSprites["scoreBackground"];
            _matrixScaleProvider = matrixScaleProvider;

            _titleText          = localizedStringsRepository.Get(GameStringsLoader.ScorePageTitleString);
            _titleScalingObject = new ScalingObject(1f, 1.2f, 1.0f);
            _titleDrawingInfos  = new DrawingInfos()
            {
                Position = new Vector2(matrixScaleProvider.VirtualWidth / 2f, 100f),
                Origin   = _font.GetTextCenter(_titleText)
            };

            float textsScale = 0.4f;

            var bestFarts           = settingsRepository.GetOrSetInt(GameScores.BestFartsScoreKey, default);
            var bestNumberOfMeters  = settingsRepository.GetOrSetInt(GameScores.BestNumberOfMetersScoreKey, default);
            var bestVegetablesEaten = settingsRepository.GetOrSetInt(GameScores.BestVegetablesEatenScoreKey, default);

            _scoreInfos = new List <ScoreRecordText>()
            {
                new ScoreRecordText(
                    $"{localizedStringsRepository.Get(GameStringsLoader.BestNumberOfMetersScoreKey)}{bestNumberOfMeters}",
                    new DrawingInfos()
                {
                    Position     = new Vector2(_titleDrawingInfos.Position.X / 2, _titleDrawingInfos.Position.Y + 100f),
                    OverlayColor = Color.White.WithAlpha(0),
                    Scale        = textsScale
                }),

                new ScoreRecordText(
                    $"{localizedStringsRepository.Get(GameStringsLoader.BestVegetablesEatenScoreKey)}{bestVegetablesEaten}",
                    new DrawingInfos()
                {
                    Position     = new Vector2(_titleDrawingInfos.Position.X / 2, _titleDrawingInfos.Position.Y + 140f),
                    OverlayColor = Color.White.WithAlpha(0),
                    Scale        = textsScale
                }),

                new ScoreRecordText(
                    $"{localizedStringsRepository.Get(GameStringsLoader.BestFartsScoreKey)}{bestFarts}",
                    new DrawingInfos()
                {
                    Position     = new Vector2(_titleDrawingInfos.Position.X / 2, _titleDrawingInfos.Position.Y + 180f),
                    OverlayColor = Color.White.WithAlpha(0),
                    Scale        = textsScale
                }),
            };

            _nTexts        = _scoreInfos.Count;
            _currentTextId = 0;
            _fadeObject    = new FadeObject(TimeSpan.FromMilliseconds(500), Color.White);
            _fadeObject.FadeInCompleted += _textFadeObject_FadeInCompleted;
            _fadeObject.FadeIn();
        }
Exemple #3
0
        public RellowGame(
            IScreenTransformationMatrixProvider matrixScaleProvider,
            AssetsLoader assetsLoader,
            GameOrchestrator gameOrchestrator,
            SoundManager soundManager,
            ISettingsRepository settingsRepository,
            ILocalizedStringsRepository localizedStringsRepository)
        {
            _localizedStringsRepository = localizedStringsRepository;
            _matrixScaleProvider        = matrixScaleProvider ?? throw new ArgumentNullException(nameof(matrixScaleProvider));

            _gameButtonsManager = new GameButtonsManager(
                assetsLoader,
                localizedStringsRepository,
                new Vector2(60f, 800f));

            _scoreDifferentialPopups = new List <PopupText>();

            _soundManager       = soundManager ?? throw new ArgumentNullException(nameof(soundManager));
            _gameOrchestrator   = gameOrchestrator ?? throw new ArgumentNullException(nameof(gameOrchestrator));
            _settingsRepository = settingsRepository ?? throw new ArgumentNullException(nameof(settingsRepository));

            _currentGameState = GameStates.PlayingWaitingForInput;
            _gameColors       = new UIColors(_gameButtonsManager.SpawnableColors.Select(c => c.ColorGraphic).ToArray());

            _choiceTime = TimeSpan.FromSeconds(2.5);

            _backgroundRectangle = new Rectangle(0, 0, matrixScaleProvider.VirtualWidth, matrixScaleProvider.VirtualHeight);

            _scoreTextTitle = localizedStringsRepository.Get(GameStringsLoader.ScoreStringKey);

            _gameButtonsManager = new GameButtonsManager(
                assetsLoader,
                localizedStringsRepository,
                new Vector2(60f, 720f));
            _gameButtonsManager.OnLost += _gameButtonsManager_OnLost;
            _gameButtonsManager.OnWon  += _gameButtonsManager_OnWon;

            _writingFont = assetsLoader.WritingFont;

            _colorTextBackgroundRectangle = new Rectangle(
                0, 500,
                matrixScaleProvider.VirtualWidth,
                120);

            _numberOfVictories = 0;
            _score             = 0;

            _timeProgressBar = new ProgressBar(
                new Rectangle(
                    0, 0,
                    matrixScaleProvider.VirtualWidth,
                    matrixScaleProvider.VirtualHeight),
                _gameColors.TimerBarColor,
                (int)_choiceTime.TotalMilliseconds);

            UpdateScoreString();
            NewRound();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PackageLanguage{TImplementation}"/> class.
        /// </summary>
        /// <param name="packageName">Name of the package that the language is for.</param>
        /// <param name="rootCulture">Culture of the non-translated message text in code.</param>
        /// <exception cref="System.ArgumentNullException">
        /// If <paramref name="packageName"/> or <paramref name="rootCulture"/> are <c>null</c>.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// If <paramref name="packageName"/> is an empty string.
        /// </exception>
        protected PackageLanguage(string packageName, CultureInfo rootCulture)
            : base(packageName, rootCulture)
        {
            this.localizedStringsRepository = this.CreateLocalizedStringsRepository();
            this.languageDomain             = CreateLanguageDomain(this.localizedStringsRepository);

            this.Load();
        }
        public GameStringsLoader(ILocalizedStringsRepository localizedStringsRepository, CultureInfo cultureInfo)
        {
            if (cultureInfo.TwoLetterISOLanguageName == "it")
            {
                localizedStringsRepository.AddString(PlayButtonString, "gioca");
                localizedStringsRepository.AddString(ScoreButtonString, "punteggi");
                localizedStringsRepository.AddString(FartButtonString, "scoreggia");

                localizedStringsRepository.AddString(ScorePageTitleString, "Punteggi");
                localizedStringsRepository.AddString(BestNumberOfMetersScoreKey, "Maggior numero di metri percorsi: ");
                localizedStringsRepository.AddString(BestVegetablesEatenScoreKey, "Maggior numero di verdure mangiate: ");
                localizedStringsRepository.AddString(BestFartsScoreKey, "Maggior numero di scoregge: ");

                localizedStringsRepository.AddString(MetriTimeString, " metri");
                localizedStringsRepository.AddString(NumberOfMetersString, "Numero di metri: ");
                localizedStringsRepository.AddString(NumberOfVegetablesEaten, "Numero di verdure mangiate: ");
                localizedStringsRepository.AddString(NumbersOfFartsString, "Numero di scoregge flatulate: ");

                localizedStringsRepository.AddString(BeanPowerupText, "SEDERE IN TEMPESTA!");
                localizedStringsRepository.AddString(BroccoloPowerupText, "CAVALCA LA CACCA!");
            }
            else
            {
                localizedStringsRepository.AddString(PlayButtonString, "play");
                localizedStringsRepository.AddString(ScoreButtonString, "score");
                localizedStringsRepository.AddString(FartButtonString, "fart");

                localizedStringsRepository.AddString(ScorePageTitleString, "Score");
                localizedStringsRepository.AddString(BestNumberOfMetersScoreKey, "Highest number of meters: ");
                localizedStringsRepository.AddString(BestVegetablesEatenScoreKey, "Highest number of vegetables eaten: ");
                localizedStringsRepository.AddString(BestFartsScoreKey, "Highest number of farts: ");

                localizedStringsRepository.AddString(MetriTimeString, " meters");
                localizedStringsRepository.AddString(NumberOfMetersString, "Number of meters: ");
                localizedStringsRepository.AddString(NumberOfVegetablesEaten, "Number of vegetables eaten: ");
                localizedStringsRepository.AddString(NumbersOfFartsString, "Number of farts farted: ");

                localizedStringsRepository.AddString(BeanPowerupText, "ASS STORM!");
                localizedStringsRepository.AddString(BroccoloPowerupText, "RIDING ON A POO!");
            }
        }
Exemple #6
0
        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>());
        }
Exemple #7
0
        public GameButtonsManager(
            AssetsLoader assetsLoader,
            ILocalizedStringsRepository localizedStringsRepository,
            Vector2 startingPosition)
        {
            _buttons             = new GameButton[_totalNumberOfButtons];
            _activeButtonsNumber = 3;
            _startingPosition    = startingPosition;

            SpawnableColors = new ColorWithName[]
            {
                new ColorWithName(
                    Color.Yellow,
                    localizedStringsRepository.Get(GameStringsLoader.YellowColorKey),
                    localizedStringsRepository.Get(GameStringsLoader.SecondaryLanguageYellowColorKey)),

                new ColorWithName(
                    Color.Red,
                    localizedStringsRepository.Get(GameStringsLoader.RedColorKey),
                    localizedStringsRepository.Get(GameStringsLoader.SecondaryLanguageRedColorKey)),

                new ColorWithName(
                    Color.Blue,
                    localizedStringsRepository.Get(GameStringsLoader.BlueColorKey),
                    localizedStringsRepository.Get(GameStringsLoader.SecondaryLanguageBlueColorKey)),

                new ColorWithName(
                    new Color(0, 255, 0),
                    localizedStringsRepository.Get(GameStringsLoader.GreenColorKey),
                    localizedStringsRepository.Get(GameStringsLoader.SecondaryLanguageGreenColorKey)),

                new ColorWithName(
                    new Color(255, 115, 0),
                    localizedStringsRepository.Get(GameStringsLoader.OrangeColorKey),
                    localizedStringsRepository.Get(GameStringsLoader.SecondaryLanguageOrangeColorKey)),

                new ColorWithName(
                    new Color(255, 0, 255),
                    localizedStringsRepository.Get(GameStringsLoader.VioletColorKey),
                    localizedStringsRepository.Get(GameStringsLoader.SecondaryLanguageVioletColorKey)),

                new ColorWithName(
                    new Color(150, 150, 150),
                    localizedStringsRepository.Get(GameStringsLoader.GrayColorKey),
                    localizedStringsRepository.Get(GameStringsLoader.SecondaryLanguageGrayColorKey)),

                new ColorWithName(
                    Color.White,
                    localizedStringsRepository.Get(GameStringsLoader.WhiteColorKey),
                    localizedStringsRepository.Get(GameStringsLoader.SecondaryLanguageWhiteColorKey)),

                new ColorWithName(
                    new Color(0, 255, 255),
                    localizedStringsRepository.Get(GameStringsLoader.LightBlueColorKey),
                    localizedStringsRepository.Get(GameStringsLoader.SecondaryLanguageLightBlueColorKey))
            };

            for (int c = 0; c < 3; ++c)
            {
                for (int r = 0; r < 3; ++r)
                {
                    int index = (c * 3) + r;
                    _buttons[index] = new GameButton(
                        assetsLoader,
                        _squaredButtonSize,
                        SpawnableColors[index]);
                }
            }
        }
Exemple #8
0
        public OverlayPopup(
            string title,
            string text,
            SpriteFont font,
            IScreenTransformationMatrixProvider matrixScaleProvider,
            ILocalizedStringsRepository localizedStringsRepository,
            Action playAgainFunction,
            Action exitFunction)
        {
            _font = font;

            _backgroundRectangle = new Rectangle(0, 0, matrixScaleProvider.VirtualWidth, matrixScaleProvider.VirtualHeight);
            _backgroundColor     = Color.Gray.WithAlpha(0.7f);

            int popupRectangleWidth = 900;

            _popupRectangle = new Rectangle(
                (matrixScaleProvider.VirtualWidth - popupRectangleWidth) / 2, 260,
                popupRectangleWidth, popupRectangleWidth + 200);
            _popupBackgroundColor = Definitions.PrimaryBackgroundColor.WithAlpha(1f);

            _popupRectangleShadow = new Rectangle(
                _popupRectangle.X + 15,
                _popupRectangle.Y + 15,
                _popupRectangle.Width,
                _popupRectangle.Height);
            _popupShadowBackgroundColor = Color.Black.WithAlpha(1f);

            _titleDrawingInfos = new DrawingInfos()
            {
                Position = new Vector2(
                    matrixScaleProvider.VirtualWidth / 2,
                    _popupRectangle.Y + _popupRectangle.Height / 4),
                Origin       = _font.GetTextCenter(title),
                OverlayColor = Color.Black
            };

            _textDrawingInfos = new DrawingInfos()
            {
                Position     = _titleDrawingInfos.Position + new Vector2(0f, 200f),
                Origin       = _font.GetTextCenter(text),
                Scale        = 0.6f,
                OverlayColor = Color.White
            };

            TitleText = title;
            Text      = text;

            _playAgainButton = new FloatingTextButton(
                localizedStringsRepository.Get(GameStringsLoader.PlayAgainStringKey),
                new DrawingInfos()
            {
                Position     = _textDrawingInfos.Position + new Vector2(0f, 250f),
                Origin       = _font.GetTextCenter(localizedStringsRepository.Get(GameStringsLoader.PlayAgainStringKey)),
                OverlayColor = Definitions.PrimaryForegroundColor,
            },
                _font,
                playAgainFunction,
                0.7f, 0.8f);

            _exitButton = new FloatingTextButton(
                localizedStringsRepository.Get(GameStringsLoader.ExitStringKey),
                new DrawingInfos()
            {
                Position     = _textDrawingInfos.Position + new Vector2(0f, 450f),
                Origin       = _font.GetTextCenter(localizedStringsRepository.Get(GameStringsLoader.ExitStringKey)),
                OverlayColor = Definitions.PrimaryForegroundColor
            },
                _font,
                exitFunction,
                0.7f, 0.8f);
        }
 /// <summary>
 /// Creates the <see cref="ILanguageDomain"/> for the package.
 /// </summary>
 /// <param name="localizedStringsRepository">The localized string repository.</param>
 /// <returns>
 /// The <see cref="ILanguageDomain"/> instance.
 /// </returns>
 protected virtual ILanguageDomain CreateLanguageDomain(ILocalizedStringsRepository localizedStringsRepository)
 {
     return(new LanguageDomain(localizedStringsRepository));
 }
        public MainMenuPage(
            AssetsLoader assetsLoader,
            GameOrchestrator gameOrchestrator,
            IScreenTransformationMatrixProvider matrixScaleProvider,
            ILocalizedStringsRepository localizedStringsRepository,
            RateMeDialog rateMeDialog,
            ISettingsRepository settingsRepository)
        {
            _backgroundRectangle = new Rectangle(0, 0, matrixScaleProvider.VirtualWidth, matrixScaleProvider.VirtualHeight);

            var titleFont = assetsLoader.TitleFont;

            _writingFont  = assetsLoader.WritingFont;
            _rateMeDialog = rateMeDialog ?? throw new ArgumentNullException(nameof(rateMeDialog));

            const string titleText = "RELLOW";

            _title = new FloatingText(
                titleText,
                new DrawingInfos()
            {
                Position     = new Vector2(matrixScaleProvider.VirtualWidth / 2f, 250f),
                Origin       = titleFont.GetTextCenter(titleText),
                OverlayColor = _foregroundColor
            },
                titleFont);

            var playText = localizedStringsRepository.Get(GameStringsLoader.PlayStringKey);

            _playButton = new FloatingTextButton(
                playText,
                new DrawingInfos()
            {
                Position     = new Vector2(matrixScaleProvider.VirtualWidth / 2f, 850f),
                Origin       = _writingFont.GetTextCenter(playText),
                OverlayColor = _foregroundColor
            },
                _writingFont,
                () =>
            {
                gameOrchestrator.SetGameState();
            });

            var aboutText = localizedStringsRepository.Get(GameStringsLoader.AboutStringKey);

            _aboutButton = new FloatingTextButton(
                aboutText,
                new DrawingInfos()
            {
                Position     = new Vector2(matrixScaleProvider.VirtualWidth / 2f, 1150f),
                Origin       = _writingFont.GetTextCenter(aboutText),
                OverlayColor = _foregroundColor
            },
                _writingFont,
                () =>
            {
                gameOrchestrator.SetAboutState();
            });

            var currentScore = settingsRepository.GetOrSetInt(Definitions.SCORE_KEY, 0);

            _scoreText         = $"{localizedStringsRepository.Get(GameStringsLoader.ScoreStringKey)}:{currentScore}";
            _scoreDrawingInfos = new DrawingInfos()
            {
                Position     = new Vector2(matrixScaleProvider.VirtualWidth / 2f, matrixScaleProvider.VirtualHeight - 250f - 200f),
                Origin       = _writingFont.GetTextCenter(_scoreText),
                OverlayColor = _scoreColor,
                Scale        = 0.5f
            };
        }
Exemple #11
0
        public GameOverPage(
            IScreenTransformationMatrixProvider matrixScaleProvider,
            AssetsLoader assets,
            ISettingsRepository settingsRepository,
            int thisGameNumberOfVegetablesEaten,
            int thisGameNumberOfMeters,
            int thisGameNumberOfFarts,
            ILocalizedStringsRepository localizedStringsRepository)
        {
            _font                = assets.Font;
            _background          = assets.OtherSprites["gameoverBackground"];
            _matrixScaleProvider = matrixScaleProvider;

            _gameOverTextDrawingInfos = new DrawingInfos()
            {
                Position = new Vector2()
                {
                    X = matrixScaleProvider.VirtualWidth / 2f, Y = 100f
                },
                Origin = _font.GetTextCenter(_gameOverText)
            };
            _gameOverScalingObject = new ScalingObject(1f, 1.2f, 1.0f);

            var bestFarts           = settingsRepository.GetOrSetInt(GameScores.BestFartsScoreKey, default(int));
            var bestNumberOfMeters  = settingsRepository.GetOrSetInt(GameScores.BestNumberOfMetersScoreKey, default(int));
            var bestVegetablesEaten = settingsRepository.GetOrSetInt(GameScores.BestVegetablesEatenScoreKey, default(int));

            var bestNumberOfVegetablesEatenRecord = false;

            if (thisGameNumberOfVegetablesEaten > bestVegetablesEaten)
            {
                settingsRepository.SetInt(GameScores.BestVegetablesEatenScoreKey, thisGameNumberOfVegetablesEaten);
                bestNumberOfVegetablesEatenRecord = true;
            }

            var bestAliveTimeRecord = false;

            if (thisGameNumberOfMeters > bestNumberOfMeters)
            {
                settingsRepository.SetInt(GameScores.BestNumberOfMetersScoreKey, thisGameNumberOfMeters);
                bestAliveTimeRecord = true;
            }

            var bestNumberOfFartsRecord = false;

            if (thisGameNumberOfFarts > bestFarts)
            {
                settingsRepository.SetInt(GameScores.BestFartsScoreKey, thisGameNumberOfFarts);
                bestNumberOfFartsRecord = true;
            }

            const float textsScale = 0.4f;

            _scoreInfos = new List <ScoreRecordText>()
            {
                new ScoreRecordText(
                    $"{localizedStringsRepository.Get(GameStringsLoader.NumberOfMetersString)}{thisGameNumberOfMeters}",
                    new DrawingInfos()
                {
                    Position     = new Vector2(_gameOverTextDrawingInfos.Position.X / 2, _gameOverTextDrawingInfos.Position.Y + 200f),
                    OverlayColor = Color.White.WithAlpha(0),
                    Scale        = textsScale
                },
                    !bestAliveTimeRecord ? "       " : "Record!"),

                new ScoreRecordText(
                    $"{localizedStringsRepository.Get(GameStringsLoader.NumbersOfFartsString)}{thisGameNumberOfFarts}",
                    new DrawingInfos()
                {
                    Position     = new Vector2(_gameOverTextDrawingInfos.Position.X / 2, _gameOverTextDrawingInfos.Position.Y + 125f),
                    OverlayColor = Color.White.WithAlpha(0),
                    Scale        = textsScale
                },
                    !bestNumberOfFartsRecord ? "       " : "Record!"),

                new ScoreRecordText(
                    $"{localizedStringsRepository.Get(GameStringsLoader.NumberOfVegetablesEaten)}{thisGameNumberOfVegetablesEaten}",
                    new DrawingInfos()
                {
                    Position     = new Vector2(_gameOverTextDrawingInfos.Position.X / 2, _gameOverTextDrawingInfos.Position.Y + 162f),
                    OverlayColor = Color.White.WithAlpha(0),
                    Scale        = textsScale
                },
                    !bestNumberOfVegetablesEatenRecord ? "       " : "Record!"),
            };

            _nTexts        = _scoreInfos.Count;
            _currentTextId = 0;
            _fadeObject    = new FadeObject(TimeSpan.FromMilliseconds(200), Color.White);
            _fadeObject.FadeInCompleted += _textFadeObject_FadeInCompleted;
            _fadeObject.FadeIn();
        }
Exemple #12
0
        public GameStringsLoader(ILocalizedStringsRepository localizedStringsRepository, CultureInfo cultureInfo)
        {
            if (cultureInfo.TwoLetterISOLanguageName == "it")
            {
                localizedStringsRepository.AddString(YellowColorKey, "Giallo");
                localizedStringsRepository.AddString(RedColorKey, "Rosso");
                localizedStringsRepository.AddString(GreenColorKey, "Verde");
                localizedStringsRepository.AddString(BlueColorKey, "Blu");
                localizedStringsRepository.AddString(OrangeColorKey, "Arancione");
                localizedStringsRepository.AddString(GrayColorKey, "Grigio");
                localizedStringsRepository.AddString(WhiteColorKey, "Bianco");
                localizedStringsRepository.AddString(VioletColorKey, "Viola");
                localizedStringsRepository.AddString(LightBlueColorKey, "Azzurro");

                localizedStringsRepository.AddString(SecondaryLanguageYellowColorKey, "Yellow");
                localizedStringsRepository.AddString(SecondaryLanguageRedColorKey, "Red");
                localizedStringsRepository.AddString(SecondaryLanguageGreenColorKey, "Green");
                localizedStringsRepository.AddString(SecondaryLanguageBlueColorKey, "Blue");
                localizedStringsRepository.AddString(SecondaryLanguageOrangeColorKey, "Orange");
                localizedStringsRepository.AddString(SecondaryLanguageGrayColorKey, "Gray");
                localizedStringsRepository.AddString(SecondaryLanguageWhiteColorKey, "White");
                localizedStringsRepository.AddString(SecondaryLanguageVioletColorKey, "Violet");
                localizedStringsRepository.AddString(SecondaryLanguageLightBlueColorKey, "Light blue");

                localizedStringsRepository.AddString(PlayStringKey, "Gioca");
                localizedStringsRepository.AddString(AboutStringKey, "About");
                localizedStringsRepository.AddString(PlayAgainStringKey, "Gioca ancora");
                localizedStringsRepository.AddString(ExitStringKey, "Esci");
                localizedStringsRepository.AddString(ScoreStringKey, "Punti");
                localizedStringsRepository.AddString(GlobalRankStringKey, "Pos. globale");
                localizedStringsRepository.AddString(GlobalRankLoadingStringKey, "Caricamento classifica...");
                localizedStringsRepository.AddString(GlobalRankCurrentlyUnavailableKey, "Classifica non disponibile");
            }
            else
            {
                localizedStringsRepository.AddString(YellowColorKey, "Yellow");
                localizedStringsRepository.AddString(RedColorKey, "Red");
                localizedStringsRepository.AddString(GreenColorKey, "Green");
                localizedStringsRepository.AddString(BlueColorKey, "Blue");
                localizedStringsRepository.AddString(OrangeColorKey, "Orange");
                localizedStringsRepository.AddString(GrayColorKey, "Gray");
                localizedStringsRepository.AddString(WhiteColorKey, "White");
                localizedStringsRepository.AddString(VioletColorKey, "Violet");
                localizedStringsRepository.AddString(LightBlueColorKey, "Light blue");

                localizedStringsRepository.AddString(SecondaryLanguageYellowColorKey, "Yellow");
                localizedStringsRepository.AddString(SecondaryLanguageRedColorKey, "Red");
                localizedStringsRepository.AddString(SecondaryLanguageGreenColorKey, "Green");
                localizedStringsRepository.AddString(SecondaryLanguageBlueColorKey, "Blue");
                localizedStringsRepository.AddString(SecondaryLanguageOrangeColorKey, "Orange");
                localizedStringsRepository.AddString(SecondaryLanguageGrayColorKey, "Gray");
                localizedStringsRepository.AddString(SecondaryLanguageWhiteColorKey, "White");
                localizedStringsRepository.AddString(SecondaryLanguageVioletColorKey, "Violet");
                localizedStringsRepository.AddString(SecondaryLanguageLightBlueColorKey, "Light blue");

                localizedStringsRepository.AddString(PlayStringKey, "Play");
                localizedStringsRepository.AddString(AboutStringKey, "About");
                localizedStringsRepository.AddString(PlayAgainStringKey, "Play again");
                localizedStringsRepository.AddString(ExitStringKey, "Exit");
                localizedStringsRepository.AddString(ScoreStringKey, "Score");
                localizedStringsRepository.AddString(GlobalRankStringKey, "Global rank");
                localizedStringsRepository.AddString(GlobalRankLoadingStringKey, "Loading leaderboard...");
                localizedStringsRepository.AddString(GlobalRankCurrentlyUnavailableKey, "Leaderboard not available");
            }
        }
Exemple #13
0
        public MainMenuPage(
            AssetsLoader assets,
            RateMeDialog rateMeDialog,
            SoundManager soundManager,
            IScreenTransformationMatrixProvider matrixScaleProvider,
            ILocalizedStringsRepository localizedStringsRepository)
        {
            _font = assets.Font;
            _matrixScaleProvider = matrixScaleProvider;
            _rateMeDialog        = rateMeDialog ?? throw new ArgumentNullException(nameof(rateMeDialog));
            _soundManager        = soundManager ?? throw new ArgumentNullException(nameof(soundManager));

            _background      = assets.OtherSprites["menuBackground"];
            _playText        = localizedStringsRepository.Get(GameStringsLoader.PlayButtonString);
            _scoreText       = localizedStringsRepository.Get(GameStringsLoader.ScoreButtonString);
            _fartText        = localizedStringsRepository.Get(GameStringsLoader.FartButtonString);
            _titleImage      = assets.OtherSprites["gameTitle"];
            _achievementText = "about";

            _titleScalingObject = new ScalingObject(1f, 1.2f, 1.0f);
            _titleDrawingInfos  = new DrawingInfos()
            {
                Position = new Vector2(matrixScaleProvider.VirtualWidth / 2f, 100f),
                Origin   = _titleImage.SpriteCenter
            };

            _playScalingObject = new ScalingObject(0.5f, 0.7f, 1f);
            _playDrawingInfos  = new DrawingInfos()
            {
                Position = new Vector2(140f, 250f),
                Origin   = _font.GetTextCenter(_playText)
            };
            _playTextSize = _font.MeasureString(_playText);

            _fartScalingObject = new ScalingObject(0.5f, 0.7f, 1f);
            _fartDrawingInfos  = new DrawingInfos()
            {
                Position     = new Vector2(140f, 320f),
                Origin       = _font.GetTextCenter(_fartText),
                OverlayColor = new Color(155, 88, 48)
            };
            _fartTextSize = _font.MeasureString(_fartText);

            _scoreTextSize      = _font.MeasureString(_scoreText);
            _scoreScalingObject = new ScalingObject(0.5f, 0.7f, 1f);
            _scoreDrawingInfos  = new DrawingInfos()
            {
                Position = new Vector2(matrixScaleProvider.VirtualWidth - 150f, 250f),
                Origin   = _font.GetTextCenter(_scoreText)
            };

            _aboutTextSize      = _font.MeasureString(_achievementText);
            _aboutScalingObject = new ScalingObject(0.5f, 0.7f, 1f);
            _aboutDrawingInfos  = new DrawingInfos()
            {
                Position = new Vector2(matrixScaleProvider.VirtualWidth - 150f, 320f),
                Origin   = _font.GetTextCenter(_achievementText)
            };

            _soundManager.PlayMenuBackground();
        }
Exemple #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LanguageDomain"/> class.
        /// </summary>
        /// <param name="repository">Repository for accessing localized strings within
        /// the language domain.</param>
        /// <exception cref="System.ArgumentNullException">
        /// If <paramref name="repository"/> is <c>null</c>.
        /// </exception>
        public LanguageDomain(ILocalizedStringsRepository repository)
        {
            ExceptionUtility.CheckArgumentNotNull(repository, "repository");

            this.repository = repository;
        }
Exemple #15
0
        /// <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();
        }