예제 #1
0
        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);
        }
예제 #2
0
        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);
        }