private Land CreateLand(Land.LandType landType, int x, int y, Settings.TileSettings tileSettings) { var maxFood = Mathf.Clamp(Random.value, tileSettings.MinFood, tileSettings.MaxFood); var maxAnimals = Mathf.Clamp(Random.value, tileSettings.MinAnimals, tileSettings.MaxAnimals); return(new Land(landType, maxFood, maxAnimals) { X = x, Y = y, }); // using clamp like this will give a bias towards the min/max boundary values }
public static int CountOccurences(List <Land.LandType> list) { int[] occurenceList = new int[list.Count]; Land.LandType[] typelist = new Land.LandType[list.Count]; int counter = 0; int cpt = 0; foreach (var item in list) { // This particular line was legit just copied from stack overflow without any kind of thought put into it. occurenceList[counter++] = ((from temp in list where temp.Equals(item) select temp).Count()); // Once written by the great Ali Laouichi. cpt is a programmer's best tool, you can never use it too much. typelist[cpt++] = item; } int value = Array.IndexOf(occurenceList, occurenceList.Max()); // Bug right here where you're giving it the maximum value instead of a enum type, and thus give the wrong color to each part of land return((int)typelist[value]); }