예제 #1
0
 public static bool IsEmpty(Square[] block)
 {
     foreach (Square square in block)
     {
         if (_board.Lines[square.Location.Y].IndexIsFull(square.Location.X))
         {
             return false;
         }
     }
     return true;
 }
예제 #2
0
        private void CreateSquares()
        {
            squares[0] = new Square(foreColors[(int)type], backColors[(int)type], new Size(squareSize, squareSize));
            squares[1] = new Square(foreColors[(int)type], backColors[(int)type], new Size(squareSize, squareSize));
            squares[2] = new Square(foreColors[(int)type], backColors[(int)type], new Size(squareSize, squareSize));
            squares[3] = new Square(foreColors[(int)type], backColors[(int)type], new Size(squareSize, squareSize));

           switch (type)
            {

                case BlockType.J:
                    squares[0].Location = this.location;
                    squares[1].Location = UpOne();
                    squares[2].Location = DownOne();
                    squares[3].Location = LeftOneDownOne();
                    break;
                case BlockType.L:
                    squares[0].Location = this.location;
                    squares[1].Location = UpOne();
                    squares[2].Location = DownOne();
                    squares[3].Location = RightOneDownOne();
                    break;
                case BlockType.Z:
                    squares[0].Location = this.location;
                    squares[1].Location = LeftOne();
                    squares[2].Location = DownOne();
                    squares[3].Location = RightOneDownOne();
                    break;
                case BlockType.SQUARE:
                    squares[0].Location = this.location;
                    squares[1].Location = RightOne();
                    squares[2].Location = DownOne();
                    squares[3].Location = RightOneDownOne();
                    break;
                case BlockType.T:
                    squares[0].Location = this.location;
                    squares[1].Location = RightOne();
                    squares[2].Location = LeftOne();
                    squares[3].Location = DownOne();
                    break;
                case BlockType.S:
                    squares[0].Location = this.location;
                    squares[1].Location = RightOne();
                    squares[2].Location = DownOne();
                    squares[3].Location = LeftOneDownOne();
                    break;
                case BlockType.LINE:
                    squares[0].Location = this.location;
                    squares[1].Location = UpOne();
                    squares[2].Location = DownOne();
                    squares[3].Location = DownTwo();
                    break;
            }
        }
예제 #3
0
        public static bool IsEmpty(Square[] block, Direction direction, int size)
        {
            try
            {
                switch (direction)
                {
                    case Direction.Left:
                        foreach (Square square in block)
                        {

                            if (_board.Lines[square.Location.Y].IndexIsFull(square.Location.X - size) || !IsEmpty(block))
                            {
                                return false;
                            }

                        }
                        break;
                    case Direction.Right:
                        foreach (Square square in block)
                        {

                            if (_board.Lines[square.Location.Y].IndexIsFull(square.Location.X + size) || !IsEmpty(block))
                            {
                                return false;
                            }

                        }
                        break;
                    case Direction.Down:
                       
                        foreach (Square square in block)
                        {

                            if (_board.Lines[square.Location.Y + size].IndexIsFull(square.Location.X))
                            {
                                return false;
                            }
                        }
                        break;
                }

                return true;
            }
            catch (Exception e)
            {
                string str = e.StackTrace;
                return false;
            }
        }
예제 #4
0
 public void AddSquare(int index, Square square)
 {
     if (!squares.ContainsKey(index))
     {
         squares.Add(index, square);
         if (squares.Count == GameField.Slots + 2)
             this.isFull = true;
     }
 }
예제 #5
0
        public static void StopSquare(Square[] block)
        {
            foreach (Square square in block)
            {
                string name = string.Format("[{0}.{1}]", square.Location.X, square.Location.Y);
                if (!_board.Lines[square.Location.Y].IndexIsFull(square.Location.X))
                {
                    _board.Lines[square.Location.Y].AddSquare(square.Location.X, square);
                }
            }

        }