Esempio n. 1
0
        private Color GetStartColor()
        {
            Color startColor;

            if (loopAllColors)
            {
                if (randomFirstColor)
                {
                    startColor = new Color(MyRandom.NextFloat(), MyRandom.NextFloat(), MyRandom.NextFloat(), 1);
                }
                else
                {
                    startColor = genericRenderer.Color;
                }
            }
            else
            {
                if (colorsToChange.Length == 0)
                {
                    Debug.LogError("ColorsToChange need be greather than 1");
                }

                startColor      = colorsToChange[0];
                atualColorIndex = 1;
            }

            return(startColor);
        }
Esempio n. 2
0
        /// <summary>
        ///  Return true or false based on a probability of "0.0 to 1.0"
        /// </summary>
        public static bool Chance(float probability)
        {
            int randint = MyRandom.Next(0, 101);

            return((probability * 100) >= randint);
        }
Esempio n. 3
0
        /// <summary>
        /// Choice and return a random value of the collection.
        /// </summary>
        public static T ChoiceAnyOne <T>(this IReadOnlyList <T> collection)
        {
            int index = MyRandom.Next(0, collection.Count);

            return(collection[index]);
        }