Пример #1
0
 public void SetNextClipHolder(string _name)
 {
     for (int i = 0; i < clips.Length; i++)
     {
         if (clips[i].ClipName == _name)
         {
             clipVideo = clips[i];
         }
     }
 }
Пример #2
0
 IEnumerator loadAudioFromCache(string audioPath, string sortName, ClipHolder holder)
 {
     holder.clip = GTResouseManage.Instance().GetOneAudio(audioPath, sortName);
     yield return(holder);
 }
Пример #3
0
    IEnumerator playSoundEff(string key, string sortName, float vol, ulong delay, bool bLoop, bool isSound)
    {
        if (m_EffPlayFlag == false)
        {
            yield break;
        }
        ClipHolder holder = new ClipHolder();

        yield return(StartCoroutine(loadAudioFromCache(key, sortName, holder)));

        if (holder.clip == null)
        {
            yield break;
        }
        string nameStr = sortName + "_" + key;

        if (!catchAudio.ContainsKey(sortName))
        {
            catchAudio [sortName] = new Dictionary <string, GTAudioSource> ();
        }
        Dictionary <string, GTAudioSource> oneSortArr = catchAudio [sortName];

        if (oneSortArr != null)
        {
            if (oneSortArr.ContainsKey(key))
            {
                GTAudioSource sourceOld = oneSortArr [key];
                if (sourceOld != null)
                {
                    if (vol < 0.0f)
                    {
                        vol = 0.1f;
                    }
                    if (isSound)
                    {
                        sourceOld.source.volume = GameSet.bSoundvolume * vol;
                    }
                    else
                    {
                        sourceOld.source.volume = GameSet.bMusicOnvolume * vol;
                    }


                    //if (vol < 0.0f)
                    //{
                    //    sourceOld.source.volume = 0.1f;
                    //}
                    //else
                    //{
                    //    sourceOld.source.volume = vol;
                    //}
                    if (delay != 0)
                    {
                        sourceOld.source.Play(delay);
                    }
                    else
                    {
                        sourceOld.source.Play();
                    }
                    sourceOld.source.loop = !isSound;
                    if (!GameSet.bSoundOn)
                    {
                        sourceOld.source.Stop();
                    }
                }
            }
            else
            {
                GameObject obj = new GameObject(key);
                obj.transform.parent = gameObject.transform;
                AudioSource   source    = obj.AddComponent <AudioSource> ();
                GTAudioSource newSource = new GTAudioSource();

                newSource.sortName = sortName;
                newSource.sortKey  = key;
                newSource.isSound  = isSound;
                if (source != null && holder != null && holder.clip != null)
                {
                    source.clip      = holder.clip;
                    newSource.source = source;
                    oneSortArr [key] = newSource;
                    source.loop      = bLoop;

                    if (vol < 1f)
                    {
                        vol = 1f;
                    }
                    if (isSound)
                    {
                        source.volume = GameSet.bSoundvolume * vol;
                    }
                    else
                    {
                        source.volume = GameSet.bMusicOnvolume * vol;
                    }
                    //if (vol < 1.0f)
                    //{
                    //    source.volume = 1.0f;
                    //}
                    //else
                    //{
                    //    source.volume = vol;
                    //}
                    if (delay != 0)
                    {
                        source.Play(delay);
                    }
                    else
                    {
                        source.Play();
                    }
                    source.loop = !isSound;
                    if (!GameSet.bSoundOn)
                    {
                        source.Stop();
                    }
                }
                else
                {
                    catchAudio.Remove(key);
                    GameObject.Destroy(obj);
                }
            }
        }
    }