I have a list of 7 colors : Red, Blue, Green, Maroon, Brown, Aqua and Black.
In my program I have it so you click on a box, and then the box gets filled with a colour. I want it to be a random colour (from my list of 7 colours) for every box, which I have managed to do below:
Random random = new Random();
int randomColour = random.Next(0,6);
if (e.Button == MouseButtons.Left)
{
//got the y values of the grid
//got the x values of the grid
//Randomize The Colours
if (randomColour == 0)
{
Form.GetTile(x, y).FrontColour = Color.Red;
Score = Score + 1;
}
else if (randomColour == 1)
{
Form.GetTile(x, y).FrontColour = Color.Blue;
Score = Score + 2;
}
else if (randomColour == 2)
{
Form.GetTile(x, y).FrontColour = Color.Maroon;
Score = Score + 5;
}
else if (randomColour == 3)
{
Form.GetTile(x, y).FrontColour = Color.Aqua;
Score = Score + 10;
}
else if (randomColour == 4)
{
Form.GetTile(x, y).FrontColour = Color.Black;
Score = Score - 3;
}
else if (randomColour == 5)
{
Form.GetTile(x, y).FrontColour = Color.Brown;
Score = Score - 1;
}
else if (randomColour == 6)
{
Form.GetTile(x, y).FrontColour = Color.Green;
Score = Score + 3;
}
However, I want to set up my code so there can only be a maximum of 20 red boxes, 20 blue boxes, 5 green, 5 brown, 4 aqua, 5 maroon, and 5 black.
This should be the output, except more shuffled.
The Form.GetTile(x,y).FrontColour is a property that I am accessing from another class that changes the colours of the box