コード例 #1
0
 public void DeRegister(RandomCuePlayer player)
 {
     if (m_players.Contains(player))
     {
         m_players.Remove(player);
     }
 }
コード例 #2
0
 public void Register(RandomCuePlayer player)
 {
     if (!m_players.Contains(player))
     {
         m_players.Add(player);
     }
 }
コード例 #3
0
        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();
                    }
                }
            }
        }