Esempio n. 1
0
 public void Start()
 {
     Clear();
     NextPolyomino = new Tetromono();
     Place(currentPolyomino);
     scoreBoard.Reset();
     IsStarted = true;
     GameStarted?.Invoke();
 }
 public void Start()
 {
     Clear();
     NextPolyomino = new Tetromono();
     Place(currentPolyomino);
     scoreBoard.Reset();
     IsStarted = true;
     GameStarted?.Invoke();
 }
Esempio n. 3
0
 bool PlaceNextPolyomino()
 {
     currentPolyomino = NextPolyomino;
     if (Place(currentPolyomino))
     {
         NextPolyomino = new Tetromono();
         return(true);
     }
     return(false);
 }
Esempio n. 4
0
        bool Turn(Tetromono currentPolyomino, bool clockwise = true)
        {
            var cellsClone = CellsClone;

            if (currentPolyomino.Turn(cellsClone, clockwise))
            {
                CellsClone = cellsClone;
                return(true);
            }
            return(false);
        }
Esempio n. 5
0
        bool Move(Point <int> position, Tetromono polyomino)
        {
            var cellsClone = CellsClone;

            if (polyomino.Move(cellsClone, position))
            {
                CellsClone = cellsClone;
                return(true);
            }
            return(false);
        }
Esempio n. 6
0
        public bool Place(PolyominoIndex[,] cellsClone, Point <int> position)
        {
            var placeablePoints = PlaceablePoints(shape, cellsClone, position);

            if (placeablePoints == null)
            {
                return(false);
            }
            placeablePoints.ForEach(point => cellsClone.Set(Tetromono.GetPosition(position, point), Index));
            Position = position;
            return(true);
        }
Esempio n. 7
0
        bool Place(Tetromono polyomino)
        {
            var position = new Point <int> {
                X = (Size.Width - polyomino.Size.Width) / 2, Y = 0
            };
            var cellsClone = CellsClone;

            if (polyomino.Place(cellsClone, position))
            {
                CellsClone = cellsClone;
                return(true);
            }
            return(false);
        }
        public bool Place(Tetromono polyomino)
        {
            Contract.Assert(polyomino.Size.Width  <= Size.Width  &&
                            polyomino.Size.Height <= Size.Height);

            Clear();
            var position = new Point<int>().Add(Size.Subtract(polyomino.Size).Divide(2));
            var cellsClone = CellsClone;
            if (polyomino.Place(cellsClone, position)) {
                CellsClone = cellsClone;
                return true;
            }
            return false;
        }
Esempio n. 9
0
        public bool Turn(PolyominoIndex[,] cellsClone, bool clockwise = true)
        {
            Erase(cellsClone);

            var newShape        = Turn(clockwise);
            var placeablePoints = PlaceablePoints(newShape, cellsClone, Position);

            if (placeablePoints == null)
            {
                return(false);
            }
            placeablePoints.ForEach(point => cellsClone.Set(Tetromono.GetPosition(Position, point), Index));
            shape = newShape;
            return(true);
        }
Esempio n. 10
0
        public bool Place(Tetromono polyomino)
        {
            Contract.Assert(polyomino.Size.Width <= Size.Width &&
                            polyomino.Size.Height <= Size.Height);

            Clear();
            var position   = new Point <int>().Add(Size.Subtract(polyomino.Size).Divide(2));
            var cellsClone = CellsClone;

            if (polyomino.Place(cellsClone, position))
            {
                CellsClone = cellsClone;
                return(true);
            }
            return(false);
        }
 bool Place(Tetromono polyomino)
 {
     var position = new Point<int> { X = (Size.Width - polyomino.Size.Width) / 2, Y = 0 };
     var cellsClone = CellsClone;
     if (polyomino.Place(cellsClone, position)) {
         CellsClone = cellsClone;
         return true;
     }
     return false;
 }
 bool Turn(Tetromono currentPolyomino, bool clockwise = true)
 {
     var cellsClone = CellsClone;
     if (currentPolyomino.Turn(cellsClone, clockwise)) {
         CellsClone = cellsClone;
         return true;
     }
     return false;
 }
 bool MoveRight(Tetromono polyomino)
 { return Move(new Point<int> { X = polyomino.Position.X + 1, Y = polyomino.Position.Y }, polyomino); }
 bool Move(Point<int> position, Tetromono polyomino)
 {
     var cellsClone = CellsClone;
     if (polyomino.Move(cellsClone, position)) {
         CellsClone = cellsClone;
         return true;
     }
     return false;
 }
 bool PlaceNextPolyomino()
 {
     currentPolyomino = NextPolyomino;
     if (Place(currentPolyomino)) {
         NextPolyomino = new Tetromono();
         return true;
     }
     return false;
 }
Esempio n. 16
0
 bool MoveRight(Tetromono polyomino)
 {
     return(Move(new Point <int> {
         X = polyomino.Position.X + 1, Y = polyomino.Position.Y
     }, polyomino));
 }
Esempio n. 17
0
 bool Down(Tetromono polyomino)
 {
     return(Move(new Point <int> {
         X = polyomino.Position.X, Y = polyomino.Position.Y + 1
     }, polyomino));
 }
 bool Down(Tetromono polyomino)
 { return Move(new Point<int> { X = polyomino.Position.X, Y = polyomino.Position.Y + 1 }, polyomino); }