Exemple #1
0
        private void Start()
        {
            _grainPool = new Pool <SampoProduct>(32, false, _grainPrefab);
            _saltPool  = new Pool <SampoProduct>(32, false, _saltPrefab);
            _goldPool  = new Pool <SampoProduct>(32, false, _goldPrefab);

            if (_sampoSpinner == null)
            {
                _sampoSpinner = FindObjectOfType <SampoSpinner>();
            }
            if (_collSpawner == null)
            {
                _collSpawner = FindObjectOfType <CollectableSpawner>();
            }

            _sampoSpinner.HalfTurn += SampoSpinnerHalfTurn;
        }
        private void Start()
        {
            _eventSystem   = FindObjectOfType <EventSystem>();
            _stateManager  = FindObjectOfType <StateManager>();
            _confirmation  = GetComponentInChildren <ConfirmationDialog>();
            _highscoreList = GameManager.Instance.HighscoreList;
            _cursor        = FindObjectOfType <MouseCursorController>();
            _heatMap       = FindObjectOfType <HeatMap>();
            _kantelePanel  = FindObjectOfType <KanteleHeroPanel>();
            _collSpawner   = FindObjectOfType <CollectableSpawner>();

            // Allows the cursor to select the current menu's
            // default selected button when it is hidden
            _cursor.SelectMenuButtonAction = SelectDefaultSelectedMenuButton;

            // Hides the scoreboard by default
            _highscoreList.Visible = false;

            // Registers to listen to the GameOver event.
            // When the GameOver event is triggered, the first
            // button in the game over menu is highlighted
            _stateManager.GameOver += HighlightGameOverMenuButton;

            //// Registers to listen to the PauseMenuActivated event.
            //// Makes the scoreboard visible and doesn't allow
            //// hiding it in the pause menu
            //_stateManager.PauseMenuActivated += PauseMenuEntered;

            //// Registers to listen to the PauseMenuDeactivated event.
            //// Changes the scoreboard's visibility to what it
            //// was before accessing the pause menu
            //_stateManager.PauseMenuDeactivated += PauseMenuExited;

            // Registers to listen to the ScreenStateChanged event.
            _stateManager.ScreenStateChanged += OnScreenStateChanged;
            OnScreenStateChanged(ScreenStateType.MainMenu);

            L10n.LanguageLoaded += OnLanguageLoaded;
            OnLanguageLoaded();

#if UNITY_EDITOR
            _debugEnabled = true;
#else
            _debugEnabled = false;
#endif
        }
Exemple #3
0
        private void Init()
        {
            // Initializes the highscore list
            _highscoreList = FindObjectOfType <HighscoreList>();
            if (_highscoreList == null)
            {
                Debug.LogError("HighscoreList object not found in the scene.");
            }

            // Initializes localization
            InitLocalization();

            // Initializes the save system and loads data
            _saveSystem = new SaveSystem(new JSONPersistence(SavePath));
            LoadGame();

            // Initializes states
            _stateManager = FindObjectOfType <StateManager>();
            if (_stateManager != null)
            {
                _stateManager.Init();
            }
            else
            {
                Debug.LogError("StateManager object not found in the scene.");
            }

            _playfield = FindObjectOfType <Playfield>();
            if (_playfield == null)
            {
                Debug.LogError("Playfield object not found in the scene.");
            }

            _collectableSpawner = FindObjectOfType <CollectableSpawner>();
            _cameraCtrl         = FindObjectOfType <CameraController>();

            DontDestroyOnLoad(gameObject);
        }
 public void SetHandler(CollectableSpawner handler)
 {
     _handler = handler;
 }