public void DeRegister(RandomCuePlayer player) { if (m_players.Contains(player)) { m_players.Remove(player); } }
public void Register(RandomCuePlayer player) { if (!m_players.Contains(player)) { m_players.Add(player); } }
void UpdatePlayer(RandomCuePlayer player, Vector3 listenerPosition) { if (player.CueList == null || player.CueList.AudioClips.Length == 0) { return; } if (player.CheckDistance) { if (Vector3.Distance(listenerPosition, player.transform.position) < player.MinDistance) { return; } } player.TTL -= Time.deltaTime; if (player.TTL <= 0) { if (player.CurrentState == RandomCuePlayer.State.Delay) { int rnd = UnityEngine.Random.Range(0, player.CueList.AudioClips.Length - 1); player.AudioSource.Stop(); player.AudioSource.clip = player.CueList.AudioClips[rnd]; player.AudioSource.Play(); player.CurrentState = RandomCuePlayer.State.Playing; } else { if (!player.AudioSource.isPlaying && player.CurrentState == RandomCuePlayer.State.Playing) { player.Delay(); } } } }