Exemplo n.º 1
0
        /// <summary>
        /// Overload: Gets the next random entry. Refills depending on passed LotteryMode.
        /// </summary>
        /// <param name="mode">The mode to determine how to behave, when copied list is empty.</param>
        /// <returns>Returns next entry or default(T), depending on mode.</returns>
        public T DrawNext(LotteryMode mode)
        {
            if (IsEmtpy())
            {
                switch (mode)
                {
                case LotteryMode.RefillOnEmpty:
                    CopyEntries();
                    break;

                case LotteryMode.RemoveOnEmpty:
                    LotteryManager <T> .Remove(Collection);

                    return(default(T));

                case LotteryMode.None:
                    return(default(T));
                }
            }
            var id   = UnityEngine.Random.Range(0, CollectionCopy.Count);
            var temp = CollectionCopy[id];

            CollectionCopy.Remove(CollectionCopy[id]);
            return(temp);
        }
Exemplo n.º 2
0
 // Disables remembering which elements of the passed IList<T> have been already returned
 // by removing from an internal tracking dictionary
 public static void Remove <T>(this IList <T> collection)
 {
     Debug.Log("Removed: " + collection.GetType());
     LotteryManager <T> .Remove(collection);
 }