30 lines
837 B
C#
30 lines
837 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Random = System.Random;
|
|
|
|
namespace Util
|
|
{
|
|
[CreateAssetMenu(fileName = "Effect", menuName = "Effects/EffectData")]
|
|
public class Effect : ScriptableObject
|
|
{
|
|
private static readonly Random RandomSound = new Random();
|
|
|
|
public List<string> listOfSounds;
|
|
|
|
public GameObject effect;
|
|
public bool autoDestroy = true;
|
|
public float liveTime = 1f;
|
|
|
|
|
|
public static T ChooseRandom<T>(List<T> list)
|
|
{
|
|
if (list == null || list.Count == 0)
|
|
{
|
|
throw new ArgumentException($"The list of sounds in Effect should not be empty");
|
|
}
|
|
int index = RandomSound.Next(list.Count);
|
|
return list[index];
|
|
}
|
|
}
|
|
} |