Exemplo n.º 1
0
        private IList <ICommand> CreateCommand(Point startPosition, ConsoleCursor cursor)
        {
            int left = startPosition.X + _gameBoard.FrameSize;
            int top  = startPosition.Y + _gameBoard.FrameSize;

            // -1 для корректного отображения курсора после ввода
            int         right        = _gameBoard.Width + _gameBoard.FrameSize - 1;
            int         bottom       = _gameBoard.Height + _gameBoard.FrameSize;
            CursorField _cursorField = new CursorField(left, top, right, bottom, cursor);

            IList <ICommand> commands = new List <ICommand>
            {
                new MoveRightCommand(ConsoleKey.RightArrow, _cursorField),
                new MoveLeftCommand(ConsoleKey.LeftArrow, _cursorField),
                new MoveDownCommand(ConsoleKey.DownArrow, _cursorField),
                new MoveUpCommand(ConsoleKey.UpArrow, _cursorField),
                new EnterCommand(ConsoleKey.Enter, _cursorField, _gameBoard),
                new SpaceCommand(ConsoleKey.Spacebar, this)
            };

            return(commands);
        }
Exemplo n.º 2
0
 public MoveRightCommand(ConsoleKey key, CursorField cursorField) :
     base(key, cursorField)
 {
 }
Exemplo n.º 3
0
 public MoveCommand(ConsoleKey key, CursorField cursorField) :
     base(key)
 {
     _cursorField = cursorField;
 }
Exemplo n.º 4
0
 public EnterCommand(ConsoleKey key, CursorField field, GameBoard board) :
     base(key)
 {
     _board = board;
     _field = field;
 }