Exemplo n.º 1
0
        protected bool MoveRight(Figure f)
        {
            Figure moved = f.MoveRight();

            f.Type = TileType.Empty;
            SetFigure(f, true);
            if (IsEmpty(moved))
            {
                SetFigure(moved, false);
                return(true);
            }
            f.Type = moved.Type;
            SetFigure(f, false);
            return(false);
        }
Exemplo n.º 2
0
        protected Figure RotateFigure(Figure f)
        {
            Figure rotated = f.Rotate(), rotated2;

            f.Type = TileType.Empty;
            SetFigure(f, true);
            f.Type = rotated.Type;

            if (IsEmpty(rotated))
            {
                SetFigure(rotated, false);
                return(rotated);
            }
            //неудача, фигура наткнулась на препятствие, нужно сместить её
            //вниз
            rotated2 = rotated.MoveDown();
            if (IsEmpty(rotated2))
            {
                SetFigure(rotated2, false);
                return(rotated2);
            }
            //вправо
            rotated2 = rotated.MoveRight();
            if (IsEmpty(rotated2))
            {
                SetFigure(rotated2, false);
                return(rotated2);
            }
            //влево
            rotated2 = rotated.MoveLeft();
            if (IsEmpty(rotated2))
            {
                SetFigure(rotated2, false);
                return(rotated2);
            }
            //тотальная неудача, я сдаюсь
            SetFigure(f, false);
            return(Figure.Zero);
        }