示例#1
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;
                    BlockControls[i, j].BorderThickness = new Thickness(1);
                    Grid.SetRow(BlockControls[i, j], j);
                    Grid.SetColumn(BlockControls[i, j], i);
                    TetrisGrid.Children.Add(BlockControls[i, j]);
                }
            }
            currTetramino = new Tetramino();
            currTetraminoDraw();
        }
示例#2
0
文件: Board.cs 项目: CSEANZ/Kinectris
 public void LoadTeramino()
 {
     if (nextTetramino != null)
     {
         currTetramino = nextTetramino;
         currTetraminoDraw();
         nextTetramino = null;
     }
     else
     {
         SpawnTetramino("Random");
         currTetramino = nextTetramino;
         nextTetramino = null;
     }
 }
示例#3
0
        public void CurrTetraminoMovDown()
        {
            Point Position = currTetramino.getCurrPosition();

            Point[] Shape = currTetramino.getCurrShape();
            bool    move  = true;

            currTretaminoErase();

            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)
            {
                currTetramino.movDown();
                currTetraminoDraw();
            }

            else
            {
                currTetraminoDraw();
                CheckRows();

                if ((int)Position.Y == 0)
                {
                    gameOver = true;
                }

                else
                {
                    currTetramino = new Tetramino();
                }
            }
        }
示例#4
0
文件: Board.cs 项目: CSEANZ/Kinectris
        /// <summary>
        ///
        /// </summary>
        /// <param name="i">
        /// i is the shape to spawn
        /// 0. I
        /// 1. J
        /// 2. L
        /// 3.[ ]
        /// 4. S
        /// 5. T
        /// 6. Z
        /// </param>
        public void SpawnTetramino(string Shape)
        {
            int i = 0;

            if (Shape == "Random")
            {
                Random rnd = new Random();
                i = rnd.Next(0, 6);
            }
            else
            {
                switch (Shape)
                {
                case "Line":
                    i = 0;
                    break;

                case "J":
                    i = 1;
                    break;

                case "L":
                    i = 2;
                    break;

                case "Square":
                    i = 3;
                    break;

                case "S":
                    i = 4;
                    break;

                case "Tee":
                    i = 5;
                    break;

                case "Z":
                    i = 6;
                    break;
                }
            }
            nextTetramino = new Tetramino(i);
        }