示例#1
0
 public MovingTetromino(TetrisGameBoard gameBoard)
 {
     m_gameBoard     = gameBoard;
     Rotation        = TetrominoRotation.None;
     Column          = 3; // starts in the middle
     Row             = 0;
     DescriptiveGrid = null;
 }
示例#2
0
 public MovingTetromino(TetrisGameBoard gameBoard)
 {
     m_gameBoard = gameBoard;
     Rotation = TetrominoRotation.None;
     Column = 3; // starts in the middle
     Row = 0;
     DescriptiveGrid = null;
 }
示例#3
0
 public TetrisGameBoard(TetrisGameBoard source)
 {
     m_rows           = source.m_rows;
     m_columns        = source.m_columns;
     m_horizon        = new int[m_columns];
     m_gameBoardState = new BrickType[source.m_rows, source.m_columns];
     Array.Copy(source.m_gameBoardState, m_gameBoardState, m_columns * m_rows);
     CalculateHorizon();
 }
示例#4
0
        public static MovingTetromino CreateMovingTetromino(TetrisGameBoard gameBoard, BrickType brick)
        {
            MovingTetromino inst = null;

            switch (brick)
            {
            case BrickType.J:
            {
                inst = new MovingTetrominoJ(gameBoard);
                break;
            }

            case BrickType.L:
            {
                inst = new MovingTetrominoL(gameBoard);
                break;
            }

            case BrickType.O:
            {
                inst = new MovingTetrominoO(gameBoard);
                break;
            }

            case BrickType.S:
            {
                inst = new MovingTetrominoS(gameBoard);
                break;
            }

            case BrickType.T:
            {
                inst = new MovingTetrominoT(gameBoard);
                break;
            }

            case BrickType.Z:
            {
                inst = new MovingTetrominoZ(gameBoard);
                break;
            }

            default:
            case BrickType.I:
            {
                inst = new MovingTetrominoI(gameBoard);
                break;
            }
            }
            inst.InitializeDescriptiveGrid();
            return(inst);
        }
示例#5
0
        private void ReinitGameBoard()
        {
            m_world.BrickAreaOutput.Fill((float)BrickType.None);

            m_world.HintAreaOutput.Fill((float)BrickType.None);

            m_world.NextBrickNumberOutput.Fill(0.0f);

            m_world.ScoreOutput.Fill(0.0f);

            m_world.ScoreDeltaOutput.Fill(0.0f);

            m_world.LevelOutput.Fill(0.0f);

            // erase visual output not necessary - done by RenderTask

            m_gameBoard = new TetrisGameBoard(m_world.BrickAreaColumns, m_world.BrickAreaRows);

            // add almost full lines
            for (int iRow = 0; iRow < m_params.AlmostFullLinesAtStart; iRow++)
            {
                int iRowIndex = m_world.BrickAreaRows - 1 - iRow;
                for (int iCol = 0; iCol < m_world.BrickAreaColumns; iCol++)
                {
                    m_gameBoard.GameBoardState[iRowIndex, iCol] = BrickType.Preset;
                }
                int holeIndex = m_rndGen.Next(0, 10);
                m_gameBoard.GameBoardState[iRowIndex, holeIndex] = BrickType.None;
            }

            m_stepsFromLastDrop    = 0;
            m_level                = 0;
            m_score                = 0;
            m_scoreDelta           = 0;
            m_shouldSpawnTetromino = true;
            m_tetromino            = null;
            m_totalErasedLines     = 0;
            PrepareNextTetromino();
        }
示例#6
0
        private void FillBrickAreaOutput()
        {
            TetrisGameBoard gameBoardMerged = new TetrisGameBoard(m_gameBoard);

            if (m_tetromino != null)
            {
                gameBoardMerged.MergeTetrominoWithGameBoard(m_tetromino);
            }

            BrickType[,] gameBoardGrid = gameBoardMerged.GameBoardState;
            int index = 0;

            for (int iRow = 0; iRow < gameBoardGrid.GetLength(0); iRow++)
            {
                for (int iCol = 0; iCol < gameBoardGrid.GetLength(1); iCol++)
                {
                    m_world.BrickAreaOutput.Host[index] = (float)gameBoardGrid[iRow, iCol];
                    index++;
                }
            }
            m_world.BrickAreaOutput.SafeCopyToDevice();
        }
