Procedural construction

So I’ve been working on a little roguelike idea of mine, and I’m having trouble implementing it.

  1. I want the level to be a 3-dimensional grid of cubes. Now, I thought I’d just write an algorithm to decide on which coordinates to spawn cubes, and store the created map in a simple matrix. Most of my experience with multidimensional arrays comes from Java, and I have so far succeeded neither in making such an array work (js and c#), nor in finding out via searches and googling.
  2. I’d like the game to be as graphically austere as possible, with blocks having no complicated textures but simply a single colour all around. Is there a simple way to choose the blocks’ colour during instantiation, so that I can make it depend on a variable stored in the matrix mentioned above?

Thanks for any advice!

C# has syntax for multidimensional arrays similar to that in Pascal. Example:

bool[,,] matrix = new bool[3,3,3];
for(int i = 0; i < 3; i++)
    for(int j = 0; j < 3; j++)
        for(int k = 0; k < 3; k++)
            matrix[i, j, k] = (i + j + k) % 3 == 0;

As for materials, you can set their color at runtime like this:

yourGameObject.renderer.material.color =; // Or whatever you want