AwesomeRunner/Assets/Scripts/Extentions/RandomExtentions.cs
VladimirPirozhenko 4fa18a41a0 Changed animation strings to hashes, added IPoolable interface, upgrade pool system
Change generation of obstacles
Now all the important objects is cointained by pools
2022-08-09 22:23:49 +03:00

24 lines
614 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class RandomExtentions
{
public static bool IsEmpty<T>(this List<T> list)
{
return list.Count == 0 ? true : false;
}
public static T GetRandomElement<T>(this List<T> list)
{
return list[Random.Range(0, list.Count)];
}
public static bool GetRandomElement<T>(this List<T> list, out T element)
{
element = default(T);
if (list.IsEmpty())
return false;
element = list[Random.Range(0, list.Count)];
return true;
}
}