WizardDuels/WizardDuelsProject/Assets/Scripts/SoundGroup.cs
2025-03-19 09:23:22 +01:00

26 lines
No EOL
532 B
C#

using System;
using System.Linq;
namespace DefaultNamespace
{
[System.Serializable]
public class SoundGroup
{
public string name;
public Sound[] sounds;
private int index;
public void Play()
{
if (index >= sounds.Length)
{
// Shuffle the sounds
sounds = sounds.OrderBy(s => Guid.NewGuid()).ToArray();
index = 0;
}
sounds[index].source.Play();
index++;
}
}
}