Exemplo n.º 1
0
    public void PlaySound3D(int audioClipId, Vector3 position, float volume, float pitch)
    {
        if (!GameData.Instance().M_SettingData.m_SoundOn)
        {
            return;
        }
        AudioClip ac = map [audioClipId];

        if (ac != null)
        {
            if (waitPlaySoundData3Ds.Count < MAX_NUM)
            {
                PlaySoundData psd = PlaySoundData.Instance().pools.Obtain();
                psd.clip     = ac;
                psd.volume   = volume;
                psd.pitch    = pitch;
                psd.position = position;
                waitPlaySoundData3Ds.Add(psd);
            }
        }
        else
        {
            DebuggerUtil.LogError(" Sound Manager play3D, the audio clip is null");
        }
    }
Exemplo n.º 2
0
    private void PlaySound(Bytes.Data data)
    {
        PlaySoundData soundData = (PlaySoundData)data;
        float         vol       = soundData.Volume * source.volume;

        if (soundData.Volume == -1)
        {
            vol = source.volume;
        }

        string variation = "";

        if (soundData.NbVariations > 1)
        {
            variation = "_" + Random.Range(1, soundData.NbVariations).ToString();
        }
        AudioClip clip = Resources.Load <AudioClip>("Sounds/" + soundData.Name + variation);

        if (clip != null)
        {
            source.PlayOneShot(clip, vol);
        }
        //else
        //Debug.LogError("Sounds/" + soundData.Name + " doesnt exist!");
    }
Exemplo n.º 3
0
 public static PlaySoundData Instance()
 {
     if (g_Instance == null)
     {
         g_Instance = new PlaySoundData();
     }
     return(g_Instance);
 }
Exemplo n.º 4
0
    private void PlaySound(Bytes.Data data)
    {
        PlaySoundData soundData = (PlaySoundData)data;
        float         vol       = source.volume / 2f;
        //if (soundData.Volume == -1) { vol = source.volume; }

        AudioClip clip = Resources.Load <AudioClip>("Sounds/" + soundData.Name);

        if (clip != null)
        {
            source.PlayOneShot(clip, vol);
        }
        //else
        //Debug.LogError("Sounds/" + soundData.Name + " doesnt exist!");
    }
Exemplo n.º 5
0
    void Update_WaitPlaySound3D()
    {
        if (waitPlaySoundData3Ds.Count == 0)
        {
            return;
        }
        AudioSource source = GetFreeSource3D();

        if (source != null)
        {
            PlaySoundData psd = waitPlaySoundData3Ds [0];
            psd.Play(source);
            waitPlaySoundData3Ds.RemoveAt(0);
            PlaySoundData.Instance().pools.Free(psd);
        }
    }
Exemplo n.º 6
0
	public static PlaySoundData Instance ()
	{
		if (g_Instance == null)
			g_Instance = new PlaySoundData ();
		return g_Instance;
	}