コード例 #1
0
        public static bool GetBoolean(float chance, int checkInterval)
        {
            if (checkInterval <= 0)
            {
                return(StrongRandom.Next(0, 1000) < (int)(chance * 1000.0f));
            }

            if (Environment.TickCount - _lastCheckedTime < checkInterval)
            {
                return(false);
            }

            _lastCheckedTime = Environment.TickCount;

            return(StrongRandom.Next(0, 1000) < (int)(chance * 1000.0f));
        }
コード例 #2
0
        /// <summary>
        /// Gets a random integer value in range
        /// </summary>
        /// <param name="abs">Return the absolute value.</param>
        /// <returns></returns>
        public static int GetInteger(int min, int max, bool abs)
        {
            var result = StrongRandom.Next(min, max);

            return(abs ? Math.Abs(result) : result);
        }