Exemplo n.º 1
0
        public void Right(IBoard board)
        {
            int numSquares = 1;
            var boardCoordinate = board.GetMainSelectedSquare();
            var changedSquareCoordinates = new List<BoardCoordinate>();

            while (board.IsSelectedAndCanGoInAllDirections(boardCoordinate.X, boardCoordinate.Y, numSquares))
            {
                var tile = board[boardCoordinate.X, boardCoordinate.Y - numSquares].Tile;

                board[boardCoordinate.X, boardCoordinate.Y - numSquares].Tile =
                    board[boardCoordinate.X - numSquares, boardCoordinate.Y].Tile;

                board[boardCoordinate.X - numSquares, boardCoordinate.Y].Tile =
                    board[boardCoordinate.X, boardCoordinate.Y + numSquares].Tile;

                board[boardCoordinate.X, boardCoordinate.Y + numSquares].Tile =
                    board[boardCoordinate.X + numSquares, boardCoordinate.Y].Tile;

                board[boardCoordinate.X + numSquares, boardCoordinate.Y].Tile =
                    tile;

                changedSquareCoordinates.Add(new BoardCoordinate(boardCoordinate.X, boardCoordinate.Y - numSquares));
                changedSquareCoordinates.Add(new BoardCoordinate(boardCoordinate.X - numSquares, boardCoordinate.Y));
                changedSquareCoordinates.Add(new BoardCoordinate(boardCoordinate.X, boardCoordinate.Y + numSquares));
                changedSquareCoordinates.Add(new BoardCoordinate(boardCoordinate.X + numSquares, boardCoordinate.Y));

                numSquares++;
            }

            GameEvents.Raise(new RotatedRightEvent{BoardCoordinates = changedSquareCoordinates});
        }