Exemple #1
0
        private void CheckInput()
        {
            Object obj = InputManager.PollKey(CurrentDirection, GameState);

            if (obj is EDirection)
            {
                CurrentDirection = (EDirection)obj;
            }
            OnDirectionChangedListener(CurrentDirection);
            if (obj is EGameState)
            {
                GameState = (EGameState)obj;
            }
            OnGameStateChangedListener(GameState);
        }
Exemple #2
0
        private void CheckInput()
        {
            Object obj = InputManager.PollKey(CurrentDirection);

            // checking return from inputmanager if not paused
            if (obj != null && GameState != EGameState.Paused)
            {
                if (obj is ConsoleKeyInfo)
                {
                    var cki = (ConsoleKeyInfo)obj;
                    if (cki.Key == ConsoleKey.Escape)
                    {
                        GameState = EGameState.Over;
                    }
                    else if (cki.Key == ConsoleKey.Spacebar)
                    {
                        GameState = EGameState.Paused;
                        OnGameStateChangedListener(GameState);
                    }
                    OnGameStateChangedListener(GameState);
                }
                else if (obj is EDirection)
                {
                    CurrentDirection = (EDirection)obj;
                    OnDirectionChangedListener(CurrentDirection);
                }
                // checking return from inputmanager if paused
            }
            else if (obj != null)
            {
                if (obj is ConsoleKeyInfo)
                {
                    var cki = (ConsoleKeyInfo)obj;
                    if (cki.Key == ConsoleKey.Spacebar)
                    {
                        GameState = GameState == EGameState.Running ? EGameState.Paused : EGameState.Running;
                        OnGameStateChangedListener(GameState);
                    }
                }
            }
        }