Exemple #1
0
        /// <summary>
        /// Retrieves a random element from an enumerable list
        /// </summary>
        /// <typeparam name="T">The element type.</typeparam>
        /// <param name="items">The items</param>
        /// <returns></returns>
        T GetRandomElement <T>(IEnumerable <T> items)
        {
            if (items == null || !items.Any())
            {
                throw new Exception($"Invalid items list");
            }

            return(items.ElementAt(Random.Range(items.Count())));
        }
        private int GetStatusIndex()
        {
            if (!config.Randomize)
            {
                return((statusIndex + 1) % config.Status.Count);
            }

            var index = 0;

            do
            {
                index = Random.Range(0, config.Status.Count - 1);
            }while (index == statusIndex);

            return(index);
        }
 private static string GetRandomCode()
 {
     return(Random.Range(1000, 9999).ToString());
 }
Exemple #4
0
 /// <summary>
 /// Gets called whenever the server saves
 /// </summary>
 void OnServerSave()
 {
     timer.Once(Random.Range(60), () => _settings.Save(FILE_USER_SETTINGS));
 }