// dummy second param
        public uint PlaySoundIndex(int in_index, bool bReturn)
        {
            uint toReturn = 0;

            if (in_index < m_indexSounds.Length)
            {
                toReturn = PlaySound(m_indexSounds[in_index], false);
            }
            else
            {
                GDebug.LogWarning("Invalid PlaySoundIndex index!");
            }
            return(toReturn);
        }
示例#2
0
        private IEnumerator SafeOnAnimationEvent(object in_name)
        {
            yield return(YieldFactory.GetWaitForEndOfFrame());

            string name = (string)in_name;

            if (m_arEventListeners != null && m_arEventListeners.ContainsKey(name))
            {
                m_arEventListeners[name](this);
            }
            else
            {
                GDebug.LogWarning("Animation event key not found : " + name, gameObject);
            }
        }
示例#3
0
        public void LoadSoundConfig(string in_jsonConfig)
        {
            JsonReader reader = new JsonReader(in_jsonConfig);
            JsonData   root   = JsonMapper.ToObject(reader);
            JsonData   jObject;

            AudioData newData         = null;
            string    keyValue        = "";
            string    assetBundleName = "";
            string    fileName        = "";

            string[] fileNames = null;
            for (int i = 0; i < root.Count; ++i)
            {
                jObject = root[i];
                newData = null;
                try
                {
                    keyValue = (string)jObject[SOUND_KEY];

                    try
                    {
                        fileName = ((string)jObject[FILE_NAME_KEY]).Trim();
                    }
                    catch (System.Exception) { fileName = ""; }

                    try
                    {
                        assetBundleName = (string)jObject[ASSET_BUNDLE_KEY];
                    }
                    catch (System.Exception) { assetBundleName = ""; }

                    try
                    {
                        fileNames = ((string)jObject[FILE_NAMES_KEY]).Split(',');
                        for (int index = 0; index < fileNames.Length; ++index)
                        {
                            fileNames[index] = fileNames[index].Trim();
                        }
                    }
                    catch (System.Exception) { fileNames = null; }

                    newData = new AudioData(keyValue,
                                            assetBundleName,
                                            fileName,
                                            fileNames,
                                            (float)(double)jObject[VOLUME_KEY],
                                            (bool)jObject[LOOP_KEY]
                                            );
                    // set fade amount
                    try
                    {
                        newData.FadeAmount = (float)(double)jObject[FADE_AMOUNT_KEY];
                    }
                    catch (System.Exception) { }

                    // set fade out time
                    try
                    {
                        newData.FadeOutTime = (float)(double)jObject[FADE_OUT_TIME_KEY];
                    }
                    catch (System.Exception) { }

                    // set probability
                    try
                    {
                        newData.Probability = (float)(double)jObject[PROBABILITY_KEY];
                    }
                    catch (System.Exception) { }

                    // set the audio type
                    try
                    {
                        string tempType = (string)jObject[AUDIO_TYPE_KEY];
                        if (tempType == "effect")
                        {
                            newData.AudioType = AudioData.eAudioType.effect;
                        }
                        else if (tempType == "music")
                        {
                            newData.AudioType = AudioData.eAudioType.music;
                        }
                        else if (tempType == "voice")
                        {
                            newData.AudioType = AudioData.eAudioType.voice;
                        }
                    }
                    catch (System.Exception) { }
                }
                catch (System.Exception)
                {
                }

                if (newData != null)
                {
                    if (!m_audioLookupData.ContainsKey(keyValue))
                    {
                        m_audioLookupData[keyValue] = newData;
                    }
                    else
                    {
                        GDebug.LogWarning("Attempted to add new AudioData " + keyValue + ", but it already exists.  No action taken.  Have you tried unloading a previous config file");
                    }
                }
            }
        }