public void CheckAndUpdateHighScore()
 {
     if (_scoreManager.IsNewHighScore())
     {
         _uiManager.SetHighScoreUI(_scoreManager.GetHighScore());
         _uiManager.SetMainMenuHighScoreUI(_scoreManager.GetHighScore());
         _scoreManager.SetHighScore(_scoreManager.GetScore());
         PlayerPrefs.SetInt("highScore", _scoreManager.GetHighScore());
     }
 }
 private void MissHandler()
 {
     _isGameOver = true;
     SoundManager.Instance.PlayGameOverSound();
     _uiManager.OpenGameOverMenu();
     PauseGame();
     if (_scoreManager.IsNewHighScore())
     {
         PlayerPrefs.SetInt("highscore", _scoreManager.GetHighScore());
         _uiManager.SetHighScoreUI(_scoreManager.GetScore());
     }
     _uiManager.SetGameOverMenuHighScoreUI(_scoreManager.GetScore());
 }
        // Start is called before the first frame update
        private void Start()
        {
            string savedColorPalette = PlayerPrefs.GetString("ColorPalette");

            _currentColorPalette = savedColorPalette != "" ?
                                   Resources.Load <ColorPalette>("ColorPalettes/" + savedColorPalette) : Resources.Load <ColorPalette>("ColorPalettes/Classic");

            _uiManager    = FindObjectOfType <UIManager>();
            _scoreManager = FindObjectOfType <ScoreManager>();

            _scoreManager.SetHighScore(PlayerPrefs.GetInt("highscore"));
            _uiManager.SetHighScoreUI(_scoreManager.GetHighScore());

            _mainCamera = Camera.main;

            CreateBalls();
            CreateShapes();
            CreateShapesColors();

            ChangeGameColorPalette();
        }
        // Start is called before the first frame update
        private void Start()
        {
            string savedColorPalette = PlayerPrefs.GetString("ColorPalette");

            _currentColorPalette = savedColorPalette != "" ?
                                   Resources.Load <ColorPalette>("ColorPalettes/" + savedColorPalette) : Resources.Load <ColorPalette>("ColorPalettes/Day");

            _gameBoard    = FindObjectOfType <Board>();
            _spawner      = FindObjectOfType <Spawner>();
            _uiManager    = FindObjectOfType <UIManager>();
            _scoreManager = FindObjectOfType <ScoreManager>();

            // If the game is restarted we don't need main menu displayed again
            if (_isRestarted)
            {
                _uiManager.CloseMainMenu();
                _isRestarted = false;
                SoundManager.Instance.PlayStartSound();
            }

            _mainCamera = Camera.main;
            if (!_mainCamera)
            {
                Debug.Log("Cant get main camera");
                return;
            }

            _shapesInPlay         = new Shape[3];
            _numberOfShapesInPlay = _shapesInPlay.Length;

            _scoreManager.SetHighScore(PlayerPrefs.GetInt("highScore"));
            _uiManager.SetHighScoreUI(_scoreManager.GetHighScore());
            _uiManager.SetMainMenuHighScoreUI(_scoreManager.GetHighScore());

            if (!_gameBoard)
            {
                Debug.LogWarning("There is no game board");
                return;
            }

            if (!_spawner)
            {
                Debug.LogWarning("There is no spawner");
                return;
            }

            // Spawn first 3 shapes
            Shape spawnedShape = _spawner.SpawnShapeAtPositionWithScaleAndRandomRotation(
                new Vector3(1f, -3, -2),
                new Vector3(0.6f, 0.6f, 1.0f));

            _shapesInPlay[0] = spawnedShape;
            spawnedShape     = _spawner.SpawnShapeAtPositionWithScaleAndRandomRotation(
                new Vector3(4.5f, -3, -2),
                new Vector3(0.6f, 0.6f, 1.0f));
            _shapesInPlay[1] = spawnedShape;
            spawnedShape     = _spawner.SpawnShapeAtPositionWithScaleAndRandomRotation(
                new Vector3(8f, -3, -2),
                new Vector3(0.6f, 0.6f, 1.0f));
            _shapesInPlay[2] = spawnedShape;

            ChangeGameColorPalette(_currentColorPalette);
        }