Ejemplo n.º 1
0
        public void ShiftHandler(object o, EventArgs e)
        {
            ConsoleKeyEventsArgs ce = (ConsoleKeyEventsArgs)e;

            switch (ce.CurrentConsoleKey)
            {
            case ConsoleKey.RightArrow:
                ((IBoard)o).Point = new Point(((IBoard)o).Point.X + 1, ((IBoard)o).Point.Y);
                break;

            case ConsoleKey.LeftArrow:
                ((IBoard)o).Point = new Point(((IBoard)o).Point.X - 1, ((IBoard)o).Point.Y);
                break;

            case ConsoleKey.DownArrow:
                ((IBoard)o).Point = new Point(((IBoard)o).Point.X, ((IBoard)o).Point.Y + 1);
                break;

            case ConsoleKey.UpArrow:
                ((IBoard)o).Point = new Point(((IBoard)o).Point.X, ((IBoard)o).Point.Y - 1);
                break;

            default:
                break;
            }
            if (IsPointOutOfBoard((IBoard)o))
            {
                switch (ce.CurrentConsoleKey)
                {
                case ConsoleKey.RightArrow:
                    ((IBoard)o).Point = new Point(((IBoard)o).Point.X - 1, ((IBoard)o).Point.Y);
                    break;

                case ConsoleKey.LeftArrow:
                    ((IBoard)o).Point = new Point(((IBoard)o).Point.X + 1, ((IBoard)o).Point.Y);
                    break;

                case ConsoleKey.DownArrow:
                    ((IBoard)o).Point = new Point(((IBoard)o).Point.X, ((IBoard)o).Point.Y - 1);
                    break;

                case ConsoleKey.UpArrow:
                    ((IBoard)o).Point = new Point(((IBoard)o).Point.X, ((IBoard)o).Point.Y + 1);
                    break;

                default:
                    break;
                }
            }

            DrawSmth((IBoard)o);
        }
Ejemplo n.º 2
0
        public void Input(IBoard board)
        {
            ConsoleKeyEventsArgs e = new ConsoleKeyEventsArgs(Console.ReadKey().Key);

            shift(board, e);
        }