Exemple #1
0
        /** @fn     void PlayLoop( string strCueName, int nLoopCount )
         *  @brief  play a sound cue a specified number of times
         *  @param  strCueName [in] the name of the cue to play
         *  @param  nLoopCount [in] the number of times to play the cue, or -1 to play infinitely
         */
        public void PlayLoop(string strCueName, int nLoopCount)
        {
            if (m_waveBank.IsPrepared)
            {
                SoundCue tempCue = new SoundCue(m_soundBank.GetCue(strCueName));
                tempCue.LoopCount = nLoopCount - 1;
                tempCue.Play();

                m_lstSoundsPlaying.Add(tempCue);
            }
        }
Exemple #2
0
        /** @fn     void StopCue( string strName )
         *  @brief  stop all playing occurences of a specific sound cue
         *  @param  strName [in] the name of the cue(s) to stop
         */
        public void StopCue(string strName)
        {
            for (int i = 0; i < m_lstSoundsPlaying.Count; ++i)
            {
                SoundCue cue = m_lstSoundsPlaying[i];
                if (cue.CueName.Equals(strName))
                {
                    cue.Stop();

                    m_lstSoundsPlaying.RemoveAt(i);
                    i--;
                }
            }
        }
Exemple #3
0
        /** @fn     void PlayCue( string strCueName )
         *  @brief  play a cue, one time
         *  @param  strCueName [in] the name of the cue to play
         */
        public void PlayCue(string strCueName)
        {
            if (m_waveBank.IsPrepared)
            {
                try
                {
                    SoundCue tempCue = new SoundCue(m_soundBank.GetCue(strCueName));
                    tempCue.Play();

                    m_lstSoundsPlaying.Add(tempCue);
                }
                catch (Exception e)
                {
                    Error.Trace("PlayCue Error: " + e.Message);
                }
            }
        }
Exemple #4
0
        /** @fn     void Update()
         *  @brief  update the sound manager - should be done once per frame
         */
        public void Update()
        {
            m_audioEngine.Update();

            ////////////////////////
            //Set the volumes
            m_acMusic.SetVolume(m_fMusicVolume * m_fTotalVolume);
            m_acSounds.SetVolume(m_fSoundVolume * m_fTotalVolume);

            //////////////////////
            //Replay looping sounds and delete finished sounds
            for (int i = 0; i < m_lstSoundsPlaying.Count; ++i)
            {
                SoundCue cue = m_lstSoundsPlaying[i];

                if (cue.IsPlaying == false)
                {
                    if (cue.LoopCount != 0)
                    {
                        SoundCue newCue = new SoundCue(m_soundBank.GetCue(cue.CueName));
                        newCue.LoopCount = cue.LoopCount - 1;

                        newCue.Play();

                        m_lstSoundsPlaying.RemoveAt(i);
                        i--;
                        m_lstSoundsPlaying.Add(newCue);
                    }
                    else //loop count IS 0
                    {
                        m_lstSoundsPlaying.RemoveAt(i);
                        --i;
                    }
                }
            }
        }