示例#1
0
        public void CurrentTetrisMoveDown()
        {
            Point Position = CurrentTetris.getCurrentPosition();

            Point[] Shape = CurrentTetris.getCurrentShape();
            bool    Move  = true;

            CurrentTetrisErase();
            foreach (Point S in Shape)
            {
                if (((int)(S.Y + Position.Y) + 2 + 1) >= Rows)
                {
                    Move = false;
                }
                else if (BlockControls[(int)(S.X + Position.X) + ((Cols / 2) - 1), (int)(S.Y + Position.Y) + 2 + 1].Background != NoBrush)
                {
                    Move = false;
                }
            }
            if (Move)
            {
                CurrentTetris.MoveDown();
                CurrentTetrisDraw();
            }
            else
            {
                CurrentTetrisDraw();
                CheckRows();
                CurrentTetris = new Tetriss();
            }
        }
示例#2
0
        public Board(Grid TetrisGrid)
        {
            Rows        = TetrisGrid.RowDefinitions.Count;
            Cols        = TetrisGrid.ColumnDefinitions.Count;
            Score       = 0;
            LinesFilled = 0;

            BlockControls = new Label[Cols, Rows];
            for (int i = 0; i < Cols; i++)
            {
                for (int j = 0; j < Rows; j++)
                {
                    BlockControls[i, j]             = new Label();
                    BlockControls[i, j].Background  = NoBrush;
                    BlockControls[i, j].BorderBrush = SilverBrush;
                    Grid.SetRow(BlockControls[i, j], j);
                    Grid.SetColumn(BlockControls[i, j], i);
                    TetrisGrid.Children.Add(BlockControls[i, j]);
                }
            }
            CurrentTetris = new Tetriss();
        }