Esempio n. 1
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();
        }
Esempio n. 2
0
 public FloatingText(
     string text,
     DrawingInfos drawingInfos,
     SpriteFont font,
     float minScale = 1.0f,
     float maxScale = 1.2f)
 {
     _text          = text;
     _drawingInfos  = drawingInfos;
     _scalingObject = new ScalingObject(minScale, maxScale, 1.0f);
     _font          = font;
 }
Esempio n. 3
0
        public ScoreRecordText(
            string scoreText,
            DrawingInfos textDrawingInfos,
            string recordText = null)
        {
            ScoreText        = scoreText;
            TextDrawingInfos = textDrawingInfos;
            RecordText       = recordText;
            int positionToAdd = recordText == null ? 0 : 100;

            textDrawingInfos.Position = new Vector2(
                textDrawingInfos.Position.X + positionToAdd,
                textDrawingInfos.Position.Y);
            RecordTextDrawingInfos = new DrawingInfos()
            {
                Position     = textDrawingInfos.Position - new Vector2(150f, 0f),
                Scale        = textDrawingInfos.Scale,
                OverlayColor = _recordColor
            };

            _recordScalingObject = new ScalingObject(textDrawingInfos.Scale - 0.01f, textDrawingInfos.Scale + 0.01f);
        }
Esempio n. 4
0
 public PopupText()
 {
     _scalingObject = new ScalingObject(1f, 1.8f, 2f);
 }
Esempio n. 5
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();
        }
Esempio n. 6
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();
        }