2 using System.Collections.Generic;
4 namespace HKI.Core.Audio
18 [CreateAssetMenu(fileName =
"Playlist", menuName =
"HKI/Audio/Playlist", order = 0)]
25 RandomShuffelWithProtection,
34 [SerializeField] List<SoundClip> Clips =
new List<SoundClip>();
41 public int GetNumberOfClips {
get {
return Clips.Count; } }
61 index = (index + 1) % Clips.Count;
63 switch(PlaylistPlayType)
69 return Clips[shuffleList[index]];
72 return Clips[Random.Range(0, Clips.Count)];
84 if(
string.IsNullOrEmpty(name))
87 for(
int i = 0; i < Clips.Count; i++)
89 if(Clips[i].name == name)
98 if(
string.IsNullOrEmpty(name))
101 for(
int i = 0; i < Clips.Count; i++)
103 if (Clips[i].ClipId == clipId)
140 int count = Clips.Count;
141 int last = count - 1;
143 int lastIndex = shuffleList[last];
145 for(
int i = 0; i < count; ++i)
147 int rand = Random.Range(i, count);
148 int tmp = shuffleList[i];
149 shuffleList[i] = shuffleList[rand];
150 shuffleList[rand] = tmp;
153 if(count > 1 && shuffleList[0] == lastIndex)
155 int rand = Random.Range(1, count);
156 shuffleList[0] = shuffleList[rand];
157 shuffleList[rand] = lastIndex;
162 int count = Clips.Count;
163 int last = count - 1;
164 for(
int i = 0; i < count; ++i)
166 int rand = Random.Range(i, count);
167 int tmp = shuffleList[i];
168 shuffleList[i] = shuffleList[rand];
169 shuffleList[rand] = tmp;
176 shuffleList =
new List<int>();
177 for (
int i = 0; i < Clips.Count; i++)
SimpleAudioPlayer VoicesAudioPlayer
This ScriptableObject contains the data of a playlist for the AudioPlayer.
SimpleAudioPlayer UiFxAudioPlayer
void ChangePlaylist(Playlist playlist)
void ChangeVoicesPlaylist(bool playPlaylist=false)
SoundClip GetClipByClipId(int clipId)
SimpleAudioPlayer MusicAudioPlayer
static AudioSystem Instance
The AudioSystem is responsble of the creation and access of the general purpose AudioPlayers.
SimpleAudioPlayer FxAudioPlayer
void ChangeAmbientPlaylist(bool playPlaylist=true)
SimpleAudioPlayer AmbientAudioPlayer
SoundClip GetClipByName(string name)
void ChangeMusicPlaylist(bool playPlaylist=true)
This is a container ScriptableObject that holds all data required to play a AudioClip.
void ChangeFxPlaylist(bool playPlaylist=false)
void ChangeUiFxPlaylist(bool playPlaylist=false)