private int RandomWeightedIndex(codeProbability[] array) { float value = GameGlobal.RandomFloat(0.0f, 1.0f); int index = 0; while (array.Length > index + 1 && value > array[index + 1].probability) { value -= array[index++].probability; } return(array[index].type); }
private float[] GetRandomDistribution() { float[] result = new float[Globals.StatTypeCount]; float total = 0; for (int i = 0; i < Globals.StatTypeCount; i++) { result[i] = GameGlobal.RandomFloat(0.0f, 10.0f); total += result[i]; } for (int i = 0; i < Globals.StatTypeCount; i++) { result[i] = result[i] / total; } return(result); }