示例#7
0
 public TetrisGameBoard(TetrisGameBoard source)
 {
     m_rows = source.m_rows;
     m_columns = source.m_columns;
     m_horizon = new int[m_columns];
     m_gameBoardState = new BrickType[source.m_rows, source.m_columns];
     Array.Copy(source.m_gameBoardState, m_gameBoardState, m_columns * m_rows);
     CalculateHorizon();
 }
示例#8
0
 public MovingTetrominoZ(TetrisGameBoard gameBoard)
     : base(gameBoard)
 {
 }
示例#9
0
 public static MovingTetromino CreateMovingTetromino(TetrisGameBoard gameBoard, BrickType brick)
 {
     MovingTetromino inst = null;
     switch(brick)
     {
         case BrickType.J:
             {
                 inst = new MovingTetrominoJ(gameBoard);
                 break;
             }
         case BrickType.L:
             {
                 inst = new MovingTetrominoL(gameBoard);
                 break;
             }
         case BrickType.O:
             {
                 inst = new MovingTetrominoO(gameBoard);
                 break;
             }
         case BrickType.S:
             {
                 inst = new MovingTetrominoS(gameBoard);
                 break;
             }
         case BrickType.T:
             {
                 inst = new MovingTetrominoT(gameBoard);
                 break;
             }
         case BrickType.Z:
             {
                 inst = new MovingTetrominoZ(gameBoard);
                 break;
             }
         default:
         case BrickType.I:
             {
                 inst = new MovingTetrominoI(gameBoard);
                 break;
             }
     }
     inst.InitializeDescriptiveGrid();
     return inst;
 }
示例#10
0
        private void ReinitGameBoard()
        {
            m_world.BrickAreaOutput.Fill((float)BrickType.None);

            m_world.HintAreaOutput.Fill((float)BrickType.None);

            m_world.NextBrickNumberOutput.Fill(0.0f);

            m_world.ScoreOutput.Fill(0.0f);

            m_world.ScoreDeltaOutput.Fill(0.0f);

            m_world.LevelOutput.Fill(0.0f);

            // erase visual output not necessary - done by RenderTask

            m_gameBoard = new TetrisGameBoard(m_world.BrickAreaColumns, m_world.BrickAreaRows);

            // add almost full lines
            for(int iRow = 0; iRow < m_params.AlmostFullLinesAtStart; iRow++)
            {
                int iRowIndex = m_world.BrickAreaRows - 1 - iRow;
                for(int iCol = 0; iCol < m_world.BrickAreaColumns; iCol++)
                {
                    m_gameBoard.GameBoardState[iRowIndex,iCol] = BrickType.Preset;
                }
                int holeIndex = m_rndGen.Next(0, 10);
                m_gameBoard.GameBoardState[iRowIndex, holeIndex] = BrickType.None;
            }

            m_stepsFromLastDrop = 0;
            m_level = 0;
            m_score = 0;
            m_scoreDelta = 0;
            m_shouldSpawnTetromino = true;
            m_tetromino = null;
            m_totalErasedLines = 0;
            PrepareNextTetromino();
        }
示例#11
0
        private void FillBrickAreaOutput()
        {
            TetrisGameBoard gameBoardMerged = new TetrisGameBoard(m_gameBoard);
            if (m_tetromino != null)
            {
                gameBoardMerged.MergeTetrominoWithGameBoard(m_tetromino);
            }

            BrickType[,] gameBoardGrid = gameBoardMerged.GameBoardState;
            int index = 0;
            for (int iRow = 0; iRow < gameBoardGrid.GetLength(0); iRow++)
            {
                for (int iCol = 0; iCol < gameBoardGrid.GetLength(1); iCol++)
                {
                    m_world.BrickAreaOutput.Host[index] = (float)gameBoardGrid[iRow, iCol];
                    index++;
                }
            }
            m_world.BrickAreaOutput.SafeCopyToDevice();
        }
示例#12
0
 public MovingTetrominoZ(TetrisGameBoard gameBoard) : base(gameBoard)
 {
 }
示例#13
0
 public TetrisGameBoard(TetrisGameBoard source)
 {
     m_rows = source.m_rows;
     m_columns = source.m_columns;
     m_gameBoardState = new BrickType[source.m_rows, source.m_columns];
     Array.Copy(source.m_gameBoardState, m_gameBoardState, m_columns * m_rows);
 }