コード例 #1
0
ファイル: GameBoard.cs プロジェクト: Sjantos/ComputerGraphic
        /// <summary>
        /// Size should be less than 20
        /// </summary>
        /// <param name="width">width of game board</param>
        public GameBoard(int width = 10)
        {
            random              = new Random();
            cubeSize            = 1.1f;
            boardWidth          = width;
            boardHeight         = 2 * width;
            boardAbsoluteWidth  = boardWidth + 2;
            boardAbsoluteHeight = boardHeight + 5;
            board = new GameBoardCell[boardAbsoluteWidth, boardAbsoluteHeight];

            for (int i = 0; i < boardAbsoluteWidth; i++)
            {
                for (int j = 0; j < boardAbsoluteHeight; j++)
                {
                    board[i, j] = new GameBoardCell();
                }
            }

            for (int j = 0; j < boardAbsoluteHeight; j++)
            {
                board[0, j].CellStatus = CellStatus.Filled;
                board[boardAbsoluteWidth - 1, j].CellStatus = CellStatus.Filled;
            }
            for (int i = 0; i < boardAbsoluteWidth - 1; i++)
            {
                board[i, 0].CellStatus = CellStatus.Filled;
            }
        }
コード例 #2
0
ファイル: GameBoard.cs プロジェクト: Sjantos/ComputerGraphic
        public bool DeleteFullLine()
        {
            bool lineDeleted = false;

            for (int j = 1; j < boardHeight + 1; j++)
            {
                bool rowFilled = true;
                for (int i = 1; i < boardAbsoluteWidth - 1; i++)
                {
                    if (board[i, j].CellStatus == CellStatus.Free)
                    {
                        rowFilled = false;
                        break;
                    }
                }
                if (rowFilled)
                {
                    lineDeleted = true;
                    int k = j;
                    for (k = j; k < boardHeight - 1; k++)
                    {
                        for (int l = 1; l < boardAbsoluteWidth - 1; l++)
                        {
                            board[l, k] = board[l, k + 1];
                        }
                    }
                    for (int l = 1; l < boardAbsoluteWidth - 1; l++)
                    {
                        board[l, k] = new GameBoardCell();
                    }
                    j--;
                }
            }
            return(lineDeleted);
        }