コード例 #1
0
        /// <summary>
        /// Will actually start playing, but assumes
        /// accompanying bookkeeping has been done. Use Play(list) instead.
        /// </summary>
        internal AudioCue Play(GameThing emitter)
        {
            AudioCue cue = BokuGame.Audio.GetCue(cuename, emitter, Spatial);

            cue.Play();
            cue.Sound = this;
            cues.Add(cue);
            return(cue);
        }
コード例 #2
0
            }   // end of Playing()

            #endregion

            #region Internal

            private void Restart(AudioCue audioCue, GameThing emitter)
            {
                audioCue.Reset();
                Cue cue = BokuGame.Audio.SoundBank.GetCue(soundName);

                audioCue.Set(cue, emitter);
                audioCue.Play();
                frame    = Time.FrameCounter;
                lastTime = Time.WallClockTotalSeconds;
            }   // end of Restart()
コード例 #3
0
            /// <summary>
            /// Play a spacialized sound attatched to a GameThing.
            /// </summary>
            /// <param name="emitter"></param>
            public void Play(GameThing emitter)
            {
                // Don't allow mute actors to make noise.
                GameActor actor = emitter as GameActor;

                if (actor != null && actor.Mute)
                {
                    return;
                }

                // If a singleton and already playing, ignore this call.
                if (singleton && Playing(emitter))
                {
                    return;
                }

                if (BokuGame.Audio.Enabled)
                {
                    // Ensure we haven't already played this sound this frame.
                    if (frame == Time.FrameCounter)
                    {
                        return;
                    }

                    // Make sure enough time has elapsed.
                    double dt = Time.WallClockTotalSeconds - lastTime;
                    if (dt < timeGap)
                    {
                        return;
                    }

                    AudioCue cue = BokuGame.Audio.GetCue(soundName, emitter, true);
                    cue.Play();
                    frame    = Time.FrameCounter;
                    lastTime = Time.WallClockTotalSeconds;
                } // end if enabled.
            }     // end of Play()
コード例 #4
0
            }     // end of Play()

            /// <summary>
            /// Play a spacialized sound from a fixed position.
            /// </summary>
            /// <param name="position">Where the sound is coming from.</param>
            /// <param name="volume">In range 0..1</param>
            public void Play(Vector3 position, float volume)
            {
                if (BokuGame.Audio.Enabled)
                {
                    // Ensure we haven't already played this sound this frame.
                    if (frame == Time.FrameCounter)
                    {
                        return;
                    }

                    // Make sure enough time has elapsed.
                    double dt = Time.WallClockTotalSeconds - lastTime;
                    if (dt < timeGap)
                    {
                        return;
                    }

                    AudioCue cue = BokuGame.Audio.GetCue(soundName, position);
                    cue.SetVolume(volume);
                    cue.Play();
                    frame    = Time.FrameCounter;
                    lastTime = Time.WallClockTotalSeconds;
                } // end if enabled.
            }     // end of Play()