Esempio n. 1
0
        private void Awake()
        {
            _settingsProvider = new PlayerPrefsSettingProvider();
#if UNITY_EDITOR || UNITY_STANDALONE
            _inputService = new KeyboardInput();
#elif (UNITY_ANDROID || UNITY_IOS)
            _inputService = new MobileInput();
#endif
            CreateBall();
            CreateRackets();

            _scoreCounter          = new ScoreCounter.ScoreCounter();
            _ball.OnBallHitRacket += _scoreCounter.IncrementScore;
            _ball.OnBallRestart   += _scoreCounter.ResetScore;

            _scoreCounterText             = new ScoreCounterText(scoreCounterTextGo);
            _scoreCounter.OnScoreUpdated += _scoreCounterText.UpdateScore;

            _bestScoreUpdater             = new BestScoreUpdater(_settingsProvider);
            _scoreCounter.OnScoreUpdated += _bestScoreUpdater.UpdateScore;
            _ball.OnBallRestart          += _bestScoreUpdater.SaveToDisk;

            _bestScoreCounterText = new ScoreCounterText(bestScoreCounterTextGo, _settingsProvider.GetBestScore());
            _bestScoreUpdater.OnBestScoreUpdated += _bestScoreCounterText.UpdateScore;
        }
Esempio n. 2
0
 public BestScoreUpdater(ISettingsProvider settingsProvider)
 {
     _settingsProvider = settingsProvider;
     _currentBestScore = _settingsProvider.GetBestScore();
 }