Esempio n. 1
0
        public void CurrentTerminateMoveDown()
        {
            Point Position = currentTerminate.getCurrentPosition;

            Point[] Shape = currentTerminate.getCurrentShape;
            bool    move  = true;

            currentTerminateErase();
            foreach (Point S in Shape)
            {
                if (((int)(S.Y + Position.Y) + 2 + 1) >= Rows)
                {
                    move = false;
                }
                else if (BlockControls[((int)(S.X + Position.X) + (Columns / 2) - 1),
                                       (int)(S.Y + Position.Y) + 2 + 1].Background != NoBrush)
                {
                    move = false;
                }
            }
            if (move)
            {
                currentTerminate.moveDown();
                currentTerminateDraw();
            }
            else
            {
                currentTerminateDraw();
                CheckRows();
                currentTerminate = new Terminate();
            }
        }
Esempio n. 2
0
        public Board(Grid TetrisGrid)
        {
            Rows        = TetrisGrid.RowDefinitions.Count;
            Columns     = TetrisGrid.ColumnDefinitions.Count;
            Score       = 0;
            Linesfilled = 0;

            BlockControls = new Label[Columns, Rows];
            for (int i = 0; i < Columns; i++)
            {
                for (int j = 0; j < Rows; j++)
                {
                    BlockControls[i, j]                 = new Label();
                    BlockControls[i, j].Background      = NoBrush;
                    BlockControls[i, j].BorderBrush     = SilverBrush;
                    BlockControls[i, j].BorderThickness = new Thickness(1, 1, 1, 1);
                    Grid.SetRow(BlockControls[i, j], j);
                    Grid.SetColumn(BlockControls[i, j], i);
                    TetrisGrid.Children.Add(BlockControls[i, j]);
                }
            }
            currentTerminate = new Terminate();
            currentTerminateDraw();
        }