Exemplo n.º 1
0
        public void SetGameState()
        {
            if (_currentState == GameStates.Playing)
            {
                return;
            }

            if (_stateTransition.IsFading)
            {
                return;
            }

            ShouldEndApplication = false;
            _stateTransition.FadeOut();
            _afterTransitionAction = new Action(
                () =>
            {
                _stateTransition.FadeIn();

                _currentState = GameStates.Playing;
                _game         = _gameFactory();
                _menu         = null;
                _score        = null;
            });
        }
Exemplo n.º 2
0
        public void SetMenuState()
        {
            if (_currentState == GameStates.Menu)
            {
                return;
            }

            if (_stateTransition.IsFading)
            {
                return;
            }

            _stateTransition.FadeOut();
            _afterTransitionAction = new Action(
                () =>
            {
                _stateTransition.FadeIn();

                if (_currentState == GameStates.Playing && _game.IsGameOver)
                {
                    // Significa che sono uscito dal gioco
                    // perché ho perso
                    GameOver?.Invoke(this, EventArgs.Empty);
                }

                _currentState = GameStates.Menu;
                _game         = null;
                _score        = null;
                _menu         = _menuFactory();
            });
        }
Exemplo n.º 3
0
        public void SetGameOverState(
            int thisGameNumberOfVegetablesEaten,
            int thisGameNumberOfMeters,
            int thisGameNumberOfFarts)
        {
            if (_currentState == GameStates.GameOver)
            {
                return;
            }

            if (_stateTransition.IsFading)
            {
                return;
            }

            ShouldEndApplication = false;
            _stateTransition.FadeOut();
            _afterTransitionAction = new Action(
                () =>
            {
                _stateTransition.FadeIn();

                _currentState = GameStates.GameOver;
                _game         = null;
                _menu         = null;
                _score        = null;
                _gameOver     = new GameOverPage(
                    matrixScaleProvider: _matrixScaleProvider,
                    assets: _assets,
                    settingsRepository: _settingsRepository,
                    thisGameNumberOfVegetablesEaten: thisGameNumberOfVegetablesEaten,
                    thisGameNumberOfMeters: thisGameNumberOfMeters,
                    thisGameNumberOfFarts: thisGameNumberOfFarts,
                    localizedStringsRepository: _localizedStringsRepository);
            });
        }