using System; using Enums; using Random = UnityEngine.Random; namespace Utils { public static class RandomUtils { private static readonly GemType[] SPAWNABLE_GEMS = BuildSpawnableGems(); private static GemType[] BuildSpawnableGems() { Array values = Enum.GetValues(typeof(GemType)); int count = 0; for (int i = 0; i < values.Length; i++) { if ((GemType)values.GetValue(i) != GemType.Bomb) count++; } GemType[] result = new GemType[count]; int write = 0; for (int i = 0; i < values.Length; i++) { GemType t = (GemType)values.GetValue(i); if (t == GemType.Bomb) continue; result[write++] = t; } return result; } public static GemType RandomGemType() { return SPAWNABLE_GEMS[Random.Range(0, SPAWNABLE_GEMS.Length)]; } } }