コード例 #1
0
    static void InitializeCubeColors(SquareColor[,] danceCube)
    {
        // Set counter to 0
        int counter = 0;

        // Iterate through the cube, setting the appropriate color
        for (int squareRow = 0; squareRow < danceCube.GetLength(0); squareRow++)
        {
            for (int squareCol = 0; squareCol < danceCube.GetLength(1); squareCol++)
            {
                if (counter % 2 == 0)
                {
                    danceCube[squareRow, squareCol] = SquareColor.RED;
                }
                else
                {
                    danceCube[squareRow, squareCol] = SquareColor.BLUE;
                }

                counter++;
            }
        }

        // Set the middle square color to Green
        danceCube[1, 1] = SquareColor.GREEN;
    }