Esempio n. 1
0
        public void TranslateHorizontally(MoveDirection direction)
        {
            if (!ChangeOccured)
            {
                if ((direction == MoveDirection.Right && lastMove == MoveDirection.Right) || (direction == MoveDirection.Left && lastMove == MoveDirection.Left))
                {
                    return;
                }
            }

            ChangeOccured = false;
            var rows = Squares.GroupBy(r => r.Y).ToList();

            foreach (var row in rows)
            {
                if (direction == MoveDirection.Left)
                {
                    PushRow(row.OrderBy(x => x.X).ToList(), direction);
                }
                else
                {
                    PushRow(row.OrderByDescending(x => x.X).ToList(), direction);
                }
            }
        }
Esempio n. 2
0
        public void TranslateVertically(MoveDirection direction)
        {
            if (!ChangeOccured)
            {
                if ((direction == MoveDirection.Bottom && lastMove == MoveDirection.Bottom) || (direction == MoveDirection.Top && lastMove == MoveDirection.Top))
                {
                    return;
                }
            }

            ChangeOccured = false;
            var cols = Squares.GroupBy(r => r.X).ToList();

            foreach (var col in cols)
            {
                if (direction == MoveDirection.Top)
                {
                    PushCol(col.OrderBy(x => x.Y).ToList(), direction);
                }
                else
                {
                    PushCol(col.OrderByDescending(x => x.Y).ToList(), direction);
                }
            }
        }