- Home /
Procedural construction
So I've been working on a little roguelike idea of mine, and I'm having trouble implementing it.
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.
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!
Answer by dan19 · Jul 28, 2013 at 02:34 PM
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 = Color.blue; // Or whatever you want
Your answer
Follow this Question
Related Questions
noobHell, prefab arrays, GameObjects, Random Spawning 1 Answer
How can I store different number of values using lists and arrays? 0 Answers
Skybox color pls help! 1 Answer
How do you change the tint of an entire material array for differing objects? 1 Answer
Make a GameObject changes between 2 colors with a time wait 1 Answer