void generateMapImage() { mapImage = new Texture2D(100, 100); Color emptySpaceColor = Color.black;//.setAlphaToZero(); mapImage.setColor(emptySpaceColor); int amountOfProvince; if (Game.devMode) { amountOfProvince = 10; } else { amountOfProvince = 12 + Game.random.Next(8); } //amountOfProvince = 30 + Game.random.Next(10); for (int i = 0; i < amountOfProvince; i++) { mapImage.SetPixel(mapImage.getRandomX(), mapImage.getRandomY(), UtilsMy.getRandomColor()); } uint emptyPixels = uint.MaxValue; Color currentColor = mapImage.GetPixel(0, 0); uint emergencyExit = 0; while (emptyPixels != 0 && emergencyExit < 100) { emergencyExit++; emptyPixels = 0; for (int j = 0; j < mapImage.height; j++) // cicle by province { for (int i = 0; i < mapImage.width; i++) { currentColor = mapImage.GetPixel(i, j); if (currentColor == emptySpaceColor) { emptyPixels++; } else if (currentColor.a == 1f) { mapImage.drawRandomSpot(i, j, currentColor); } } } mapImage.setAlphaToMax(); } mapImage.Apply(); }
public static string generateWord(int length) { Game.threadDangerSB.Clear(); if (Game.random.Next(10) == 1) { Game.threadDangerSB.Append(vowels.getRandom()); if (Game.random.Next(2) == 1) { Game.threadDangerSB.Append(consonants.getRandom()); } } //if (Game.random.Next(6) == 1) // Game.threadDangerSB.Append(consonants.getRandom()); for (int i = 0; i < length; i += 2) { Game.threadDangerSB.Append(consonants.getRandom()).Append(vowels.getRandom()); if (Game.random.Next(5) == 1 || length == 2) { Game.threadDangerSB.Append(consonants.getRandom()); } } return(UtilsMy.FirstLetterToUpper(Game.threadDangerSB.ToString())); }